babylon.d.ts 2.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172
  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. let Epsilon: number;
  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 Color3 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. * Adds the translation vector (using 3 floats) in the current matrix
  2943. * @param x defines the 1st component of the translation
  2944. * @param y defines the 2nd component of the translation
  2945. * @param z defines the 3rd component of the translation
  2946. * @returns the current updated matrix
  2947. */
  2948. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2949. /**
  2950. * Inserts the translation vector in the current matrix
  2951. * @param vector3 defines the translation to insert
  2952. * @returns the current updated matrix
  2953. */
  2954. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2955. /**
  2956. * Gets the translation value of the current matrix
  2957. * @returns a new Vector3 as the extracted translation from the matrix
  2958. */
  2959. getTranslation(): Vector3;
  2960. /**
  2961. * Fill a Vector3 with the extracted translation from the matrix
  2962. * @param result defines the Vector3 where to store the translation
  2963. * @returns the current matrix
  2964. */
  2965. getTranslationToRef(result: Vector3): Matrix;
  2966. /**
  2967. * Remove rotation and scaling part from the matrix
  2968. * @returns the updated matrix
  2969. */
  2970. removeRotationAndScaling(): Matrix;
  2971. /**
  2972. * Multiply two matrices
  2973. * @param other defines the second operand
  2974. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2975. */
  2976. multiply(other: DeepImmutable<Matrix>): Matrix;
  2977. /**
  2978. * Copy the current matrix from the given one
  2979. * @param other defines the source matrix
  2980. * @returns the current updated matrix
  2981. */
  2982. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2983. /**
  2984. * Populates the given array from the starting index with the current matrix values
  2985. * @param array defines the target array
  2986. * @param offset defines the offset in the target array where to start storing values
  2987. * @returns the current matrix
  2988. */
  2989. copyToArray(array: Float32Array, offset?: number): Matrix;
  2990. /**
  2991. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2992. * @param other defines the second operand
  2993. * @param result defines the matrix where to store the multiplication
  2994. * @returns the current matrix
  2995. */
  2996. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2997. /**
  2998. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2999. * @param other defines the second operand
  3000. * @param result defines the array where to store the multiplication
  3001. * @param offset defines the offset in the target array where to start storing values
  3002. * @returns the current matrix
  3003. */
  3004. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3005. /**
  3006. * Check equality between this matrix and a second one
  3007. * @param value defines the second matrix to compare
  3008. * @returns true is the current matrix and the given one values are strictly equal
  3009. */
  3010. equals(value: DeepImmutable<Matrix>): boolean;
  3011. /**
  3012. * Clone the current matrix
  3013. * @returns a new matrix from the current matrix
  3014. */
  3015. clone(): Matrix;
  3016. /**
  3017. * Returns the name of the current matrix class
  3018. * @returns the string "Matrix"
  3019. */
  3020. getClassName(): string;
  3021. /**
  3022. * Gets the hash code of the current matrix
  3023. * @returns the hash code
  3024. */
  3025. getHashCode(): number;
  3026. /**
  3027. * Decomposes the current Matrix into a translation, rotation and scaling components
  3028. * @param scale defines the scale vector3 given as a reference to update
  3029. * @param rotation defines the rotation quaternion given as a reference to update
  3030. * @param translation defines the translation vector3 given as a reference to update
  3031. * @returns true if operation was successful
  3032. */
  3033. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3034. /**
  3035. * Gets specific row of the matrix
  3036. * @param index defines the number of the row to get
  3037. * @returns the index-th row of the current matrix as a new Vector4
  3038. */
  3039. getRow(index: number): Nullable<Vector4>;
  3040. /**
  3041. * Sets the index-th row of the current matrix to the vector4 values
  3042. * @param index defines the number of the row to set
  3043. * @param row defines the target vector4
  3044. * @returns the updated current matrix
  3045. */
  3046. setRow(index: number, row: Vector4): Matrix;
  3047. /**
  3048. * Compute the transpose of the matrix
  3049. * @returns the new transposed matrix
  3050. */
  3051. transpose(): Matrix;
  3052. /**
  3053. * Compute the transpose of the matrix and store it in a given matrix
  3054. * @param result defines the target matrix
  3055. * @returns the current matrix
  3056. */
  3057. transposeToRef(result: Matrix): Matrix;
  3058. /**
  3059. * Sets the index-th row of the current matrix with the given 4 x float values
  3060. * @param index defines the row index
  3061. * @param x defines the x component to set
  3062. * @param y defines the y component to set
  3063. * @param z defines the z component to set
  3064. * @param w defines the w component to set
  3065. * @returns the updated current matrix
  3066. */
  3067. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3068. /**
  3069. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3070. * @param scale defines the scale factor
  3071. * @returns a new matrix
  3072. */
  3073. scale(scale: number): Matrix;
  3074. /**
  3075. * Scale the current matrix values by a factor to a given result matrix
  3076. * @param scale defines the scale factor
  3077. * @param result defines the matrix to store the result
  3078. * @returns the current matrix
  3079. */
  3080. scaleToRef(scale: number, result: Matrix): Matrix;
  3081. /**
  3082. * Scale the current matrix values by a factor and add the result to a given matrix
  3083. * @param scale defines the scale factor
  3084. * @param result defines the Matrix to store the result
  3085. * @returns the current matrix
  3086. */
  3087. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3088. /**
  3089. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3090. * @param ref matrix to store the result
  3091. */
  3092. toNormalMatrix(ref: Matrix): void;
  3093. /**
  3094. * Gets only rotation part of the current matrix
  3095. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3096. */
  3097. getRotationMatrix(): Matrix;
  3098. /**
  3099. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3100. * @param result defines the target matrix to store data to
  3101. * @returns the current matrix
  3102. */
  3103. getRotationMatrixToRef(result: Matrix): Matrix;
  3104. /**
  3105. * Toggles model matrix from being right handed to left handed in place and vice versa
  3106. */
  3107. toggleModelMatrixHandInPlace(): void;
  3108. /**
  3109. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3110. */
  3111. toggleProjectionMatrixHandInPlace(): void;
  3112. /**
  3113. * Creates a matrix from an array
  3114. * @param array defines the source array
  3115. * @param offset defines an offset in the source array
  3116. * @returns a new Matrix set from the starting index of the given array
  3117. */
  3118. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3119. /**
  3120. * Copy the content of an array into a given matrix
  3121. * @param array defines the source array
  3122. * @param offset defines an offset in the source array
  3123. * @param result defines the target matrix
  3124. */
  3125. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3126. /**
  3127. * Stores an array into a matrix after having multiplied each component by a given factor
  3128. * @param array defines the source array
  3129. * @param offset defines the offset in the source array
  3130. * @param scale defines the scaling factor
  3131. * @param result defines the target matrix
  3132. */
  3133. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3134. /**
  3135. * Gets an identity matrix that must not be updated
  3136. */
  3137. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3138. /**
  3139. * Stores a list of values (16) inside a given matrix
  3140. * @param initialM11 defines 1st value of 1st row
  3141. * @param initialM12 defines 2nd value of 1st row
  3142. * @param initialM13 defines 3rd value of 1st row
  3143. * @param initialM14 defines 4th value of 1st row
  3144. * @param initialM21 defines 1st value of 2nd row
  3145. * @param initialM22 defines 2nd value of 2nd row
  3146. * @param initialM23 defines 3rd value of 2nd row
  3147. * @param initialM24 defines 4th value of 2nd row
  3148. * @param initialM31 defines 1st value of 3rd row
  3149. * @param initialM32 defines 2nd value of 3rd row
  3150. * @param initialM33 defines 3rd value of 3rd row
  3151. * @param initialM34 defines 4th value of 3rd row
  3152. * @param initialM41 defines 1st value of 4th row
  3153. * @param initialM42 defines 2nd value of 4th row
  3154. * @param initialM43 defines 3rd value of 4th row
  3155. * @param initialM44 defines 4th value of 4th row
  3156. * @param result defines the target matrix
  3157. */
  3158. 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;
  3159. /**
  3160. * Creates new matrix from a list of values (16)
  3161. * @param initialM11 defines 1st value of 1st row
  3162. * @param initialM12 defines 2nd value of 1st row
  3163. * @param initialM13 defines 3rd value of 1st row
  3164. * @param initialM14 defines 4th value of 1st row
  3165. * @param initialM21 defines 1st value of 2nd row
  3166. * @param initialM22 defines 2nd value of 2nd row
  3167. * @param initialM23 defines 3rd value of 2nd row
  3168. * @param initialM24 defines 4th value of 2nd row
  3169. * @param initialM31 defines 1st value of 3rd row
  3170. * @param initialM32 defines 2nd value of 3rd row
  3171. * @param initialM33 defines 3rd value of 3rd row
  3172. * @param initialM34 defines 4th value of 3rd row
  3173. * @param initialM41 defines 1st value of 4th row
  3174. * @param initialM42 defines 2nd value of 4th row
  3175. * @param initialM43 defines 3rd value of 4th row
  3176. * @param initialM44 defines 4th value of 4th row
  3177. * @returns the new matrix
  3178. */
  3179. 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;
  3180. /**
  3181. * Creates a new matrix 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. * @returns a new matrix
  3186. */
  3187. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3188. /**
  3189. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3190. * @param scale defines the scale vector3
  3191. * @param rotation defines the rotation quaternion
  3192. * @param translation defines the translation vector3
  3193. * @param result defines the target matrix
  3194. */
  3195. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3196. /**
  3197. * Creates a new identity matrix
  3198. * @returns a new identity matrix
  3199. */
  3200. static Identity(): Matrix;
  3201. /**
  3202. * Creates a new identity matrix and stores the result in a given matrix
  3203. * @param result defines the target matrix
  3204. */
  3205. static IdentityToRef(result: Matrix): void;
  3206. /**
  3207. * Creates a new zero matrix
  3208. * @returns a new zero matrix
  3209. */
  3210. static Zero(): Matrix;
  3211. /**
  3212. * Creates a new rotation matrix for "angle" radians around the X axis
  3213. * @param angle defines the angle (in radians) to use
  3214. * @return the new matrix
  3215. */
  3216. static RotationX(angle: number): Matrix;
  3217. /**
  3218. * Creates a new matrix as the invert of a given matrix
  3219. * @param source defines the source matrix
  3220. * @returns the new matrix
  3221. */
  3222. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3223. /**
  3224. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3225. * @param angle defines the angle (in radians) to use
  3226. * @param result defines the target matrix
  3227. */
  3228. static RotationXToRef(angle: number, result: Matrix): void;
  3229. /**
  3230. * Creates a new rotation matrix for "angle" radians around the Y axis
  3231. * @param angle defines the angle (in radians) to use
  3232. * @return the new matrix
  3233. */
  3234. static RotationY(angle: number): Matrix;
  3235. /**
  3236. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3237. * @param angle defines the angle (in radians) to use
  3238. * @param result defines the target matrix
  3239. */
  3240. static RotationYToRef(angle: number, result: Matrix): void;
  3241. /**
  3242. * Creates a new rotation matrix for "angle" radians around the Z axis
  3243. * @param angle defines the angle (in radians) to use
  3244. * @return the new matrix
  3245. */
  3246. static RotationZ(angle: number): Matrix;
  3247. /**
  3248. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3249. * @param angle defines the angle (in radians) to use
  3250. * @param result defines the target matrix
  3251. */
  3252. static RotationZToRef(angle: number, result: Matrix): void;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the given axis
  3255. * @param axis defines the axis to use
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3262. * @param axis defines the axis to use
  3263. * @param angle defines the angle (in radians) to use
  3264. * @param result defines the target matrix
  3265. */
  3266. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3267. /**
  3268. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3269. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3270. * @param from defines the vector to align
  3271. * @param to defines the vector to align to
  3272. * @param result defines the target matrix
  3273. */
  3274. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3275. /**
  3276. * Creates a rotation matrix
  3277. * @param yaw defines the yaw angle in radians (Y axis)
  3278. * @param pitch defines the pitch angle in radians (X axis)
  3279. * @param roll defines the roll angle in radians (X axis)
  3280. * @returns the new rotation matrix
  3281. */
  3282. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3283. /**
  3284. * Creates a rotation matrix and stores it in a given matrix
  3285. * @param yaw defines the yaw angle in radians (Y axis)
  3286. * @param pitch defines the pitch angle in radians (X axis)
  3287. * @param roll defines the roll angle in radians (X axis)
  3288. * @param result defines the target matrix
  3289. */
  3290. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3291. /**
  3292. * Creates a scaling matrix
  3293. * @param x defines the scale factor on X axis
  3294. * @param y defines the scale factor on Y axis
  3295. * @param z defines the scale factor on Z axis
  3296. * @returns the new matrix
  3297. */
  3298. static Scaling(x: number, y: number, z: number): Matrix;
  3299. /**
  3300. * Creates a scaling matrix and stores it in a given matrix
  3301. * @param x defines the scale factor on X axis
  3302. * @param y defines the scale factor on Y axis
  3303. * @param z defines the scale factor on Z axis
  3304. * @param result defines the target matrix
  3305. */
  3306. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3307. /**
  3308. * Creates a translation matrix
  3309. * @param x defines the translation on X axis
  3310. * @param y defines the translation on Y axis
  3311. * @param z defines the translationon Z axis
  3312. * @returns the new matrix
  3313. */
  3314. static Translation(x: number, y: number, z: number): Matrix;
  3315. /**
  3316. * Creates a translation matrix and stores it in a given matrix
  3317. * @param x defines the translation on X axis
  3318. * @param y defines the translation on Y axis
  3319. * @param z defines the translationon Z axis
  3320. * @param result defines the target matrix
  3321. */
  3322. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3323. /**
  3324. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3325. * @param startValue defines the start value
  3326. * @param endValue defines the end value
  3327. * @param gradient defines the gradient factor
  3328. * @returns the new matrix
  3329. */
  3330. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3331. /**
  3332. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3333. * @param startValue defines the start value
  3334. * @param endValue defines the end value
  3335. * @param gradient defines the gradient factor
  3336. * @param result defines the Matrix object where to store data
  3337. */
  3338. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3339. /**
  3340. * Builds a new matrix whose values are computed by:
  3341. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3342. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3343. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3344. * @param startValue defines the first matrix
  3345. * @param endValue defines the second matrix
  3346. * @param gradient defines the gradient between the two matrices
  3347. * @returns the new matrix
  3348. */
  3349. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3350. /**
  3351. * Update a matrix to values which are computed by:
  3352. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3353. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3354. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3355. * @param startValue defines the first matrix
  3356. * @param endValue defines the second matrix
  3357. * @param gradient defines the gradient between the two matrices
  3358. * @param result defines the target matrix
  3359. */
  3360. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3361. /**
  3362. * 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"
  3363. * This function works in left handed mode
  3364. * @param eye defines the final position of the entity
  3365. * @param target defines where the entity should look at
  3366. * @param up defines the up vector for the entity
  3367. * @returns the new matrix
  3368. */
  3369. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3370. /**
  3371. * 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".
  3372. * This function works in left handed mode
  3373. * @param eye defines the final position of the entity
  3374. * @param target defines where the entity should look at
  3375. * @param up defines the up vector for the entity
  3376. * @param result defines the target matrix
  3377. */
  3378. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3379. /**
  3380. * 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"
  3381. * This function works in right handed mode
  3382. * @param eye defines the final position of the entity
  3383. * @param target defines where the entity should look at
  3384. * @param up defines the up vector for the entity
  3385. * @returns the new matrix
  3386. */
  3387. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3388. /**
  3389. * 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".
  3390. * This function works in right handed mode
  3391. * @param eye defines the final position of the entity
  3392. * @param target defines where the entity should look at
  3393. * @param up defines the up vector for the entity
  3394. * @param result defines the target matrix
  3395. */
  3396. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3397. /**
  3398. * Create a left-handed orthographic projection matrix
  3399. * @param width defines the viewport width
  3400. * @param height defines the viewport height
  3401. * @param znear defines the near clip plane
  3402. * @param zfar defines the far clip plane
  3403. * @returns a new matrix as a left-handed orthographic projection matrix
  3404. */
  3405. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3406. /**
  3407. * Store a left-handed orthographic projection to a given matrix
  3408. * @param width defines the viewport width
  3409. * @param height defines the viewport height
  3410. * @param znear defines the near clip plane
  3411. * @param zfar defines the far clip plane
  3412. * @param result defines the target matrix
  3413. */
  3414. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3415. /**
  3416. * Create a left-handed orthographic projection matrix
  3417. * @param left defines the viewport left coordinate
  3418. * @param right defines the viewport right coordinate
  3419. * @param bottom defines the viewport bottom coordinate
  3420. * @param top defines the viewport top coordinate
  3421. * @param znear defines the near clip plane
  3422. * @param zfar defines the far clip plane
  3423. * @returns a new matrix as a left-handed orthographic projection matrix
  3424. */
  3425. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3426. /**
  3427. * Stores a left-handed orthographic projection into a given matrix
  3428. * @param left defines the viewport left coordinate
  3429. * @param right defines the viewport right coordinate
  3430. * @param bottom defines the viewport bottom coordinate
  3431. * @param top defines the viewport top coordinate
  3432. * @param znear defines the near clip plane
  3433. * @param zfar defines the far clip plane
  3434. * @param result defines the target matrix
  3435. */
  3436. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3437. /**
  3438. * Creates a right-handed orthographic projection matrix
  3439. * @param left defines the viewport left coordinate
  3440. * @param right defines the viewport right coordinate
  3441. * @param bottom defines the viewport bottom coordinate
  3442. * @param top defines the viewport top coordinate
  3443. * @param znear defines the near clip plane
  3444. * @param zfar defines the far clip plane
  3445. * @returns a new matrix as a right-handed orthographic projection matrix
  3446. */
  3447. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3448. /**
  3449. * Stores a right-handed orthographic projection into a given matrix
  3450. * @param left defines the viewport left coordinate
  3451. * @param right defines the viewport right coordinate
  3452. * @param bottom defines the viewport bottom coordinate
  3453. * @param top defines the viewport top coordinate
  3454. * @param znear defines the near clip plane
  3455. * @param zfar defines the far clip plane
  3456. * @param result defines the target matrix
  3457. */
  3458. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3459. /**
  3460. * Creates a left-handed perspective projection matrix
  3461. * @param width defines the viewport width
  3462. * @param height defines the viewport height
  3463. * @param znear defines the near clip plane
  3464. * @param zfar defines the far clip plane
  3465. * @returns a new matrix as a left-handed perspective projection matrix
  3466. */
  3467. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3468. /**
  3469. * Creates a left-handed perspective projection matrix
  3470. * @param fov defines the horizontal field of view
  3471. * @param aspect defines the aspect ratio
  3472. * @param znear defines the near clip plane
  3473. * @param zfar defines the far clip plane
  3474. * @returns a new matrix as a left-handed perspective projection matrix
  3475. */
  3476. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3477. /**
  3478. * Stores a left-handed perspective projection into a given matrix
  3479. * @param fov defines the horizontal field of view
  3480. * @param aspect defines the aspect ratio
  3481. * @param znear defines the near clip plane
  3482. * @param zfar defines the far clip plane
  3483. * @param result defines the target matrix
  3484. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3485. */
  3486. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3487. /**
  3488. * Creates a right-handed perspective projection matrix
  3489. * @param fov defines the horizontal field of view
  3490. * @param aspect defines the aspect ratio
  3491. * @param znear defines the near clip plane
  3492. * @param zfar defines the far clip plane
  3493. * @returns a new matrix as a right-handed perspective projection matrix
  3494. */
  3495. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3496. /**
  3497. * Stores a right-handed perspective projection into a given matrix
  3498. * @param fov defines the horizontal field of view
  3499. * @param aspect defines the aspect ratio
  3500. * @param znear defines the near clip plane
  3501. * @param zfar defines the far clip plane
  3502. * @param result defines the target matrix
  3503. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3504. */
  3505. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3506. /**
  3507. * Stores a perspective projection for WebVR info a given matrix
  3508. * @param fov defines the field of view
  3509. * @param znear defines the near clip plane
  3510. * @param zfar defines the far clip plane
  3511. * @param result defines the target matrix
  3512. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3513. */
  3514. static PerspectiveFovWebVRToRef(fov: {
  3515. upDegrees: number;
  3516. downDegrees: number;
  3517. leftDegrees: number;
  3518. rightDegrees: number;
  3519. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3520. /**
  3521. * Computes a complete transformation matrix
  3522. * @param viewport defines the viewport to use
  3523. * @param world defines the world matrix
  3524. * @param view defines the view matrix
  3525. * @param projection defines the projection matrix
  3526. * @param zmin defines the near clip plane
  3527. * @param zmax defines the far clip plane
  3528. * @returns the transformation matrix
  3529. */
  3530. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3531. /**
  3532. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3533. * @param matrix defines the matrix to use
  3534. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3535. */
  3536. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3537. /**
  3538. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3539. * @param matrix defines the matrix to use
  3540. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3541. */
  3542. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3543. /**
  3544. * Compute the transpose of a given matrix
  3545. * @param matrix defines the matrix to transpose
  3546. * @returns the new matrix
  3547. */
  3548. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3549. /**
  3550. * Compute the transpose of a matrix and store it in a target matrix
  3551. * @param matrix defines the matrix to transpose
  3552. * @param result defines the target matrix
  3553. */
  3554. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3555. /**
  3556. * Computes a reflection matrix from a plane
  3557. * @param plane defines the reflection plane
  3558. * @returns a new matrix
  3559. */
  3560. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3561. /**
  3562. * Computes a reflection matrix from a plane
  3563. * @param plane defines the reflection plane
  3564. * @param result defines the target matrix
  3565. */
  3566. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3567. /**
  3568. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3569. * @param xaxis defines the value of the 1st axis
  3570. * @param yaxis defines the value of the 2nd axis
  3571. * @param zaxis defines the value of the 3rd axis
  3572. * @param result defines the target matrix
  3573. */
  3574. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3575. /**
  3576. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3577. * @param quat defines the quaternion to use
  3578. * @param result defines the target matrix
  3579. */
  3580. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3581. }
  3582. /**
  3583. * Represens a plane by the equation ax + by + cz + d = 0
  3584. */
  3585. export class Plane {
  3586. /**
  3587. * Normal of the plane (a,b,c)
  3588. */
  3589. normal: Vector3;
  3590. /**
  3591. * d component of the plane
  3592. */
  3593. d: number;
  3594. /**
  3595. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3596. * @param a a component of the plane
  3597. * @param b b component of the plane
  3598. * @param c c component of the plane
  3599. * @param d d component of the plane
  3600. */
  3601. constructor(a: number, b: number, c: number, d: number);
  3602. /**
  3603. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3604. */
  3605. asArray(): number[];
  3606. /**
  3607. * @returns a new plane copied from the current Plane.
  3608. */
  3609. clone(): Plane;
  3610. /**
  3611. * @returns the string "Plane".
  3612. */
  3613. getClassName(): string;
  3614. /**
  3615. * @returns the Plane hash code.
  3616. */
  3617. getHashCode(): number;
  3618. /**
  3619. * Normalize the current Plane in place.
  3620. * @returns the updated Plane.
  3621. */
  3622. normalize(): Plane;
  3623. /**
  3624. * Applies a transformation the plane and returns the result
  3625. * @param transformation the transformation matrix to be applied to the plane
  3626. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3627. */
  3628. transform(transformation: DeepImmutable<Matrix>): Plane;
  3629. /**
  3630. * Calcualtte the dot product between the point and the plane normal
  3631. * @param point point to calculate the dot product with
  3632. * @returns the dot product (float) of the point coordinates and the plane normal.
  3633. */
  3634. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3635. /**
  3636. * Updates the current Plane from the plane defined by the three given points.
  3637. * @param point1 one of the points used to contruct the plane
  3638. * @param point2 one of the points used to contruct the plane
  3639. * @param point3 one of the points used to contruct the plane
  3640. * @returns the updated Plane.
  3641. */
  3642. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3643. /**
  3644. * Checks if the plane is facing a given direction
  3645. * @param direction the direction to check if the plane is facing
  3646. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3647. * @returns True is the vector "direction" is the same side than the plane normal.
  3648. */
  3649. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3650. /**
  3651. * Calculates the distance to a point
  3652. * @param point point to calculate distance to
  3653. * @returns the signed distance (float) from the given point to the Plane.
  3654. */
  3655. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3656. /**
  3657. * Creates a plane from an array
  3658. * @param array the array to create a plane from
  3659. * @returns a new Plane from the given array.
  3660. */
  3661. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3662. /**
  3663. * Creates a plane from three points
  3664. * @param point1 point used to create the plane
  3665. * @param point2 point used to create the plane
  3666. * @param point3 point used to create the plane
  3667. * @returns a new Plane defined by the three given points.
  3668. */
  3669. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3670. /**
  3671. * Creates a plane from an origin point and a normal
  3672. * @param origin origin of the plane to be constructed
  3673. * @param normal normal of the plane to be constructed
  3674. * @returns a new Plane the normal vector to this plane at the given origin point.
  3675. * Note : the vector "normal" is updated because normalized.
  3676. */
  3677. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3678. /**
  3679. * Calculates the distance from a plane and a point
  3680. * @param origin origin of the plane to be constructed
  3681. * @param normal normal of the plane to be constructed
  3682. * @param point point to calculate distance to
  3683. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3684. */
  3685. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3686. }
  3687. /**
  3688. * Class used to represent a viewport on screen
  3689. */
  3690. export class Viewport {
  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 Viewport object located at (x, y) and sized (width, height)
  3701. * @param x defines viewport left coordinate
  3702. * @param y defines viewport top coordinate
  3703. * @param width defines the viewport width
  3704. * @param height defines the viewport height
  3705. */
  3706. constructor(
  3707. /** viewport left coordinate */
  3708. x: number,
  3709. /** viewport top coordinate */
  3710. y: number,
  3711. /**viewport width */
  3712. width: number,
  3713. /** viewport height */
  3714. height: number);
  3715. /**
  3716. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3717. * @param renderWidth defines the rendering width
  3718. * @param renderHeight defines the rendering height
  3719. * @returns a new Viewport
  3720. */
  3721. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3722. /**
  3723. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3724. * @param renderWidth defines the rendering width
  3725. * @param renderHeight defines the rendering height
  3726. * @param ref defines the target viewport
  3727. * @returns the current viewport
  3728. */
  3729. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3730. /**
  3731. * Returns a new Viewport copied from the current one
  3732. * @returns a new Viewport
  3733. */
  3734. clone(): Viewport;
  3735. }
  3736. /**
  3737. * Reprasents a camera frustum
  3738. */
  3739. export class Frustum {
  3740. /**
  3741. * Gets the planes representing the frustum
  3742. * @param transform matrix to be applied to the returned planes
  3743. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3744. */
  3745. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3746. /**
  3747. * Gets the near frustum plane transformed by the transform matrix
  3748. * @param transform transformation matrix to be applied to the resulting frustum plane
  3749. * @param frustumPlane the resuling frustum plane
  3750. */
  3751. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3752. /**
  3753. * Gets the far frustum plane transformed by the transform matrix
  3754. * @param transform transformation matrix to be applied to the resulting frustum plane
  3755. * @param frustumPlane the resuling frustum plane
  3756. */
  3757. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3758. /**
  3759. * Gets the left frustum plane transformed by the transform matrix
  3760. * @param transform transformation matrix to be applied to the resulting frustum plane
  3761. * @param frustumPlane the resuling frustum plane
  3762. */
  3763. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3764. /**
  3765. * Gets the right frustum plane transformed by the transform matrix
  3766. * @param transform transformation matrix to be applied to the resulting frustum plane
  3767. * @param frustumPlane the resuling frustum plane
  3768. */
  3769. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3770. /**
  3771. * Gets the top frustum plane transformed by the transform matrix
  3772. * @param transform transformation matrix to be applied to the resulting frustum plane
  3773. * @param frustumPlane the resuling frustum plane
  3774. */
  3775. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3776. /**
  3777. * Gets the bottom frustum plane transformed by the transform matrix
  3778. * @param transform transformation matrix to be applied to the resulting frustum plane
  3779. * @param frustumPlane the resuling frustum plane
  3780. */
  3781. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3782. /**
  3783. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3784. * @param transform transformation matrix to be applied to the resulting frustum planes
  3785. * @param frustumPlanes the resuling frustum planes
  3786. */
  3787. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3788. }
  3789. /** Defines supported spaces */
  3790. export enum Space {
  3791. /** Local (object) space */
  3792. LOCAL = 0,
  3793. /** World space */
  3794. WORLD = 1,
  3795. /** Bone space */
  3796. BONE = 2
  3797. }
  3798. /** Defines the 3 main axes */
  3799. export class Axis {
  3800. /** X axis */
  3801. static X: Vector3;
  3802. /** Y axis */
  3803. static Y: Vector3;
  3804. /** Z axis */
  3805. static Z: Vector3;
  3806. }
  3807. /** Class used to represent a Bezier curve */
  3808. export class BezierCurve {
  3809. /**
  3810. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3811. * @param t defines the time
  3812. * @param x1 defines the left coordinate on X axis
  3813. * @param y1 defines the left coordinate on Y axis
  3814. * @param x2 defines the right coordinate on X axis
  3815. * @param y2 defines the right coordinate on Y axis
  3816. * @returns the interpolated value
  3817. */
  3818. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3819. }
  3820. /**
  3821. * Defines potential orientation for back face culling
  3822. */
  3823. export enum Orientation {
  3824. /**
  3825. * Clockwise
  3826. */
  3827. CW = 0,
  3828. /** Counter clockwise */
  3829. CCW = 1
  3830. }
  3831. /**
  3832. * Defines angle representation
  3833. */
  3834. export class Angle {
  3835. private _radians;
  3836. /**
  3837. * Creates an Angle object of "radians" radians (float).
  3838. * @param radians the angle in radians
  3839. */
  3840. constructor(radians: number);
  3841. /**
  3842. * Get value in degrees
  3843. * @returns the Angle value in degrees (float)
  3844. */
  3845. degrees(): number;
  3846. /**
  3847. * Get value in radians
  3848. * @returns the Angle value in radians (float)
  3849. */
  3850. radians(): number;
  3851. /**
  3852. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3853. * @param a defines first vector
  3854. * @param b defines second vector
  3855. * @returns a new Angle
  3856. */
  3857. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3858. /**
  3859. * Gets a new Angle object from the given float in radians
  3860. * @param radians defines the angle value in radians
  3861. * @returns a new Angle
  3862. */
  3863. static FromRadians(radians: number): Angle;
  3864. /**
  3865. * Gets a new Angle object from the given float in degrees
  3866. * @param degrees defines the angle value in degrees
  3867. * @returns a new Angle
  3868. */
  3869. static FromDegrees(degrees: number): Angle;
  3870. }
  3871. /**
  3872. * This represents an arc in a 2d space.
  3873. */
  3874. export class Arc2 {
  3875. /** Defines the start point of the arc */
  3876. startPoint: Vector2;
  3877. /** Defines the mid point of the arc */
  3878. midPoint: Vector2;
  3879. /** Defines the end point of the arc */
  3880. endPoint: Vector2;
  3881. /**
  3882. * Defines the center point of the arc.
  3883. */
  3884. centerPoint: Vector2;
  3885. /**
  3886. * Defines the radius of the arc.
  3887. */
  3888. radius: number;
  3889. /**
  3890. * Defines the angle of the arc (from mid point to end point).
  3891. */
  3892. angle: Angle;
  3893. /**
  3894. * Defines the start angle of the arc (from start point to middle point).
  3895. */
  3896. startAngle: Angle;
  3897. /**
  3898. * Defines the orientation of the arc (clock wise/counter clock wise).
  3899. */
  3900. orientation: Orientation;
  3901. /**
  3902. * Creates an Arc object from the three given points : start, middle and end.
  3903. * @param startPoint Defines the start point of the arc
  3904. * @param midPoint Defines the midlle point of the arc
  3905. * @param endPoint Defines the end point of the arc
  3906. */
  3907. constructor(
  3908. /** Defines the start point of the arc */
  3909. startPoint: Vector2,
  3910. /** Defines the mid point of the arc */
  3911. midPoint: Vector2,
  3912. /** Defines the end point of the arc */
  3913. endPoint: Vector2);
  3914. }
  3915. /**
  3916. * Represents a 2D path made up of multiple 2D points
  3917. */
  3918. export class Path2 {
  3919. private _points;
  3920. private _length;
  3921. /**
  3922. * If the path start and end point are the same
  3923. */
  3924. closed: boolean;
  3925. /**
  3926. * Creates a Path2 object from the starting 2D coordinates x and y.
  3927. * @param x the starting points x value
  3928. * @param y the starting points y value
  3929. */
  3930. constructor(x: number, y: number);
  3931. /**
  3932. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3933. * @param x the added points x value
  3934. * @param y the added points y value
  3935. * @returns the updated Path2.
  3936. */
  3937. addLineTo(x: number, y: number): Path2;
  3938. /**
  3939. * 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.
  3940. * @param midX middle point x value
  3941. * @param midY middle point y value
  3942. * @param endX end point x value
  3943. * @param endY end point y value
  3944. * @param numberOfSegments (default: 36)
  3945. * @returns the updated Path2.
  3946. */
  3947. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3948. /**
  3949. * Closes the Path2.
  3950. * @returns the Path2.
  3951. */
  3952. close(): Path2;
  3953. /**
  3954. * Gets the sum of the distance between each sequential point in the path
  3955. * @returns the Path2 total length (float).
  3956. */
  3957. length(): number;
  3958. /**
  3959. * Gets the points which construct the path
  3960. * @returns the Path2 internal array of points.
  3961. */
  3962. getPoints(): Vector2[];
  3963. /**
  3964. * Retreives the point at the distance aways from the starting point
  3965. * @param normalizedLengthPosition the length along the path to retreive the point from
  3966. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3967. */
  3968. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3969. /**
  3970. * Creates a new path starting from an x and y position
  3971. * @param x starting x value
  3972. * @param y starting y value
  3973. * @returns a new Path2 starting at the coordinates (x, y).
  3974. */
  3975. static StartingAt(x: number, y: number): Path2;
  3976. }
  3977. /**
  3978. * Represents a 3D path made up of multiple 3D points
  3979. */
  3980. export class Path3D {
  3981. /**
  3982. * an array of Vector3, the curve axis of the Path3D
  3983. */
  3984. path: Vector3[];
  3985. private _curve;
  3986. private _distances;
  3987. private _tangents;
  3988. private _normals;
  3989. private _binormals;
  3990. private _raw;
  3991. /**
  3992. * new Path3D(path, normal, raw)
  3993. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3994. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3995. * @param path an array of Vector3, the curve axis of the Path3D
  3996. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3997. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3998. */
  3999. constructor(
  4000. /**
  4001. * an array of Vector3, the curve axis of the Path3D
  4002. */
  4003. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4004. /**
  4005. * Returns the Path3D array of successive Vector3 designing its curve.
  4006. * @returns the Path3D array of successive Vector3 designing its curve.
  4007. */
  4008. getCurve(): Vector3[];
  4009. /**
  4010. * Returns an array populated with tangent vectors on each Path3D curve point.
  4011. * @returns an array populated with tangent vectors on each Path3D curve point.
  4012. */
  4013. getTangents(): Vector3[];
  4014. /**
  4015. * Returns an array populated with normal vectors on each Path3D curve point.
  4016. * @returns an array populated with normal vectors on each Path3D curve point.
  4017. */
  4018. getNormals(): Vector3[];
  4019. /**
  4020. * Returns an array populated with binormal vectors on each Path3D curve point.
  4021. * @returns an array populated with binormal vectors on each Path3D curve point.
  4022. */
  4023. getBinormals(): Vector3[];
  4024. /**
  4025. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4026. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4027. */
  4028. getDistances(): number[];
  4029. /**
  4030. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4031. * @param path path which all values are copied into the curves points
  4032. * @param firstNormal which should be projected onto the curve
  4033. * @returns the same object updated.
  4034. */
  4035. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4036. private _compute;
  4037. private _getFirstNonNullVector;
  4038. private _getLastNonNullVector;
  4039. private _normalVector;
  4040. }
  4041. /**
  4042. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4043. * A Curve3 is designed from a series of successive Vector3.
  4044. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4045. */
  4046. export class Curve3 {
  4047. private _points;
  4048. private _length;
  4049. /**
  4050. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4051. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4052. * @param v1 (Vector3) the control point
  4053. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4054. * @param nbPoints (integer) the wanted number of points in the curve
  4055. * @returns the created Curve3
  4056. */
  4057. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4058. /**
  4059. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4060. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4061. * @param v1 (Vector3) the first control point
  4062. * @param v2 (Vector3) the second control point
  4063. * @param v3 (Vector3) the end point of the Cubic Bezier
  4064. * @param nbPoints (integer) the wanted number of points in the curve
  4065. * @returns the created Curve3
  4066. */
  4067. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4068. /**
  4069. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4070. * @param p1 (Vector3) the origin point of the Hermite Spline
  4071. * @param t1 (Vector3) the tangent vector at the origin point
  4072. * @param p2 (Vector3) the end point of the Hermite Spline
  4073. * @param t2 (Vector3) the tangent vector at the end point
  4074. * @param nbPoints (integer) the wanted number of points in the curve
  4075. * @returns the created Curve3
  4076. */
  4077. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4078. /**
  4079. * Returns a Curve3 object along a CatmullRom Spline curve :
  4080. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4081. * @param nbPoints (integer) the wanted number of points between each curve control points
  4082. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4083. * @returns the created Curve3
  4084. */
  4085. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4086. /**
  4087. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4088. * A Curve3 is designed from a series of successive Vector3.
  4089. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4090. * @param points points which make up the curve
  4091. */
  4092. constructor(points: Vector3[]);
  4093. /**
  4094. * @returns the Curve3 stored array of successive Vector3
  4095. */
  4096. getPoints(): Vector3[];
  4097. /**
  4098. * @returns the computed length (float) of the curve.
  4099. */
  4100. length(): number;
  4101. /**
  4102. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4103. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4104. * curveA and curveB keep unchanged.
  4105. * @param curve the curve to continue from this curve
  4106. * @returns the newly constructed curve
  4107. */
  4108. continue(curve: DeepImmutable<Curve3>): Curve3;
  4109. private _computeLength;
  4110. }
  4111. /**
  4112. * Contains position and normal vectors for a vertex
  4113. */
  4114. export class PositionNormalVertex {
  4115. /** the position of the vertex (defaut: 0,0,0) */
  4116. position: Vector3;
  4117. /** the normal of the vertex (defaut: 0,1,0) */
  4118. normal: Vector3;
  4119. /**
  4120. * Creates a PositionNormalVertex
  4121. * @param position the position of the vertex (defaut: 0,0,0)
  4122. * @param normal the normal of the vertex (defaut: 0,1,0)
  4123. */
  4124. constructor(
  4125. /** the position of the vertex (defaut: 0,0,0) */
  4126. position?: Vector3,
  4127. /** the normal of the vertex (defaut: 0,1,0) */
  4128. normal?: Vector3);
  4129. /**
  4130. * Clones the PositionNormalVertex
  4131. * @returns the cloned PositionNormalVertex
  4132. */
  4133. clone(): PositionNormalVertex;
  4134. }
  4135. /**
  4136. * Contains position, normal and uv vectors for a vertex
  4137. */
  4138. export class PositionNormalTextureVertex {
  4139. /** the position of the vertex (defaut: 0,0,0) */
  4140. position: Vector3;
  4141. /** the normal of the vertex (defaut: 0,1,0) */
  4142. normal: Vector3;
  4143. /** the uv of the vertex (default: 0,0) */
  4144. uv: Vector2;
  4145. /**
  4146. * Creates a PositionNormalTextureVertex
  4147. * @param position the position of the vertex (defaut: 0,0,0)
  4148. * @param normal the normal of the vertex (defaut: 0,1,0)
  4149. * @param uv the uv of the vertex (default: 0,0)
  4150. */
  4151. constructor(
  4152. /** the position of the vertex (defaut: 0,0,0) */
  4153. position?: Vector3,
  4154. /** the normal of the vertex (defaut: 0,1,0) */
  4155. normal?: Vector3,
  4156. /** the uv of the vertex (default: 0,0) */
  4157. uv?: Vector2);
  4158. /**
  4159. * Clones the PositionNormalTextureVertex
  4160. * @returns the cloned PositionNormalTextureVertex
  4161. */
  4162. clone(): PositionNormalTextureVertex;
  4163. }
  4164. /**
  4165. * @hidden
  4166. */
  4167. export class Tmp {
  4168. static Color3: Color3[];
  4169. static Color4: Color4[];
  4170. static Vector2: Vector2[];
  4171. static Vector3: Vector3[];
  4172. static Vector4: Vector4[];
  4173. static Quaternion: Quaternion[];
  4174. static Matrix: Matrix[];
  4175. }
  4176. }
  4177. declare module BABYLON {
  4178. /**
  4179. * Class used to enable access to offline support
  4180. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4181. */
  4182. export interface IOfflineProvider {
  4183. /**
  4184. * Gets a boolean indicating if scene must be saved in the database
  4185. */
  4186. enableSceneOffline: boolean;
  4187. /**
  4188. * Gets a boolean indicating if textures must be saved in the database
  4189. */
  4190. enableTexturesOffline: boolean;
  4191. /**
  4192. * Open the offline support and make it available
  4193. * @param successCallback defines the callback to call on success
  4194. * @param errorCallback defines the callback to call on error
  4195. */
  4196. open(successCallback: () => void, errorCallback: () => void): void;
  4197. /**
  4198. * Loads an image from the offline support
  4199. * @param url defines the url to load from
  4200. * @param image defines the target DOM image
  4201. */
  4202. loadImage(url: string, image: HTMLImageElement): void;
  4203. /**
  4204. * Loads a file from offline support
  4205. * @param url defines the URL to load from
  4206. * @param sceneLoaded defines a callback to call on success
  4207. * @param progressCallBack defines a callback to call when progress changed
  4208. * @param errorCallback defines a callback to call on error
  4209. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4210. */
  4211. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4212. }
  4213. }
  4214. declare module BABYLON {
  4215. /**
  4216. * A class serves as a medium between the observable and its observers
  4217. */
  4218. export class EventState {
  4219. /**
  4220. * Create a new EventState
  4221. * @param mask defines the mask associated with this state
  4222. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4223. * @param target defines the original target of the state
  4224. * @param currentTarget defines the current target of the state
  4225. */
  4226. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4227. /**
  4228. * Initialize the current event state
  4229. * @param mask defines the mask associated with this state
  4230. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4231. * @param target defines the original target of the state
  4232. * @param currentTarget defines the current target of the state
  4233. * @returns the current event state
  4234. */
  4235. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4236. /**
  4237. * An Observer can set this property to true to prevent subsequent observers of being notified
  4238. */
  4239. skipNextObservers: boolean;
  4240. /**
  4241. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4242. */
  4243. mask: number;
  4244. /**
  4245. * The object that originally notified the event
  4246. */
  4247. target?: any;
  4248. /**
  4249. * The current object in the bubbling phase
  4250. */
  4251. currentTarget?: any;
  4252. /**
  4253. * This will be populated with the return value of the last function that was executed.
  4254. * If it is the first function in the callback chain it will be the event data.
  4255. */
  4256. lastReturnValue?: any;
  4257. }
  4258. /**
  4259. * Represent an Observer registered to a given Observable object.
  4260. */
  4261. export class Observer<T> {
  4262. /**
  4263. * Defines the callback to call when the observer is notified
  4264. */
  4265. callback: (eventData: T, eventState: EventState) => void;
  4266. /**
  4267. * Defines the mask of the observer (used to filter notifications)
  4268. */
  4269. mask: number;
  4270. /**
  4271. * Defines the current scope used to restore the JS context
  4272. */
  4273. scope: any;
  4274. /** @hidden */
  4275. _willBeUnregistered: boolean;
  4276. /**
  4277. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4278. */
  4279. unregisterOnNextCall: boolean;
  4280. /**
  4281. * Creates a new observer
  4282. * @param callback defines the callback to call when the observer is notified
  4283. * @param mask defines the mask of the observer (used to filter notifications)
  4284. * @param scope defines the current scope used to restore the JS context
  4285. */
  4286. constructor(
  4287. /**
  4288. * Defines the callback to call when the observer is notified
  4289. */
  4290. callback: (eventData: T, eventState: EventState) => void,
  4291. /**
  4292. * Defines the mask of the observer (used to filter notifications)
  4293. */
  4294. mask: number,
  4295. /**
  4296. * Defines the current scope used to restore the JS context
  4297. */
  4298. scope?: any);
  4299. }
  4300. /**
  4301. * Represent a list of observers registered to multiple Observables object.
  4302. */
  4303. export class MultiObserver<T> {
  4304. private _observers;
  4305. private _observables;
  4306. /**
  4307. * Release associated resources
  4308. */
  4309. dispose(): void;
  4310. /**
  4311. * Raise a callback when one of the observable will notify
  4312. * @param observables defines a list of observables to watch
  4313. * @param callback defines the callback to call on notification
  4314. * @param mask defines the mask used to filter notifications
  4315. * @param scope defines the current scope used to restore the JS context
  4316. * @returns the new MultiObserver
  4317. */
  4318. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4319. }
  4320. /**
  4321. * The Observable class is a simple implementation of the Observable pattern.
  4322. *
  4323. * 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.
  4324. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4325. * 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).
  4326. * 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.
  4327. */
  4328. export class Observable<T> {
  4329. private _observers;
  4330. private _eventState;
  4331. private _onObserverAdded;
  4332. /**
  4333. * Creates a new observable
  4334. * @param onObserverAdded defines a callback to call when a new observer is added
  4335. */
  4336. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4337. /**
  4338. * Create a new Observer with the specified callback
  4339. * @param callback the callback that will be executed for that Observer
  4340. * @param mask the mask used to filter observers
  4341. * @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.
  4342. * @param scope optional scope for the callback to be called from
  4343. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4344. * @returns the new observer created for the callback
  4345. */
  4346. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4347. /**
  4348. * Create a new Observer with the specified callback and unregisters after the next notification
  4349. * @param callback the callback that will be executed for that Observer
  4350. * @returns the new observer created for the callback
  4351. */
  4352. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4353. /**
  4354. * Remove an Observer from the Observable object
  4355. * @param observer the instance of the Observer to remove
  4356. * @returns false if it doesn't belong to this Observable
  4357. */
  4358. remove(observer: Nullable<Observer<T>>): boolean;
  4359. /**
  4360. * Remove a callback from the Observable object
  4361. * @param callback the callback to remove
  4362. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4363. * @returns false if it doesn't belong to this Observable
  4364. */
  4365. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4366. private _deferUnregister;
  4367. private _remove;
  4368. /**
  4369. * Moves the observable to the top of the observer list making it get called first when notified
  4370. * @param observer the observer to move
  4371. */
  4372. makeObserverTopPriority(observer: Observer<T>): void;
  4373. /**
  4374. * Moves the observable to the bottom of the observer list making it get called last when notified
  4375. * @param observer the observer to move
  4376. */
  4377. makeObserverBottomPriority(observer: Observer<T>): void;
  4378. /**
  4379. * Notify all Observers by calling their respective callback with the given data
  4380. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4381. * @param eventData defines the data to send to all observers
  4382. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4383. * @param target defines the original target of the state
  4384. * @param currentTarget defines the current target of the state
  4385. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4386. */
  4387. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4388. /**
  4389. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4390. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4391. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4392. * and it is crucial that all callbacks will be executed.
  4393. * The order of the callbacks is kept, callbacks are not executed parallel.
  4394. *
  4395. * @param eventData The data to be sent to each callback
  4396. * @param mask is used to filter observers defaults to -1
  4397. * @param target defines the callback target (see EventState)
  4398. * @param currentTarget defines he current object in the bubbling phase
  4399. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4400. */
  4401. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4402. /**
  4403. * Notify a specific observer
  4404. * @param observer defines the observer to notify
  4405. * @param eventData defines the data to be sent to each callback
  4406. * @param mask is used to filter observers defaults to -1
  4407. */
  4408. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4409. /**
  4410. * Gets a boolean indicating if the observable has at least one observer
  4411. * @returns true is the Observable has at least one Observer registered
  4412. */
  4413. hasObservers(): boolean;
  4414. /**
  4415. * Clear the list of observers
  4416. */
  4417. clear(): void;
  4418. /**
  4419. * Clone the current observable
  4420. * @returns a new observable
  4421. */
  4422. clone(): Observable<T>;
  4423. /**
  4424. * Does this observable handles observer registered with a given mask
  4425. * @param mask defines the mask to be tested
  4426. * @return whether or not one observer registered with the given mask is handeled
  4427. **/
  4428. hasSpecificMask(mask?: number): boolean;
  4429. }
  4430. }
  4431. declare module BABYLON {
  4432. /**
  4433. * Class used to help managing file picking and drag'n'drop
  4434. * File Storage
  4435. */
  4436. export class FilesInputStore {
  4437. /**
  4438. * List of files ready to be loaded
  4439. */
  4440. static FilesToLoad: {
  4441. [key: string]: File;
  4442. };
  4443. }
  4444. }
  4445. declare module BABYLON {
  4446. /** Defines the cross module used constants to avoid circular dependncies */
  4447. export class Constants {
  4448. /** Defines that alpha blending is disabled */
  4449. static readonly ALPHA_DISABLE: number;
  4450. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4451. static readonly ALPHA_ADD: number;
  4452. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4453. static readonly ALPHA_COMBINE: number;
  4454. /** Defines that alpha blending to DEST - SRC * DEST */
  4455. static readonly ALPHA_SUBTRACT: number;
  4456. /** Defines that alpha blending to SRC * DEST */
  4457. static readonly ALPHA_MULTIPLY: number;
  4458. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4459. static readonly ALPHA_MAXIMIZED: number;
  4460. /** Defines that alpha blending to SRC + DEST */
  4461. static readonly ALPHA_ONEONE: number;
  4462. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4463. static readonly ALPHA_PREMULTIPLIED: number;
  4464. /**
  4465. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4466. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4467. */
  4468. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4469. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4470. static readonly ALPHA_INTERPOLATE: number;
  4471. /**
  4472. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4473. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4474. */
  4475. static readonly ALPHA_SCREENMODE: number;
  4476. /** Defines that the ressource is not delayed*/
  4477. static readonly DELAYLOADSTATE_NONE: number;
  4478. /** Defines that the ressource was successfully delay loaded */
  4479. static readonly DELAYLOADSTATE_LOADED: number;
  4480. /** Defines that the ressource is currently delay loading */
  4481. static readonly DELAYLOADSTATE_LOADING: number;
  4482. /** Defines that the ressource is delayed and has not started loading */
  4483. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4484. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4485. static readonly NEVER: number;
  4486. /** 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 */
  4487. static readonly ALWAYS: number;
  4488. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4489. static readonly LESS: number;
  4490. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4491. static readonly EQUAL: number;
  4492. /** 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 */
  4493. static readonly LEQUAL: number;
  4494. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4495. static readonly GREATER: number;
  4496. /** 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 */
  4497. static readonly GEQUAL: number;
  4498. /** 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 */
  4499. static readonly NOTEQUAL: number;
  4500. /** Passed to stencilOperation to specify that stencil value must be kept */
  4501. static readonly KEEP: number;
  4502. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4503. static readonly REPLACE: number;
  4504. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4505. static readonly INCR: number;
  4506. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4507. static readonly DECR: number;
  4508. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4509. static readonly INVERT: number;
  4510. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4511. static readonly INCR_WRAP: number;
  4512. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4513. static readonly DECR_WRAP: number;
  4514. /** Texture is not repeating outside of 0..1 UVs */
  4515. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4516. /** Texture is repeating outside of 0..1 UVs */
  4517. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4518. /** Texture is repeating and mirrored */
  4519. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4520. /** ALPHA */
  4521. static readonly TEXTUREFORMAT_ALPHA: number;
  4522. /** LUMINANCE */
  4523. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4524. /** LUMINANCE_ALPHA */
  4525. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4526. /** RGB */
  4527. static readonly TEXTUREFORMAT_RGB: number;
  4528. /** RGBA */
  4529. static readonly TEXTUREFORMAT_RGBA: number;
  4530. /** RED */
  4531. static readonly TEXTUREFORMAT_RED: number;
  4532. /** RED (2nd reference) */
  4533. static readonly TEXTUREFORMAT_R: number;
  4534. /** RG */
  4535. static readonly TEXTUREFORMAT_RG: number;
  4536. /** RED_INTEGER */
  4537. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4538. /** RED_INTEGER (2nd reference) */
  4539. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4540. /** RG_INTEGER */
  4541. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4542. /** RGB_INTEGER */
  4543. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4544. /** RGBA_INTEGER */
  4545. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4546. /** UNSIGNED_BYTE */
  4547. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4548. /** UNSIGNED_BYTE (2nd reference) */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4550. /** FLOAT */
  4551. static readonly TEXTURETYPE_FLOAT: number;
  4552. /** HALF_FLOAT */
  4553. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4554. /** BYTE */
  4555. static readonly TEXTURETYPE_BYTE: number;
  4556. /** SHORT */
  4557. static readonly TEXTURETYPE_SHORT: number;
  4558. /** UNSIGNED_SHORT */
  4559. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4560. /** INT */
  4561. static readonly TEXTURETYPE_INT: number;
  4562. /** UNSIGNED_INT */
  4563. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4564. /** UNSIGNED_SHORT_4_4_4_4 */
  4565. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4566. /** UNSIGNED_SHORT_5_5_5_1 */
  4567. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4568. /** UNSIGNED_SHORT_5_6_5 */
  4569. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4570. /** UNSIGNED_INT_2_10_10_10_REV */
  4571. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4572. /** UNSIGNED_INT_24_8 */
  4573. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4574. /** UNSIGNED_INT_10F_11F_11F_REV */
  4575. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4576. /** UNSIGNED_INT_5_9_9_9_REV */
  4577. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4578. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4579. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4580. /** nearest is mag = nearest and min = nearest and mip = linear */
  4581. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4582. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4583. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4584. /** Trilinear is mag = linear and min = linear and mip = linear */
  4585. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4586. /** nearest is mag = nearest and min = nearest and mip = linear */
  4587. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4588. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4589. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4590. /** Trilinear is mag = linear and min = linear and mip = linear */
  4591. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4592. /** mag = nearest and min = nearest and mip = nearest */
  4593. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4594. /** mag = nearest and min = linear and mip = nearest */
  4595. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4596. /** mag = nearest and min = linear and mip = linear */
  4597. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4598. /** mag = nearest and min = linear and mip = none */
  4599. static readonly TEXTURE_NEAREST_LINEAR: number;
  4600. /** mag = nearest and min = nearest and mip = none */
  4601. static readonly TEXTURE_NEAREST_NEAREST: number;
  4602. /** mag = linear and min = nearest and mip = nearest */
  4603. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4604. /** mag = linear and min = nearest and mip = linear */
  4605. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4606. /** mag = linear and min = linear and mip = none */
  4607. static readonly TEXTURE_LINEAR_LINEAR: number;
  4608. /** mag = linear and min = nearest and mip = none */
  4609. static readonly TEXTURE_LINEAR_NEAREST: number;
  4610. /** Explicit coordinates mode */
  4611. static readonly TEXTURE_EXPLICIT_MODE: number;
  4612. /** Spherical coordinates mode */
  4613. static readonly TEXTURE_SPHERICAL_MODE: number;
  4614. /** Planar coordinates mode */
  4615. static readonly TEXTURE_PLANAR_MODE: number;
  4616. /** Cubic coordinates mode */
  4617. static readonly TEXTURE_CUBIC_MODE: number;
  4618. /** Projection coordinates mode */
  4619. static readonly TEXTURE_PROJECTION_MODE: number;
  4620. /** Skybox coordinates mode */
  4621. static readonly TEXTURE_SKYBOX_MODE: number;
  4622. /** Inverse Cubic coordinates mode */
  4623. static readonly TEXTURE_INVCUBIC_MODE: number;
  4624. /** Equirectangular coordinates mode */
  4625. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4626. /** Equirectangular Fixed coordinates mode */
  4627. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4628. /** Equirectangular Fixed Mirrored coordinates mode */
  4629. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4630. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4631. static readonly SCALEMODE_FLOOR: number;
  4632. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4633. static readonly SCALEMODE_NEAREST: number;
  4634. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4635. static readonly SCALEMODE_CEILING: number;
  4636. /**
  4637. * The dirty texture flag value
  4638. */
  4639. static readonly MATERIAL_TextureDirtyFlag: number;
  4640. /**
  4641. * The dirty light flag value
  4642. */
  4643. static readonly MATERIAL_LightDirtyFlag: number;
  4644. /**
  4645. * The dirty fresnel flag value
  4646. */
  4647. static readonly MATERIAL_FresnelDirtyFlag: number;
  4648. /**
  4649. * The dirty attribute flag value
  4650. */
  4651. static readonly MATERIAL_AttributesDirtyFlag: number;
  4652. /**
  4653. * The dirty misc flag value
  4654. */
  4655. static readonly MATERIAL_MiscDirtyFlag: number;
  4656. /**
  4657. * The all dirty flag value
  4658. */
  4659. static readonly MATERIAL_AllDirtyFlag: number;
  4660. /**
  4661. * Returns the triangle fill mode
  4662. */
  4663. static readonly MATERIAL_TriangleFillMode: number;
  4664. /**
  4665. * Returns the wireframe mode
  4666. */
  4667. static readonly MATERIAL_WireFrameFillMode: number;
  4668. /**
  4669. * Returns the point fill mode
  4670. */
  4671. static readonly MATERIAL_PointFillMode: number;
  4672. /**
  4673. * Returns the point list draw mode
  4674. */
  4675. static readonly MATERIAL_PointListDrawMode: number;
  4676. /**
  4677. * Returns the line list draw mode
  4678. */
  4679. static readonly MATERIAL_LineListDrawMode: number;
  4680. /**
  4681. * Returns the line loop draw mode
  4682. */
  4683. static readonly MATERIAL_LineLoopDrawMode: number;
  4684. /**
  4685. * Returns the line strip draw mode
  4686. */
  4687. static readonly MATERIAL_LineStripDrawMode: number;
  4688. /**
  4689. * Returns the triangle strip draw mode
  4690. */
  4691. static readonly MATERIAL_TriangleStripDrawMode: number;
  4692. /**
  4693. * Returns the triangle fan draw mode
  4694. */
  4695. static readonly MATERIAL_TriangleFanDrawMode: number;
  4696. /**
  4697. * Stores the clock-wise side orientation
  4698. */
  4699. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4700. /**
  4701. * Stores the counter clock-wise side orientation
  4702. */
  4703. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4704. /**
  4705. * Nothing
  4706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4707. */
  4708. static readonly ACTION_NothingTrigger: number;
  4709. /**
  4710. * On pick
  4711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4712. */
  4713. static readonly ACTION_OnPickTrigger: number;
  4714. /**
  4715. * On left pick
  4716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4717. */
  4718. static readonly ACTION_OnLeftPickTrigger: number;
  4719. /**
  4720. * On right pick
  4721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4722. */
  4723. static readonly ACTION_OnRightPickTrigger: number;
  4724. /**
  4725. * On center pick
  4726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4727. */
  4728. static readonly ACTION_OnCenterPickTrigger: number;
  4729. /**
  4730. * On pick down
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPickDownTrigger: number;
  4734. /**
  4735. * On double pick
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnDoublePickTrigger: number;
  4739. /**
  4740. * On pick up
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnPickUpTrigger: number;
  4744. /**
  4745. * On pick out.
  4746. * This trigger will only be raised if you also declared a OnPickDown
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnPickOutTrigger: number;
  4750. /**
  4751. * On long press
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnLongPressTrigger: number;
  4755. /**
  4756. * On pointer over
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnPointerOverTrigger: number;
  4760. /**
  4761. * On pointer out
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnPointerOutTrigger: number;
  4765. /**
  4766. * On every frame
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnEveryFrameTrigger: number;
  4770. /**
  4771. * On intersection enter
  4772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4773. */
  4774. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4775. /**
  4776. * On intersection exit
  4777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4778. */
  4779. static readonly ACTION_OnIntersectionExitTrigger: number;
  4780. /**
  4781. * On key down
  4782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4783. */
  4784. static readonly ACTION_OnKeyDownTrigger: number;
  4785. /**
  4786. * On key up
  4787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4788. */
  4789. static readonly ACTION_OnKeyUpTrigger: number;
  4790. /**
  4791. * Billboard mode will only apply to Y axis
  4792. */
  4793. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4794. /**
  4795. * Billboard mode will apply to all axes
  4796. */
  4797. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4798. /**
  4799. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4800. */
  4801. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4802. /**
  4803. * Gets or sets base Assets URL
  4804. */
  4805. static readonly PARTICLES_BaseAssetsUrl: string;
  4806. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4807. * Test order :
  4808. * Is the bounding sphere outside the frustum ?
  4809. * If not, are the bounding box vertices outside the frustum ?
  4810. * It not, then the cullable object is in the frustum.
  4811. */
  4812. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4813. /** Culling strategy : Bounding Sphere Only.
  4814. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4815. * It's also less accurate than the standard because some not visible objects can still be selected.
  4816. * Test : is the bounding sphere outside the frustum ?
  4817. * If not, then the cullable object is in the frustum.
  4818. */
  4819. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4820. /** Culling strategy : Optimistic Inclusion.
  4821. * This in an inclusion test first, then the standard exclusion test.
  4822. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4823. * 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.
  4824. * Anyway, it's as accurate as the standard strategy.
  4825. * Test :
  4826. * Is the cullable object bounding sphere center in the frustum ?
  4827. * If not, apply the default culling strategy.
  4828. */
  4829. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4830. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4831. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4832. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4833. * 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.
  4834. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4835. * Test :
  4836. * Is the cullable object bounding sphere center in the frustum ?
  4837. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4838. */
  4839. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4840. /**
  4841. * No logging while loading
  4842. */
  4843. static readonly SCENELOADER_NO_LOGGING: number;
  4844. /**
  4845. * Minimal logging while loading
  4846. */
  4847. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4848. /**
  4849. * Summary logging while loading
  4850. */
  4851. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4852. /**
  4853. * Detailled logging while loading
  4854. */
  4855. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4856. }
  4857. }
  4858. declare module BABYLON {
  4859. /**
  4860. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4861. * Babylon.js
  4862. */
  4863. export class DomManagement {
  4864. /**
  4865. * Checks if the window object exists
  4866. * @returns true if the window object exists
  4867. */
  4868. static IsWindowObjectExist(): boolean;
  4869. /**
  4870. * Extracts text content from a DOM element hierarchy
  4871. * @param element defines the root element
  4872. * @returns a string
  4873. */
  4874. static GetDOMTextContent(element: HTMLElement): string;
  4875. }
  4876. }
  4877. declare module BABYLON {
  4878. /**
  4879. * Logger used througouht the application to allow configuration of
  4880. * the log level required for the messages.
  4881. */
  4882. export class Logger {
  4883. /**
  4884. * No log
  4885. */
  4886. static readonly NoneLogLevel: number;
  4887. /**
  4888. * Only message logs
  4889. */
  4890. static readonly MessageLogLevel: number;
  4891. /**
  4892. * Only warning logs
  4893. */
  4894. static readonly WarningLogLevel: number;
  4895. /**
  4896. * Only error logs
  4897. */
  4898. static readonly ErrorLogLevel: number;
  4899. /**
  4900. * All logs
  4901. */
  4902. static readonly AllLogLevel: number;
  4903. private static _LogCache;
  4904. /**
  4905. * Gets a value indicating the number of loading errors
  4906. * @ignorenaming
  4907. */
  4908. static errorsCount: number;
  4909. /**
  4910. * Callback called when a new log is added
  4911. */
  4912. static OnNewCacheEntry: (entry: string) => void;
  4913. private static _AddLogEntry;
  4914. private static _FormatMessage;
  4915. private static _LogDisabled;
  4916. private static _LogEnabled;
  4917. private static _WarnDisabled;
  4918. private static _WarnEnabled;
  4919. private static _ErrorDisabled;
  4920. private static _ErrorEnabled;
  4921. /**
  4922. * Log a message to the console
  4923. */
  4924. static Log: (message: string) => void;
  4925. /**
  4926. * Write a warning message to the console
  4927. */
  4928. static Warn: (message: string) => void;
  4929. /**
  4930. * Write an error message to the console
  4931. */
  4932. static Error: (message: string) => void;
  4933. /**
  4934. * Gets current log cache (list of logs)
  4935. */
  4936. static readonly LogCache: string;
  4937. /**
  4938. * Clears the log cache
  4939. */
  4940. static ClearLogCache(): void;
  4941. /**
  4942. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4943. */
  4944. static LogLevels: number;
  4945. }
  4946. }
  4947. declare module BABYLON {
  4948. /** @hidden */
  4949. export class _TypeStore {
  4950. /** @hidden */
  4951. static RegisteredTypes: {
  4952. [key: string]: Object;
  4953. };
  4954. /** @hidden */
  4955. static GetClass(fqdn: string): any;
  4956. }
  4957. }
  4958. declare module BABYLON {
  4959. /**
  4960. * Class containing a set of static utilities functions for deep copy.
  4961. */
  4962. export class DeepCopier {
  4963. /**
  4964. * Tries to copy an object by duplicating every property
  4965. * @param source defines the source object
  4966. * @param destination defines the target object
  4967. * @param doNotCopyList defines a list of properties to avoid
  4968. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4969. */
  4970. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4971. }
  4972. }
  4973. declare module BABYLON {
  4974. /**
  4975. * Class containing a set of static utilities functions for precision date
  4976. */
  4977. export class PrecisionDate {
  4978. /**
  4979. * Gets either window.performance.now() if supported or Date.now() else
  4980. */
  4981. static readonly Now: number;
  4982. }
  4983. }
  4984. declare module BABYLON {
  4985. /** @hidden */
  4986. export class _DevTools {
  4987. static WarnImport(name: string): string;
  4988. }
  4989. }
  4990. declare module BABYLON {
  4991. /**
  4992. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4993. */
  4994. export class WebRequest {
  4995. private _xhr;
  4996. /**
  4997. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4998. * i.e. when loading files, where the server/service expects an Authorization header
  4999. */
  5000. static CustomRequestHeaders: {
  5001. [key: string]: string;
  5002. };
  5003. /**
  5004. * Add callback functions in this array to update all the requests before they get sent to the network
  5005. */
  5006. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5007. private _injectCustomRequestHeaders;
  5008. /**
  5009. * Gets or sets a function to be called when loading progress changes
  5010. */
  5011. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5012. /**
  5013. * Returns client's state
  5014. */
  5015. readonly readyState: number;
  5016. /**
  5017. * Returns client's status
  5018. */
  5019. readonly status: number;
  5020. /**
  5021. * Returns client's status as a text
  5022. */
  5023. readonly statusText: string;
  5024. /**
  5025. * Returns client's response
  5026. */
  5027. readonly response: any;
  5028. /**
  5029. * Returns client's response url
  5030. */
  5031. readonly responseURL: string;
  5032. /**
  5033. * Returns client's response as text
  5034. */
  5035. readonly responseText: string;
  5036. /**
  5037. * Gets or sets the expected response type
  5038. */
  5039. responseType: XMLHttpRequestResponseType;
  5040. /** @hidden */
  5041. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5042. /** @hidden */
  5043. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5044. /**
  5045. * Cancels any network activity
  5046. */
  5047. abort(): void;
  5048. /**
  5049. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5050. * @param body defines an optional request body
  5051. */
  5052. send(body?: Document | BodyInit | null): void;
  5053. /**
  5054. * Sets the request method, request URL
  5055. * @param method defines the method to use (GET, POST, etc..)
  5056. * @param url defines the url to connect with
  5057. */
  5058. open(method: string, url: string): void;
  5059. }
  5060. }
  5061. declare module BABYLON {
  5062. /**
  5063. * Class used to evalaute queries containing `and` and `or` operators
  5064. */
  5065. export class AndOrNotEvaluator {
  5066. /**
  5067. * Evaluate a query
  5068. * @param query defines the query to evaluate
  5069. * @param evaluateCallback defines the callback used to filter result
  5070. * @returns true if the query matches
  5071. */
  5072. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5073. private static _HandleParenthesisContent;
  5074. private static _SimplifyNegation;
  5075. }
  5076. }
  5077. declare module BABYLON {
  5078. /**
  5079. * Class used to store custom tags
  5080. */
  5081. export class Tags {
  5082. /**
  5083. * Adds support for tags on the given object
  5084. * @param obj defines the object to use
  5085. */
  5086. static EnableFor(obj: any): void;
  5087. /**
  5088. * Removes tags support
  5089. * @param obj defines the object to use
  5090. */
  5091. static DisableFor(obj: any): void;
  5092. /**
  5093. * Gets a boolean indicating if the given object has tags
  5094. * @param obj defines the object to use
  5095. * @returns a boolean
  5096. */
  5097. static HasTags(obj: any): boolean;
  5098. /**
  5099. * Gets the tags available on a given object
  5100. * @param obj defines the object to use
  5101. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5102. * @returns the tags
  5103. */
  5104. static GetTags(obj: any, asString?: boolean): any;
  5105. /**
  5106. * Adds tags to an object
  5107. * @param obj defines the object to use
  5108. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5109. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5110. */
  5111. static AddTagsTo(obj: any, tagsString: string): void;
  5112. /**
  5113. * @hidden
  5114. */
  5115. static _AddTagTo(obj: any, tag: string): void;
  5116. /**
  5117. * Removes specific tags from a specific object
  5118. * @param obj defines the object to use
  5119. * @param tagsString defines the tags to remove
  5120. */
  5121. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5122. /**
  5123. * @hidden
  5124. */
  5125. static _RemoveTagFrom(obj: any, tag: string): void;
  5126. /**
  5127. * Defines if tags hosted on an object match a given query
  5128. * @param obj defines the object to use
  5129. * @param tagsQuery defines the tag query
  5130. * @returns a boolean
  5131. */
  5132. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5133. }
  5134. }
  5135. declare module BABYLON {
  5136. /**
  5137. * Manages the defines for the Material
  5138. */
  5139. export class MaterialDefines {
  5140. private _keys;
  5141. private _isDirty;
  5142. /** @hidden */
  5143. _renderId: number;
  5144. /** @hidden */
  5145. _areLightsDirty: boolean;
  5146. /** @hidden */
  5147. _areAttributesDirty: boolean;
  5148. /** @hidden */
  5149. _areTexturesDirty: boolean;
  5150. /** @hidden */
  5151. _areFresnelDirty: boolean;
  5152. /** @hidden */
  5153. _areMiscDirty: boolean;
  5154. /** @hidden */
  5155. _areImageProcessingDirty: boolean;
  5156. /** @hidden */
  5157. _normals: boolean;
  5158. /** @hidden */
  5159. _uvs: boolean;
  5160. /** @hidden */
  5161. _needNormals: boolean;
  5162. /** @hidden */
  5163. _needUVs: boolean;
  5164. /**
  5165. * Specifies if the material needs to be re-calculated
  5166. */
  5167. readonly isDirty: boolean;
  5168. /**
  5169. * Marks the material to indicate that it has been re-calculated
  5170. */
  5171. markAsProcessed(): void;
  5172. /**
  5173. * Marks the material to indicate that it needs to be re-calculated
  5174. */
  5175. markAsUnprocessed(): void;
  5176. /**
  5177. * Marks the material to indicate all of its defines need to be re-calculated
  5178. */
  5179. markAllAsDirty(): void;
  5180. /**
  5181. * Marks the material to indicate that image processing needs to be re-calculated
  5182. */
  5183. markAsImageProcessingDirty(): void;
  5184. /**
  5185. * Marks the material to indicate the lights need to be re-calculated
  5186. */
  5187. markAsLightDirty(): void;
  5188. /**
  5189. * Marks the attribute state as changed
  5190. */
  5191. markAsAttributesDirty(): void;
  5192. /**
  5193. * Marks the texture state as changed
  5194. */
  5195. markAsTexturesDirty(): void;
  5196. /**
  5197. * Marks the fresnel state as changed
  5198. */
  5199. markAsFresnelDirty(): void;
  5200. /**
  5201. * Marks the misc state as changed
  5202. */
  5203. markAsMiscDirty(): void;
  5204. /**
  5205. * Rebuilds the material defines
  5206. */
  5207. rebuild(): void;
  5208. /**
  5209. * Specifies if two material defines are equal
  5210. * @param other - A material define instance to compare to
  5211. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5212. */
  5213. isEqual(other: MaterialDefines): boolean;
  5214. /**
  5215. * Clones this instance's defines to another instance
  5216. * @param other - material defines to clone values to
  5217. */
  5218. cloneTo(other: MaterialDefines): void;
  5219. /**
  5220. * Resets the material define values
  5221. */
  5222. reset(): void;
  5223. /**
  5224. * Converts the material define values to a string
  5225. * @returns - String of material define information
  5226. */
  5227. toString(): string;
  5228. }
  5229. }
  5230. declare module BABYLON {
  5231. /**
  5232. * Class used to store and describe the pipeline context associated with an effect
  5233. */
  5234. export interface IPipelineContext {
  5235. /**
  5236. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5237. */
  5238. isAsync: boolean;
  5239. /**
  5240. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5241. */
  5242. isReady: boolean;
  5243. /** @hidden */
  5244. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5245. }
  5246. }
  5247. declare module BABYLON {
  5248. /**
  5249. * Class used to store gfx data (like WebGLBuffer)
  5250. */
  5251. export class DataBuffer {
  5252. /**
  5253. * Gets or sets the number of objects referencing this buffer
  5254. */
  5255. references: number;
  5256. /** Gets or sets the size of the underlying buffer */
  5257. capacity: number;
  5258. /**
  5259. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5260. */
  5261. is32Bits: boolean;
  5262. /**
  5263. * Gets the underlying buffer
  5264. */
  5265. readonly underlyingResource: any;
  5266. }
  5267. }
  5268. declare module BABYLON {
  5269. /**
  5270. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5271. */
  5272. export class PerformanceMonitor {
  5273. private _enabled;
  5274. private _rollingFrameTime;
  5275. private _lastFrameTimeMs;
  5276. /**
  5277. * constructor
  5278. * @param frameSampleSize The number of samples required to saturate the sliding window
  5279. */
  5280. constructor(frameSampleSize?: number);
  5281. /**
  5282. * Samples current frame
  5283. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5284. */
  5285. sampleFrame(timeMs?: number): void;
  5286. /**
  5287. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5288. */
  5289. readonly averageFrameTime: number;
  5290. /**
  5291. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5292. */
  5293. readonly averageFrameTimeVariance: number;
  5294. /**
  5295. * Returns the frame time of the most recent frame
  5296. */
  5297. readonly instantaneousFrameTime: number;
  5298. /**
  5299. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5300. */
  5301. readonly averageFPS: number;
  5302. /**
  5303. * Returns the average framerate in frames per second using the most recent frame time
  5304. */
  5305. readonly instantaneousFPS: number;
  5306. /**
  5307. * Returns true if enough samples have been taken to completely fill the sliding window
  5308. */
  5309. readonly isSaturated: boolean;
  5310. /**
  5311. * Enables contributions to the sliding window sample set
  5312. */
  5313. enable(): void;
  5314. /**
  5315. * Disables contributions to the sliding window sample set
  5316. * Samples will not be interpolated over the disabled period
  5317. */
  5318. disable(): void;
  5319. /**
  5320. * Returns true if sampling is enabled
  5321. */
  5322. readonly isEnabled: boolean;
  5323. /**
  5324. * Resets performance monitor
  5325. */
  5326. reset(): void;
  5327. }
  5328. /**
  5329. * RollingAverage
  5330. *
  5331. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5332. */
  5333. export class RollingAverage {
  5334. /**
  5335. * Current average
  5336. */
  5337. average: number;
  5338. /**
  5339. * Current variance
  5340. */
  5341. variance: number;
  5342. protected _samples: Array<number>;
  5343. protected _sampleCount: number;
  5344. protected _pos: number;
  5345. protected _m2: number;
  5346. /**
  5347. * constructor
  5348. * @param length The number of samples required to saturate the sliding window
  5349. */
  5350. constructor(length: number);
  5351. /**
  5352. * Adds a sample to the sample set
  5353. * @param v The sample value
  5354. */
  5355. add(v: number): void;
  5356. /**
  5357. * Returns previously added values or null if outside of history or outside the sliding window domain
  5358. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5359. * @return Value previously recorded with add() or null if outside of range
  5360. */
  5361. history(i: number): number;
  5362. /**
  5363. * Returns true if enough samples have been taken to completely fill the sliding window
  5364. * @return true if sample-set saturated
  5365. */
  5366. isSaturated(): boolean;
  5367. /**
  5368. * Resets the rolling average (equivalent to 0 samples taken so far)
  5369. */
  5370. reset(): void;
  5371. /**
  5372. * Wraps a value around the sample range boundaries
  5373. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5374. * @return Wrapped position in sample range
  5375. */
  5376. protected _wrapPosition(i: number): number;
  5377. }
  5378. }
  5379. declare module BABYLON {
  5380. /**
  5381. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5382. * The underlying implementation relies on an associative array to ensure the best performances.
  5383. * The value can be anything including 'null' but except 'undefined'
  5384. */
  5385. export class StringDictionary<T> {
  5386. /**
  5387. * This will clear this dictionary and copy the content from the 'source' one.
  5388. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5389. * @param source the dictionary to take the content from and copy to this dictionary
  5390. */
  5391. copyFrom(source: StringDictionary<T>): void;
  5392. /**
  5393. * Get a value based from its key
  5394. * @param key the given key to get the matching value from
  5395. * @return the value if found, otherwise undefined is returned
  5396. */
  5397. get(key: string): T | undefined;
  5398. /**
  5399. * Get a value from its key or add it if it doesn't exist.
  5400. * This method will ensure you that a given key/data will be present in the dictionary.
  5401. * @param key the given key to get the matching value from
  5402. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5403. * The factory will only be invoked if there's no data for the given key.
  5404. * @return the value corresponding to the key.
  5405. */
  5406. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5407. /**
  5408. * Get a value from its key if present in the dictionary otherwise add it
  5409. * @param key the key to get the value from
  5410. * @param val if there's no such key/value pair in the dictionary add it with this value
  5411. * @return the value corresponding to the key
  5412. */
  5413. getOrAdd(key: string, val: T): T;
  5414. /**
  5415. * Check if there's a given key in the dictionary
  5416. * @param key the key to check for
  5417. * @return true if the key is present, false otherwise
  5418. */
  5419. contains(key: string): boolean;
  5420. /**
  5421. * Add a new key and its corresponding value
  5422. * @param key the key to add
  5423. * @param value the value corresponding to the key
  5424. * @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
  5425. */
  5426. add(key: string, value: T): boolean;
  5427. /**
  5428. * Update a specific value associated to a key
  5429. * @param key defines the key to use
  5430. * @param value defines the value to store
  5431. * @returns true if the value was updated (or false if the key was not found)
  5432. */
  5433. set(key: string, value: T): boolean;
  5434. /**
  5435. * Get the element of the given key and remove it from the dictionary
  5436. * @param key defines the key to search
  5437. * @returns the value associated with the key or null if not found
  5438. */
  5439. getAndRemove(key: string): Nullable<T>;
  5440. /**
  5441. * Remove a key/value from the dictionary.
  5442. * @param key the key to remove
  5443. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5444. */
  5445. remove(key: string): boolean;
  5446. /**
  5447. * Clear the whole content of the dictionary
  5448. */
  5449. clear(): void;
  5450. /**
  5451. * Gets the current count
  5452. */
  5453. readonly count: number;
  5454. /**
  5455. * Execute a callback on each key/val of the dictionary.
  5456. * Note that you can remove any element in this dictionary in the callback implementation
  5457. * @param callback the callback to execute on a given key/value pair
  5458. */
  5459. forEach(callback: (key: string, val: T) => void): void;
  5460. /**
  5461. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5462. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5463. * Note that you can remove any element in this dictionary in the callback implementation
  5464. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5465. * @returns the first item
  5466. */
  5467. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5468. private _count;
  5469. private _data;
  5470. }
  5471. }
  5472. declare module BABYLON {
  5473. /**
  5474. * Helper class that provides a small promise polyfill
  5475. */
  5476. export class PromisePolyfill {
  5477. /**
  5478. * Static function used to check if the polyfill is required
  5479. * If this is the case then the function will inject the polyfill to window.Promise
  5480. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5481. */
  5482. static Apply(force?: boolean): void;
  5483. }
  5484. }
  5485. declare module BABYLON {
  5486. /**
  5487. * Class used to store data that will be store in GPU memory
  5488. */
  5489. export class Buffer {
  5490. private _engine;
  5491. private _buffer;
  5492. /** @hidden */
  5493. _data: Nullable<DataArray>;
  5494. private _updatable;
  5495. private _instanced;
  5496. /**
  5497. * Gets the byte stride.
  5498. */
  5499. readonly byteStride: number;
  5500. /**
  5501. * Constructor
  5502. * @param engine the engine
  5503. * @param data the data to use for this buffer
  5504. * @param updatable whether the data is updatable
  5505. * @param stride the stride (optional)
  5506. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5507. * @param instanced whether the buffer is instanced (optional)
  5508. * @param useBytes set to true if the stride in in bytes (optional)
  5509. */
  5510. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5511. /**
  5512. * Create a new VertexBuffer based on the current buffer
  5513. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5514. * @param offset defines offset in the buffer (0 by default)
  5515. * @param size defines the size in floats of attributes (position is 3 for instance)
  5516. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5517. * @param instanced defines if the vertex buffer contains indexed data
  5518. * @param useBytes defines if the offset and stride are in bytes
  5519. * @returns the new vertex buffer
  5520. */
  5521. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5522. /**
  5523. * Gets a boolean indicating if the Buffer is updatable?
  5524. * @returns true if the buffer is updatable
  5525. */
  5526. isUpdatable(): boolean;
  5527. /**
  5528. * Gets current buffer's data
  5529. * @returns a DataArray or null
  5530. */
  5531. getData(): Nullable<DataArray>;
  5532. /**
  5533. * Gets underlying native buffer
  5534. * @returns underlying native buffer
  5535. */
  5536. getBuffer(): Nullable<DataBuffer>;
  5537. /**
  5538. * Gets the stride in float32 units (i.e. byte stride / 4).
  5539. * May not be an integer if the byte stride is not divisible by 4.
  5540. * DEPRECATED. Use byteStride instead.
  5541. * @returns the stride in float32 units
  5542. */
  5543. getStrideSize(): number;
  5544. /**
  5545. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5546. * @param data defines the data to store
  5547. */
  5548. create(data?: Nullable<DataArray>): void;
  5549. /** @hidden */
  5550. _rebuild(): void;
  5551. /**
  5552. * Update current buffer data
  5553. * @param data defines the data to store
  5554. */
  5555. update(data: DataArray): void;
  5556. /**
  5557. * Updates the data directly.
  5558. * @param data the new data
  5559. * @param offset the new offset
  5560. * @param vertexCount the vertex count (optional)
  5561. * @param useBytes set to true if the offset is in bytes
  5562. */
  5563. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5564. /**
  5565. * Release all resources
  5566. */
  5567. dispose(): void;
  5568. }
  5569. /**
  5570. * Specialized buffer used to store vertex data
  5571. */
  5572. export class VertexBuffer {
  5573. /** @hidden */
  5574. _buffer: Buffer;
  5575. private _kind;
  5576. private _size;
  5577. private _ownsBuffer;
  5578. private _instanced;
  5579. private _instanceDivisor;
  5580. /**
  5581. * The byte type.
  5582. */
  5583. static readonly BYTE: number;
  5584. /**
  5585. * The unsigned byte type.
  5586. */
  5587. static readonly UNSIGNED_BYTE: number;
  5588. /**
  5589. * The short type.
  5590. */
  5591. static readonly SHORT: number;
  5592. /**
  5593. * The unsigned short type.
  5594. */
  5595. static readonly UNSIGNED_SHORT: number;
  5596. /**
  5597. * The integer type.
  5598. */
  5599. static readonly INT: number;
  5600. /**
  5601. * The unsigned integer type.
  5602. */
  5603. static readonly UNSIGNED_INT: number;
  5604. /**
  5605. * The float type.
  5606. */
  5607. static readonly FLOAT: number;
  5608. /**
  5609. * Gets or sets the instance divisor when in instanced mode
  5610. */
  5611. instanceDivisor: number;
  5612. /**
  5613. * Gets the byte stride.
  5614. */
  5615. readonly byteStride: number;
  5616. /**
  5617. * Gets the byte offset.
  5618. */
  5619. readonly byteOffset: number;
  5620. /**
  5621. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5622. */
  5623. readonly normalized: boolean;
  5624. /**
  5625. * Gets the data type of each component in the array.
  5626. */
  5627. readonly type: number;
  5628. /**
  5629. * Constructor
  5630. * @param engine the engine
  5631. * @param data the data to use for this vertex buffer
  5632. * @param kind the vertex buffer kind
  5633. * @param updatable whether the data is updatable
  5634. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5635. * @param stride the stride (optional)
  5636. * @param instanced whether the buffer is instanced (optional)
  5637. * @param offset the offset of the data (optional)
  5638. * @param size the number of components (optional)
  5639. * @param type the type of the component (optional)
  5640. * @param normalized whether the data contains normalized data (optional)
  5641. * @param useBytes set to true if stride and offset are in bytes (optional)
  5642. */
  5643. 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);
  5644. /** @hidden */
  5645. _rebuild(): void;
  5646. /**
  5647. * Returns the kind of the VertexBuffer (string)
  5648. * @returns a string
  5649. */
  5650. getKind(): string;
  5651. /**
  5652. * Gets a boolean indicating if the VertexBuffer is updatable?
  5653. * @returns true if the buffer is updatable
  5654. */
  5655. isUpdatable(): boolean;
  5656. /**
  5657. * Gets current buffer's data
  5658. * @returns a DataArray or null
  5659. */
  5660. getData(): Nullable<DataArray>;
  5661. /**
  5662. * Gets underlying native buffer
  5663. * @returns underlying native buffer
  5664. */
  5665. getBuffer(): Nullable<DataBuffer>;
  5666. /**
  5667. * Gets the stride in float32 units (i.e. byte stride / 4).
  5668. * May not be an integer if the byte stride is not divisible by 4.
  5669. * DEPRECATED. Use byteStride instead.
  5670. * @returns the stride in float32 units
  5671. */
  5672. getStrideSize(): number;
  5673. /**
  5674. * Returns the offset as a multiple of the type byte length.
  5675. * DEPRECATED. Use byteOffset instead.
  5676. * @returns the offset in bytes
  5677. */
  5678. getOffset(): number;
  5679. /**
  5680. * Returns the number of components per vertex attribute (integer)
  5681. * @returns the size in float
  5682. */
  5683. getSize(): number;
  5684. /**
  5685. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5686. * @returns true if this buffer is instanced
  5687. */
  5688. getIsInstanced(): boolean;
  5689. /**
  5690. * Returns the instancing divisor, zero for non-instanced (integer).
  5691. * @returns a number
  5692. */
  5693. getInstanceDivisor(): number;
  5694. /**
  5695. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5696. * @param data defines the data to store
  5697. */
  5698. create(data?: DataArray): void;
  5699. /**
  5700. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5701. * This function will create a new buffer if the current one is not updatable
  5702. * @param data defines the data to store
  5703. */
  5704. update(data: DataArray): void;
  5705. /**
  5706. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5707. * Returns the directly updated WebGLBuffer.
  5708. * @param data the new data
  5709. * @param offset the new offset
  5710. * @param useBytes set to true if the offset is in bytes
  5711. */
  5712. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5713. /**
  5714. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5715. */
  5716. dispose(): void;
  5717. /**
  5718. * Enumerates each value of this vertex buffer as numbers.
  5719. * @param count the number of values to enumerate
  5720. * @param callback the callback function called for each value
  5721. */
  5722. forEach(count: number, callback: (value: number, index: number) => void): void;
  5723. /**
  5724. * Positions
  5725. */
  5726. static readonly PositionKind: string;
  5727. /**
  5728. * Normals
  5729. */
  5730. static readonly NormalKind: string;
  5731. /**
  5732. * Tangents
  5733. */
  5734. static readonly TangentKind: string;
  5735. /**
  5736. * Texture coordinates
  5737. */
  5738. static readonly UVKind: string;
  5739. /**
  5740. * Texture coordinates 2
  5741. */
  5742. static readonly UV2Kind: string;
  5743. /**
  5744. * Texture coordinates 3
  5745. */
  5746. static readonly UV3Kind: string;
  5747. /**
  5748. * Texture coordinates 4
  5749. */
  5750. static readonly UV4Kind: string;
  5751. /**
  5752. * Texture coordinates 5
  5753. */
  5754. static readonly UV5Kind: string;
  5755. /**
  5756. * Texture coordinates 6
  5757. */
  5758. static readonly UV6Kind: string;
  5759. /**
  5760. * Colors
  5761. */
  5762. static readonly ColorKind: string;
  5763. /**
  5764. * Matrix indices (for bones)
  5765. */
  5766. static readonly MatricesIndicesKind: string;
  5767. /**
  5768. * Matrix weights (for bones)
  5769. */
  5770. static readonly MatricesWeightsKind: string;
  5771. /**
  5772. * Additional matrix indices (for bones)
  5773. */
  5774. static readonly MatricesIndicesExtraKind: string;
  5775. /**
  5776. * Additional matrix weights (for bones)
  5777. */
  5778. static readonly MatricesWeightsExtraKind: string;
  5779. /**
  5780. * Deduces the stride given a kind.
  5781. * @param kind The kind string to deduce
  5782. * @returns The deduced stride
  5783. */
  5784. static DeduceStride(kind: string): number;
  5785. /**
  5786. * Gets the byte length of the given type.
  5787. * @param type the type
  5788. * @returns the number of bytes
  5789. */
  5790. static GetTypeByteLength(type: number): number;
  5791. /**
  5792. * Enumerates each value of the given parameters as numbers.
  5793. * @param data the data to enumerate
  5794. * @param byteOffset the byte offset of the data
  5795. * @param byteStride the byte stride of the data
  5796. * @param componentCount the number of components per element
  5797. * @param componentType the type of the component
  5798. * @param count the total number of components
  5799. * @param normalized whether the data is normalized
  5800. * @param callback the callback function called for each value
  5801. */
  5802. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5803. private static _GetFloatValue;
  5804. }
  5805. }
  5806. declare module BABYLON {
  5807. /**
  5808. * Class representing spherical harmonics coefficients to the 3rd degree
  5809. */
  5810. export class SphericalHarmonics {
  5811. /**
  5812. * Defines whether or not the harmonics have been prescaled for rendering.
  5813. */
  5814. preScaled: boolean;
  5815. /**
  5816. * The l0,0 coefficients of the spherical harmonics
  5817. */
  5818. l00: Vector3;
  5819. /**
  5820. * The l1,-1 coefficients of the spherical harmonics
  5821. */
  5822. l1_1: Vector3;
  5823. /**
  5824. * The l1,0 coefficients of the spherical harmonics
  5825. */
  5826. l10: Vector3;
  5827. /**
  5828. * The l1,1 coefficients of the spherical harmonics
  5829. */
  5830. l11: Vector3;
  5831. /**
  5832. * The l2,-2 coefficients of the spherical harmonics
  5833. */
  5834. l2_2: Vector3;
  5835. /**
  5836. * The l2,-1 coefficients of the spherical harmonics
  5837. */
  5838. l2_1: Vector3;
  5839. /**
  5840. * The l2,0 coefficients of the spherical harmonics
  5841. */
  5842. l20: Vector3;
  5843. /**
  5844. * The l2,1 coefficients of the spherical harmonics
  5845. */
  5846. l21: Vector3;
  5847. /**
  5848. * The l2,2 coefficients of the spherical harmonics
  5849. */
  5850. l22: Vector3;
  5851. /**
  5852. * Adds a light to the spherical harmonics
  5853. * @param direction the direction of the light
  5854. * @param color the color of the light
  5855. * @param deltaSolidAngle the delta solid angle of the light
  5856. */
  5857. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5858. /**
  5859. * Scales the spherical harmonics by the given amount
  5860. * @param scale the amount to scale
  5861. */
  5862. scaleInPlace(scale: number): void;
  5863. /**
  5864. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5865. *
  5866. * ```
  5867. * E_lm = A_l * L_lm
  5868. * ```
  5869. *
  5870. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5871. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5872. * the scaling factors are given in equation 9.
  5873. */
  5874. convertIncidentRadianceToIrradiance(): void;
  5875. /**
  5876. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5877. *
  5878. * ```
  5879. * L = (1/pi) * E * rho
  5880. * ```
  5881. *
  5882. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5883. */
  5884. convertIrradianceToLambertianRadiance(): void;
  5885. /**
  5886. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5887. * required operations at run time.
  5888. *
  5889. * This is simply done by scaling back the SH with Ylm constants parameter.
  5890. * The trigonometric part being applied by the shader at run time.
  5891. */
  5892. preScaleForRendering(): void;
  5893. /**
  5894. * Constructs a spherical harmonics from an array.
  5895. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5896. * @returns the spherical harmonics
  5897. */
  5898. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5899. /**
  5900. * Gets the spherical harmonics from polynomial
  5901. * @param polynomial the spherical polynomial
  5902. * @returns the spherical harmonics
  5903. */
  5904. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5905. }
  5906. /**
  5907. * Class representing spherical polynomial coefficients to the 3rd degree
  5908. */
  5909. export class SphericalPolynomial {
  5910. private _harmonics;
  5911. /**
  5912. * The spherical harmonics used to create the polynomials.
  5913. */
  5914. readonly preScaledHarmonics: SphericalHarmonics;
  5915. /**
  5916. * The x coefficients of the spherical polynomial
  5917. */
  5918. x: Vector3;
  5919. /**
  5920. * The y coefficients of the spherical polynomial
  5921. */
  5922. y: Vector3;
  5923. /**
  5924. * The z coefficients of the spherical polynomial
  5925. */
  5926. z: Vector3;
  5927. /**
  5928. * The xx coefficients of the spherical polynomial
  5929. */
  5930. xx: Vector3;
  5931. /**
  5932. * The yy coefficients of the spherical polynomial
  5933. */
  5934. yy: Vector3;
  5935. /**
  5936. * The zz coefficients of the spherical polynomial
  5937. */
  5938. zz: Vector3;
  5939. /**
  5940. * The xy coefficients of the spherical polynomial
  5941. */
  5942. xy: Vector3;
  5943. /**
  5944. * The yz coefficients of the spherical polynomial
  5945. */
  5946. yz: Vector3;
  5947. /**
  5948. * The zx coefficients of the spherical polynomial
  5949. */
  5950. zx: Vector3;
  5951. /**
  5952. * Adds an ambient color to the spherical polynomial
  5953. * @param color the color to add
  5954. */
  5955. addAmbient(color: Color3): void;
  5956. /**
  5957. * Scales the spherical polynomial by the given amount
  5958. * @param scale the amount to scale
  5959. */
  5960. scaleInPlace(scale: number): void;
  5961. /**
  5962. * Gets the spherical polynomial from harmonics
  5963. * @param harmonics the spherical harmonics
  5964. * @returns the spherical polynomial
  5965. */
  5966. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5967. /**
  5968. * Constructs a spherical polynomial from an array.
  5969. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5970. * @returns the spherical polynomial
  5971. */
  5972. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5973. }
  5974. }
  5975. declare module BABYLON {
  5976. /**
  5977. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5978. */
  5979. export interface CubeMapInfo {
  5980. /**
  5981. * The pixel array for the front face.
  5982. * This is stored in format, left to right, up to down format.
  5983. */
  5984. front: Nullable<ArrayBufferView>;
  5985. /**
  5986. * The pixel array for the back face.
  5987. * This is stored in format, left to right, up to down format.
  5988. */
  5989. back: Nullable<ArrayBufferView>;
  5990. /**
  5991. * The pixel array for the left face.
  5992. * This is stored in format, left to right, up to down format.
  5993. */
  5994. left: Nullable<ArrayBufferView>;
  5995. /**
  5996. * The pixel array for the right face.
  5997. * This is stored in format, left to right, up to down format.
  5998. */
  5999. right: Nullable<ArrayBufferView>;
  6000. /**
  6001. * The pixel array for the up face.
  6002. * This is stored in format, left to right, up to down format.
  6003. */
  6004. up: Nullable<ArrayBufferView>;
  6005. /**
  6006. * The pixel array for the down face.
  6007. * This is stored in format, left to right, up to down format.
  6008. */
  6009. down: Nullable<ArrayBufferView>;
  6010. /**
  6011. * The size of the cubemap stored.
  6012. *
  6013. * Each faces will be size * size pixels.
  6014. */
  6015. size: number;
  6016. /**
  6017. * The format of the texture.
  6018. *
  6019. * RGBA, RGB.
  6020. */
  6021. format: number;
  6022. /**
  6023. * The type of the texture data.
  6024. *
  6025. * UNSIGNED_INT, FLOAT.
  6026. */
  6027. type: number;
  6028. /**
  6029. * Specifies whether the texture is in gamma space.
  6030. */
  6031. gammaSpace: boolean;
  6032. }
  6033. /**
  6034. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6035. */
  6036. export class PanoramaToCubeMapTools {
  6037. private static FACE_FRONT;
  6038. private static FACE_BACK;
  6039. private static FACE_RIGHT;
  6040. private static FACE_LEFT;
  6041. private static FACE_DOWN;
  6042. private static FACE_UP;
  6043. /**
  6044. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6045. *
  6046. * @param float32Array The source data.
  6047. * @param inputWidth The width of the input panorama.
  6048. * @param inputHeight The height of the input panorama.
  6049. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6050. * @return The cubemap data
  6051. */
  6052. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6053. private static CreateCubemapTexture;
  6054. private static CalcProjectionSpherical;
  6055. }
  6056. }
  6057. declare module BABYLON {
  6058. /**
  6059. * Helper class dealing with the extraction of spherical polynomial dataArray
  6060. * from a cube map.
  6061. */
  6062. export class CubeMapToSphericalPolynomialTools {
  6063. private static FileFaces;
  6064. /**
  6065. * Converts a texture to the according Spherical Polynomial data.
  6066. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6067. *
  6068. * @param texture The texture to extract the information from.
  6069. * @return The Spherical Polynomial data.
  6070. */
  6071. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6072. /**
  6073. * Converts a cubemap to the according Spherical Polynomial data.
  6074. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6075. *
  6076. * @param cubeInfo The Cube map to extract the information from.
  6077. * @return The Spherical Polynomial data.
  6078. */
  6079. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6080. }
  6081. }
  6082. declare module BABYLON {
  6083. /**
  6084. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6085. * during the life time of the application.
  6086. */
  6087. export class EngineStore {
  6088. /** Gets the list of created engines */
  6089. static Instances: Engine[];
  6090. /** @hidden */
  6091. static _LastCreatedScene: Nullable<Scene>;
  6092. /**
  6093. * Gets the latest created engine
  6094. */
  6095. static readonly LastCreatedEngine: Nullable<Engine>;
  6096. /**
  6097. * Gets the latest created scene
  6098. */
  6099. static readonly LastCreatedScene: Nullable<Scene>;
  6100. }
  6101. }
  6102. declare module BABYLON {
  6103. /**
  6104. * Define options used to create a render target texture
  6105. */
  6106. export class RenderTargetCreationOptions {
  6107. /**
  6108. * Specifies is mipmaps must be generated
  6109. */
  6110. generateMipMaps?: boolean;
  6111. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6112. generateDepthBuffer?: boolean;
  6113. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6114. generateStencilBuffer?: boolean;
  6115. /** Defines texture type (int by default) */
  6116. type?: number;
  6117. /** Defines sampling mode (trilinear by default) */
  6118. samplingMode?: number;
  6119. /** Defines format (RGBA by default) */
  6120. format?: number;
  6121. }
  6122. }
  6123. declare module BABYLON {
  6124. /**
  6125. * @hidden
  6126. **/
  6127. export class _AlphaState {
  6128. private _isAlphaBlendDirty;
  6129. private _isBlendFunctionParametersDirty;
  6130. private _isBlendEquationParametersDirty;
  6131. private _isBlendConstantsDirty;
  6132. private _alphaBlend;
  6133. private _blendFunctionParameters;
  6134. private _blendEquationParameters;
  6135. private _blendConstants;
  6136. /**
  6137. * Initializes the state.
  6138. */
  6139. constructor();
  6140. readonly isDirty: boolean;
  6141. alphaBlend: boolean;
  6142. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6143. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6144. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6145. reset(): void;
  6146. apply(gl: WebGLRenderingContext): void;
  6147. }
  6148. }
  6149. declare module BABYLON {
  6150. /**
  6151. * @hidden
  6152. **/
  6153. export class _DepthCullingState {
  6154. private _isDepthTestDirty;
  6155. private _isDepthMaskDirty;
  6156. private _isDepthFuncDirty;
  6157. private _isCullFaceDirty;
  6158. private _isCullDirty;
  6159. private _isZOffsetDirty;
  6160. private _isFrontFaceDirty;
  6161. private _depthTest;
  6162. private _depthMask;
  6163. private _depthFunc;
  6164. private _cull;
  6165. private _cullFace;
  6166. private _zOffset;
  6167. private _frontFace;
  6168. /**
  6169. * Initializes the state.
  6170. */
  6171. constructor();
  6172. readonly isDirty: boolean;
  6173. zOffset: number;
  6174. cullFace: Nullable<number>;
  6175. cull: Nullable<boolean>;
  6176. depthFunc: Nullable<number>;
  6177. depthMask: boolean;
  6178. depthTest: boolean;
  6179. frontFace: Nullable<number>;
  6180. reset(): void;
  6181. apply(gl: WebGLRenderingContext): void;
  6182. }
  6183. }
  6184. declare module BABYLON {
  6185. /**
  6186. * @hidden
  6187. **/
  6188. export class _StencilState {
  6189. /** 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 */
  6190. static readonly ALWAYS: number;
  6191. /** Passed to stencilOperation to specify that stencil value must be kept */
  6192. static readonly KEEP: number;
  6193. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6194. static readonly REPLACE: number;
  6195. private _isStencilTestDirty;
  6196. private _isStencilMaskDirty;
  6197. private _isStencilFuncDirty;
  6198. private _isStencilOpDirty;
  6199. private _stencilTest;
  6200. private _stencilMask;
  6201. private _stencilFunc;
  6202. private _stencilFuncRef;
  6203. private _stencilFuncMask;
  6204. private _stencilOpStencilFail;
  6205. private _stencilOpDepthFail;
  6206. private _stencilOpStencilDepthPass;
  6207. readonly isDirty: boolean;
  6208. stencilFunc: number;
  6209. stencilFuncRef: number;
  6210. stencilFuncMask: number;
  6211. stencilOpStencilFail: number;
  6212. stencilOpDepthFail: number;
  6213. stencilOpStencilDepthPass: number;
  6214. stencilMask: number;
  6215. stencilTest: boolean;
  6216. constructor();
  6217. reset(): void;
  6218. apply(gl: WebGLRenderingContext): void;
  6219. }
  6220. }
  6221. declare module BABYLON {
  6222. /**
  6223. * @hidden
  6224. **/
  6225. export class _TimeToken {
  6226. _startTimeQuery: Nullable<WebGLQuery>;
  6227. _endTimeQuery: Nullable<WebGLQuery>;
  6228. _timeElapsedQuery: Nullable<WebGLQuery>;
  6229. _timeElapsedQueryEnded: boolean;
  6230. }
  6231. }
  6232. declare module BABYLON {
  6233. /**
  6234. * Class used to store data associated with WebGL texture data for the engine
  6235. * This class should not be used directly
  6236. */
  6237. export class InternalTexture {
  6238. /** hidden */
  6239. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6240. /**
  6241. * The source of the texture data is unknown
  6242. */
  6243. static DATASOURCE_UNKNOWN: number;
  6244. /**
  6245. * Texture data comes from an URL
  6246. */
  6247. static DATASOURCE_URL: number;
  6248. /**
  6249. * Texture data is only used for temporary storage
  6250. */
  6251. static DATASOURCE_TEMP: number;
  6252. /**
  6253. * Texture data comes from raw data (ArrayBuffer)
  6254. */
  6255. static DATASOURCE_RAW: number;
  6256. /**
  6257. * Texture content is dynamic (video or dynamic texture)
  6258. */
  6259. static DATASOURCE_DYNAMIC: number;
  6260. /**
  6261. * Texture content is generated by rendering to it
  6262. */
  6263. static DATASOURCE_RENDERTARGET: number;
  6264. /**
  6265. * Texture content is part of a multi render target process
  6266. */
  6267. static DATASOURCE_MULTIRENDERTARGET: number;
  6268. /**
  6269. * Texture data comes from a cube data file
  6270. */
  6271. static DATASOURCE_CUBE: number;
  6272. /**
  6273. * Texture data comes from a raw cube data
  6274. */
  6275. static DATASOURCE_CUBERAW: number;
  6276. /**
  6277. * Texture data come from a prefiltered cube data file
  6278. */
  6279. static DATASOURCE_CUBEPREFILTERED: number;
  6280. /**
  6281. * Texture content is raw 3D data
  6282. */
  6283. static DATASOURCE_RAW3D: number;
  6284. /**
  6285. * Texture content is a depth texture
  6286. */
  6287. static DATASOURCE_DEPTHTEXTURE: number;
  6288. /**
  6289. * Texture data comes from a raw cube data encoded with RGBD
  6290. */
  6291. static DATASOURCE_CUBERAW_RGBD: number;
  6292. /**
  6293. * Defines if the texture is ready
  6294. */
  6295. isReady: boolean;
  6296. /**
  6297. * Defines if the texture is a cube texture
  6298. */
  6299. isCube: boolean;
  6300. /**
  6301. * Defines if the texture contains 3D data
  6302. */
  6303. is3D: boolean;
  6304. /**
  6305. * Defines if the texture contains multiview data
  6306. */
  6307. isMultiview: boolean;
  6308. /**
  6309. * Gets the URL used to load this texture
  6310. */
  6311. url: string;
  6312. /**
  6313. * Gets the sampling mode of the texture
  6314. */
  6315. samplingMode: number;
  6316. /**
  6317. * Gets a boolean indicating if the texture needs mipmaps generation
  6318. */
  6319. generateMipMaps: boolean;
  6320. /**
  6321. * Gets the number of samples used by the texture (WebGL2+ only)
  6322. */
  6323. samples: number;
  6324. /**
  6325. * Gets the type of the texture (int, float...)
  6326. */
  6327. type: number;
  6328. /**
  6329. * Gets the format of the texture (RGB, RGBA...)
  6330. */
  6331. format: number;
  6332. /**
  6333. * Observable called when the texture is loaded
  6334. */
  6335. onLoadedObservable: Observable<InternalTexture>;
  6336. /**
  6337. * Gets the width of the texture
  6338. */
  6339. width: number;
  6340. /**
  6341. * Gets the height of the texture
  6342. */
  6343. height: number;
  6344. /**
  6345. * Gets the depth of the texture
  6346. */
  6347. depth: number;
  6348. /**
  6349. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6350. */
  6351. baseWidth: number;
  6352. /**
  6353. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6354. */
  6355. baseHeight: number;
  6356. /**
  6357. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6358. */
  6359. baseDepth: number;
  6360. /**
  6361. * Gets a boolean indicating if the texture is inverted on Y axis
  6362. */
  6363. invertY: boolean;
  6364. /** @hidden */
  6365. _invertVScale: boolean;
  6366. /** @hidden */
  6367. _associatedChannel: number;
  6368. /** @hidden */
  6369. _dataSource: number;
  6370. /** @hidden */
  6371. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6372. /** @hidden */
  6373. _bufferView: Nullable<ArrayBufferView>;
  6374. /** @hidden */
  6375. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6376. /** @hidden */
  6377. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6378. /** @hidden */
  6379. _size: number;
  6380. /** @hidden */
  6381. _extension: string;
  6382. /** @hidden */
  6383. _files: Nullable<string[]>;
  6384. /** @hidden */
  6385. _workingCanvas: Nullable<HTMLCanvasElement>;
  6386. /** @hidden */
  6387. _workingContext: Nullable<CanvasRenderingContext2D>;
  6388. /** @hidden */
  6389. _framebuffer: Nullable<WebGLFramebuffer>;
  6390. /** @hidden */
  6391. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6392. /** @hidden */
  6393. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6394. /** @hidden */
  6395. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6396. /** @hidden */
  6397. _attachments: Nullable<number[]>;
  6398. /** @hidden */
  6399. _cachedCoordinatesMode: Nullable<number>;
  6400. /** @hidden */
  6401. _cachedWrapU: Nullable<number>;
  6402. /** @hidden */
  6403. _cachedWrapV: Nullable<number>;
  6404. /** @hidden */
  6405. _cachedWrapR: Nullable<number>;
  6406. /** @hidden */
  6407. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6408. /** @hidden */
  6409. _isDisabled: boolean;
  6410. /** @hidden */
  6411. _compression: Nullable<string>;
  6412. /** @hidden */
  6413. _generateStencilBuffer: boolean;
  6414. /** @hidden */
  6415. _generateDepthBuffer: boolean;
  6416. /** @hidden */
  6417. _comparisonFunction: number;
  6418. /** @hidden */
  6419. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6420. /** @hidden */
  6421. _lodGenerationScale: number;
  6422. /** @hidden */
  6423. _lodGenerationOffset: number;
  6424. /** @hidden */
  6425. _colorTextureArray: Nullable<WebGLTexture>;
  6426. /** @hidden */
  6427. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6428. /** @hidden */
  6429. _lodTextureHigh: Nullable<BaseTexture>;
  6430. /** @hidden */
  6431. _lodTextureMid: Nullable<BaseTexture>;
  6432. /** @hidden */
  6433. _lodTextureLow: Nullable<BaseTexture>;
  6434. /** @hidden */
  6435. _isRGBD: boolean;
  6436. /** @hidden */
  6437. _webGLTexture: Nullable<WebGLTexture>;
  6438. /** @hidden */
  6439. _references: number;
  6440. private _engine;
  6441. /**
  6442. * Gets the Engine the texture belongs to.
  6443. * @returns The babylon engine
  6444. */
  6445. getEngine(): Engine;
  6446. /**
  6447. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6448. */
  6449. readonly dataSource: number;
  6450. /**
  6451. * Creates a new InternalTexture
  6452. * @param engine defines the engine to use
  6453. * @param dataSource defines the type of data that will be used
  6454. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6455. */
  6456. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6457. /**
  6458. * Increments the number of references (ie. the number of Texture that point to it)
  6459. */
  6460. incrementReferences(): void;
  6461. /**
  6462. * Change the size of the texture (not the size of the content)
  6463. * @param width defines the new width
  6464. * @param height defines the new height
  6465. * @param depth defines the new depth (1 by default)
  6466. */
  6467. updateSize(width: int, height: int, depth?: int): void;
  6468. /** @hidden */
  6469. _rebuild(): void;
  6470. /** @hidden */
  6471. _swapAndDie(target: InternalTexture): void;
  6472. /**
  6473. * Dispose the current allocated resources
  6474. */
  6475. dispose(): void;
  6476. }
  6477. }
  6478. declare module BABYLON {
  6479. /**
  6480. * This represents the main contract an easing function should follow.
  6481. * Easing functions are used throughout the animation system.
  6482. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6483. */
  6484. export interface IEasingFunction {
  6485. /**
  6486. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6487. * of the easing function.
  6488. * The link below provides some of the most common examples of easing functions.
  6489. * @see https://easings.net/
  6490. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6491. * @returns the corresponding value on the curve defined by the easing function
  6492. */
  6493. ease(gradient: number): number;
  6494. }
  6495. /**
  6496. * Base class used for every default easing function.
  6497. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6498. */
  6499. export class EasingFunction implements IEasingFunction {
  6500. /**
  6501. * Interpolation follows the mathematical formula associated with the easing function.
  6502. */
  6503. static readonly EASINGMODE_EASEIN: number;
  6504. /**
  6505. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6506. */
  6507. static readonly EASINGMODE_EASEOUT: number;
  6508. /**
  6509. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6510. */
  6511. static readonly EASINGMODE_EASEINOUT: number;
  6512. private _easingMode;
  6513. /**
  6514. * Sets the easing mode of the current function.
  6515. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6516. */
  6517. setEasingMode(easingMode: number): void;
  6518. /**
  6519. * Gets the current easing mode.
  6520. * @returns the easing mode
  6521. */
  6522. getEasingMode(): number;
  6523. /**
  6524. * @hidden
  6525. */
  6526. easeInCore(gradient: number): number;
  6527. /**
  6528. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6529. * of the easing function.
  6530. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6531. * @returns the corresponding value on the curve defined by the easing function
  6532. */
  6533. ease(gradient: number): number;
  6534. }
  6535. /**
  6536. * Easing function with a circle shape (see link below).
  6537. * @see https://easings.net/#easeInCirc
  6538. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6539. */
  6540. export class CircleEase extends EasingFunction implements IEasingFunction {
  6541. /** @hidden */
  6542. easeInCore(gradient: number): number;
  6543. }
  6544. /**
  6545. * Easing function with a ease back shape (see link below).
  6546. * @see https://easings.net/#easeInBack
  6547. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6548. */
  6549. export class BackEase extends EasingFunction implements IEasingFunction {
  6550. /** Defines the amplitude of the function */
  6551. amplitude: number;
  6552. /**
  6553. * Instantiates a back ease easing
  6554. * @see https://easings.net/#easeInBack
  6555. * @param amplitude Defines the amplitude of the function
  6556. */
  6557. constructor(
  6558. /** Defines the amplitude of the function */
  6559. amplitude?: number);
  6560. /** @hidden */
  6561. easeInCore(gradient: number): number;
  6562. }
  6563. /**
  6564. * Easing function with a bouncing shape (see link below).
  6565. * @see https://easings.net/#easeInBounce
  6566. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6567. */
  6568. export class BounceEase extends EasingFunction implements IEasingFunction {
  6569. /** Defines the number of bounces */
  6570. bounces: number;
  6571. /** Defines the amplitude of the bounce */
  6572. bounciness: number;
  6573. /**
  6574. * Instantiates a bounce easing
  6575. * @see https://easings.net/#easeInBounce
  6576. * @param bounces Defines the number of bounces
  6577. * @param bounciness Defines the amplitude of the bounce
  6578. */
  6579. constructor(
  6580. /** Defines the number of bounces */
  6581. bounces?: number,
  6582. /** Defines the amplitude of the bounce */
  6583. bounciness?: number);
  6584. /** @hidden */
  6585. easeInCore(gradient: number): number;
  6586. }
  6587. /**
  6588. * Easing function with a power of 3 shape (see link below).
  6589. * @see https://easings.net/#easeInCubic
  6590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6591. */
  6592. export class CubicEase extends EasingFunction implements IEasingFunction {
  6593. /** @hidden */
  6594. easeInCore(gradient: number): number;
  6595. }
  6596. /**
  6597. * Easing function with an elastic shape (see link below).
  6598. * @see https://easings.net/#easeInElastic
  6599. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6600. */
  6601. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6602. /** Defines the number of oscillations*/
  6603. oscillations: number;
  6604. /** Defines the amplitude of the oscillations*/
  6605. springiness: number;
  6606. /**
  6607. * Instantiates an elastic easing function
  6608. * @see https://easings.net/#easeInElastic
  6609. * @param oscillations Defines the number of oscillations
  6610. * @param springiness Defines the amplitude of the oscillations
  6611. */
  6612. constructor(
  6613. /** Defines the number of oscillations*/
  6614. oscillations?: number,
  6615. /** Defines the amplitude of the oscillations*/
  6616. springiness?: number);
  6617. /** @hidden */
  6618. easeInCore(gradient: number): number;
  6619. }
  6620. /**
  6621. * Easing function with an exponential shape (see link below).
  6622. * @see https://easings.net/#easeInExpo
  6623. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6624. */
  6625. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6626. /** Defines the exponent of the function */
  6627. exponent: number;
  6628. /**
  6629. * Instantiates an exponential easing function
  6630. * @see https://easings.net/#easeInExpo
  6631. * @param exponent Defines the exponent of the function
  6632. */
  6633. constructor(
  6634. /** Defines the exponent of the function */
  6635. exponent?: number);
  6636. /** @hidden */
  6637. easeInCore(gradient: number): number;
  6638. }
  6639. /**
  6640. * Easing function with a power shape (see link below).
  6641. * @see https://easings.net/#easeInQuad
  6642. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6643. */
  6644. export class PowerEase extends EasingFunction implements IEasingFunction {
  6645. /** Defines the power of the function */
  6646. power: number;
  6647. /**
  6648. * Instantiates an power base easing function
  6649. * @see https://easings.net/#easeInQuad
  6650. * @param power Defines the power of the function
  6651. */
  6652. constructor(
  6653. /** Defines the power of the function */
  6654. power?: number);
  6655. /** @hidden */
  6656. easeInCore(gradient: number): number;
  6657. }
  6658. /**
  6659. * Easing function with a power of 2 shape (see link below).
  6660. * @see https://easings.net/#easeInQuad
  6661. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6662. */
  6663. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6664. /** @hidden */
  6665. easeInCore(gradient: number): number;
  6666. }
  6667. /**
  6668. * Easing function with a power of 4 shape (see link below).
  6669. * @see https://easings.net/#easeInQuart
  6670. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6671. */
  6672. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6673. /** @hidden */
  6674. easeInCore(gradient: number): number;
  6675. }
  6676. /**
  6677. * Easing function with a power of 5 shape (see link below).
  6678. * @see https://easings.net/#easeInQuint
  6679. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6680. */
  6681. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6682. /** @hidden */
  6683. easeInCore(gradient: number): number;
  6684. }
  6685. /**
  6686. * Easing function with a sin shape (see link below).
  6687. * @see https://easings.net/#easeInSine
  6688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6689. */
  6690. export class SineEase extends EasingFunction implements IEasingFunction {
  6691. /** @hidden */
  6692. easeInCore(gradient: number): number;
  6693. }
  6694. /**
  6695. * Easing function with a bezier shape (see link below).
  6696. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6697. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6698. */
  6699. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6700. /** Defines the x component of the start tangent in the bezier curve */
  6701. x1: number;
  6702. /** Defines the y component of the start tangent in the bezier curve */
  6703. y1: number;
  6704. /** Defines the x component of the end tangent in the bezier curve */
  6705. x2: number;
  6706. /** Defines the y component of the end tangent in the bezier curve */
  6707. y2: number;
  6708. /**
  6709. * Instantiates a bezier function
  6710. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6711. * @param x1 Defines the x component of the start tangent in the bezier curve
  6712. * @param y1 Defines the y component of the start tangent in the bezier curve
  6713. * @param x2 Defines the x component of the end tangent in the bezier curve
  6714. * @param y2 Defines the y component of the end tangent in the bezier curve
  6715. */
  6716. constructor(
  6717. /** Defines the x component of the start tangent in the bezier curve */
  6718. x1?: number,
  6719. /** Defines the y component of the start tangent in the bezier curve */
  6720. y1?: number,
  6721. /** Defines the x component of the end tangent in the bezier curve */
  6722. x2?: number,
  6723. /** Defines the y component of the end tangent in the bezier curve */
  6724. y2?: number);
  6725. /** @hidden */
  6726. easeInCore(gradient: number): number;
  6727. }
  6728. }
  6729. declare module BABYLON {
  6730. /**
  6731. * Defines an interface which represents an animation key frame
  6732. */
  6733. export interface IAnimationKey {
  6734. /**
  6735. * Frame of the key frame
  6736. */
  6737. frame: number;
  6738. /**
  6739. * Value at the specifies key frame
  6740. */
  6741. value: any;
  6742. /**
  6743. * The input tangent for the cubic hermite spline
  6744. */
  6745. inTangent?: any;
  6746. /**
  6747. * The output tangent for the cubic hermite spline
  6748. */
  6749. outTangent?: any;
  6750. /**
  6751. * The animation interpolation type
  6752. */
  6753. interpolation?: AnimationKeyInterpolation;
  6754. }
  6755. /**
  6756. * Enum for the animation key frame interpolation type
  6757. */
  6758. export enum AnimationKeyInterpolation {
  6759. /**
  6760. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6761. */
  6762. STEP = 1
  6763. }
  6764. }
  6765. declare module BABYLON {
  6766. /**
  6767. * Represents the range of an animation
  6768. */
  6769. export class AnimationRange {
  6770. /**The name of the animation range**/
  6771. name: string;
  6772. /**The starting frame of the animation */
  6773. from: number;
  6774. /**The ending frame of the animation*/
  6775. to: number;
  6776. /**
  6777. * Initializes the range of an animation
  6778. * @param name The name of the animation range
  6779. * @param from The starting frame of the animation
  6780. * @param to The ending frame of the animation
  6781. */
  6782. constructor(
  6783. /**The name of the animation range**/
  6784. name: string,
  6785. /**The starting frame of the animation */
  6786. from: number,
  6787. /**The ending frame of the animation*/
  6788. to: number);
  6789. /**
  6790. * Makes a copy of the animation range
  6791. * @returns A copy of the animation range
  6792. */
  6793. clone(): AnimationRange;
  6794. }
  6795. }
  6796. declare module BABYLON {
  6797. /**
  6798. * Composed of a frame, and an action function
  6799. */
  6800. export class AnimationEvent {
  6801. /** The frame for which the event is triggered **/
  6802. frame: number;
  6803. /** The event to perform when triggered **/
  6804. action: (currentFrame: number) => void;
  6805. /** Specifies if the event should be triggered only once**/
  6806. onlyOnce?: boolean | undefined;
  6807. /**
  6808. * Specifies if the animation event is done
  6809. */
  6810. isDone: boolean;
  6811. /**
  6812. * Initializes the animation event
  6813. * @param frame The frame for which the event is triggered
  6814. * @param action The event to perform when triggered
  6815. * @param onlyOnce Specifies if the event should be triggered only once
  6816. */
  6817. constructor(
  6818. /** The frame for which the event is triggered **/
  6819. frame: number,
  6820. /** The event to perform when triggered **/
  6821. action: (currentFrame: number) => void,
  6822. /** Specifies if the event should be triggered only once**/
  6823. onlyOnce?: boolean | undefined);
  6824. /** @hidden */
  6825. _clone(): AnimationEvent;
  6826. }
  6827. }
  6828. declare module BABYLON {
  6829. /**
  6830. * Interface used to define a behavior
  6831. */
  6832. export interface Behavior<T> {
  6833. /** gets or sets behavior's name */
  6834. name: string;
  6835. /**
  6836. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6837. */
  6838. init(): void;
  6839. /**
  6840. * Called when the behavior is attached to a target
  6841. * @param target defines the target where the behavior is attached to
  6842. */
  6843. attach(target: T): void;
  6844. /**
  6845. * Called when the behavior is detached from its target
  6846. */
  6847. detach(): void;
  6848. }
  6849. /**
  6850. * Interface implemented by classes supporting behaviors
  6851. */
  6852. export interface IBehaviorAware<T> {
  6853. /**
  6854. * Attach a behavior
  6855. * @param behavior defines the behavior to attach
  6856. * @returns the current host
  6857. */
  6858. addBehavior(behavior: Behavior<T>): T;
  6859. /**
  6860. * Remove a behavior from the current object
  6861. * @param behavior defines the behavior to detach
  6862. * @returns the current host
  6863. */
  6864. removeBehavior(behavior: Behavior<T>): T;
  6865. /**
  6866. * Gets a behavior using its name to search
  6867. * @param name defines the name to search
  6868. * @returns the behavior or null if not found
  6869. */
  6870. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6871. }
  6872. }
  6873. declare module BABYLON {
  6874. /**
  6875. * @hidden
  6876. */
  6877. export class IntersectionInfo {
  6878. bu: Nullable<number>;
  6879. bv: Nullable<number>;
  6880. distance: number;
  6881. faceId: number;
  6882. subMeshId: number;
  6883. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6884. }
  6885. }
  6886. declare module BABYLON {
  6887. /**
  6888. * Class used to store bounding sphere information
  6889. */
  6890. export class BoundingSphere {
  6891. /**
  6892. * Gets the center of the bounding sphere in local space
  6893. */
  6894. readonly center: Vector3;
  6895. /**
  6896. * Radius of the bounding sphere in local space
  6897. */
  6898. radius: number;
  6899. /**
  6900. * Gets the center of the bounding sphere in world space
  6901. */
  6902. readonly centerWorld: Vector3;
  6903. /**
  6904. * Radius of the bounding sphere in world space
  6905. */
  6906. radiusWorld: number;
  6907. /**
  6908. * Gets the minimum vector in local space
  6909. */
  6910. readonly minimum: Vector3;
  6911. /**
  6912. * Gets the maximum vector in local space
  6913. */
  6914. readonly maximum: Vector3;
  6915. private _worldMatrix;
  6916. private static readonly TmpVector3;
  6917. /**
  6918. * Creates a new bounding sphere
  6919. * @param min defines the minimum vector (in local space)
  6920. * @param max defines the maximum vector (in local space)
  6921. * @param worldMatrix defines the new world matrix
  6922. */
  6923. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6924. /**
  6925. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6926. * @param min defines the new minimum vector (in local space)
  6927. * @param max defines the new maximum vector (in local space)
  6928. * @param worldMatrix defines the new world matrix
  6929. */
  6930. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6931. /**
  6932. * Scale the current bounding sphere by applying a scale factor
  6933. * @param factor defines the scale factor to apply
  6934. * @returns the current bounding box
  6935. */
  6936. scale(factor: number): BoundingSphere;
  6937. /**
  6938. * Gets the world matrix of the bounding box
  6939. * @returns a matrix
  6940. */
  6941. getWorldMatrix(): DeepImmutable<Matrix>;
  6942. /** @hidden */
  6943. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6944. /**
  6945. * Tests if the bounding sphere is intersecting the frustum planes
  6946. * @param frustumPlanes defines the frustum planes to test
  6947. * @returns true if there is an intersection
  6948. */
  6949. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6950. /**
  6951. * Tests if the bounding sphere center is in between the frustum planes.
  6952. * Used for optimistic fast inclusion.
  6953. * @param frustumPlanes defines the frustum planes to test
  6954. * @returns true if the sphere center is in between the frustum planes
  6955. */
  6956. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6957. /**
  6958. * Tests if a point is inside the bounding sphere
  6959. * @param point defines the point to test
  6960. * @returns true if the point is inside the bounding sphere
  6961. */
  6962. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6963. /**
  6964. * Checks if two sphere intersct
  6965. * @param sphere0 sphere 0
  6966. * @param sphere1 sphere 1
  6967. * @returns true if the speres intersect
  6968. */
  6969. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6970. }
  6971. }
  6972. declare module BABYLON {
  6973. /**
  6974. * Class used to store bounding box information
  6975. */
  6976. export class BoundingBox implements ICullable {
  6977. /**
  6978. * Gets the 8 vectors representing the bounding box in local space
  6979. */
  6980. readonly vectors: Vector3[];
  6981. /**
  6982. * Gets the center of the bounding box in local space
  6983. */
  6984. readonly center: Vector3;
  6985. /**
  6986. * Gets the center of the bounding box in world space
  6987. */
  6988. readonly centerWorld: Vector3;
  6989. /**
  6990. * Gets the extend size in local space
  6991. */
  6992. readonly extendSize: Vector3;
  6993. /**
  6994. * Gets the extend size in world space
  6995. */
  6996. readonly extendSizeWorld: Vector3;
  6997. /**
  6998. * Gets the OBB (object bounding box) directions
  6999. */
  7000. readonly directions: Vector3[];
  7001. /**
  7002. * Gets the 8 vectors representing the bounding box in world space
  7003. */
  7004. readonly vectorsWorld: Vector3[];
  7005. /**
  7006. * Gets the minimum vector in world space
  7007. */
  7008. readonly minimumWorld: Vector3;
  7009. /**
  7010. * Gets the maximum vector in world space
  7011. */
  7012. readonly maximumWorld: Vector3;
  7013. /**
  7014. * Gets the minimum vector in local space
  7015. */
  7016. readonly minimum: Vector3;
  7017. /**
  7018. * Gets the maximum vector in local space
  7019. */
  7020. readonly maximum: Vector3;
  7021. private _worldMatrix;
  7022. private static readonly TmpVector3;
  7023. /**
  7024. * @hidden
  7025. */
  7026. _tag: number;
  7027. /**
  7028. * Creates a new bounding box
  7029. * @param min defines the minimum vector (in local space)
  7030. * @param max defines the maximum vector (in local space)
  7031. * @param worldMatrix defines the new world matrix
  7032. */
  7033. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7034. /**
  7035. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7036. * @param min defines the new minimum vector (in local space)
  7037. * @param max defines the new maximum vector (in local space)
  7038. * @param worldMatrix defines the new world matrix
  7039. */
  7040. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7041. /**
  7042. * Scale the current bounding box by applying a scale factor
  7043. * @param factor defines the scale factor to apply
  7044. * @returns the current bounding box
  7045. */
  7046. scale(factor: number): BoundingBox;
  7047. /**
  7048. * Gets the world matrix of the bounding box
  7049. * @returns a matrix
  7050. */
  7051. getWorldMatrix(): DeepImmutable<Matrix>;
  7052. /** @hidden */
  7053. _update(world: DeepImmutable<Matrix>): void;
  7054. /**
  7055. * Tests if the bounding box is intersecting the frustum planes
  7056. * @param frustumPlanes defines the frustum planes to test
  7057. * @returns true if there is an intersection
  7058. */
  7059. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7060. /**
  7061. * Tests if the bounding box is entirely inside the frustum planes
  7062. * @param frustumPlanes defines the frustum planes to test
  7063. * @returns true if there is an inclusion
  7064. */
  7065. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7066. /**
  7067. * Tests if a point is inside the bounding box
  7068. * @param point defines the point to test
  7069. * @returns true if the point is inside the bounding box
  7070. */
  7071. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7072. /**
  7073. * Tests if the bounding box intersects with a bounding sphere
  7074. * @param sphere defines the sphere to test
  7075. * @returns true if there is an intersection
  7076. */
  7077. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7078. /**
  7079. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7080. * @param min defines the min vector to use
  7081. * @param max defines the max vector to use
  7082. * @returns true if there is an intersection
  7083. */
  7084. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7085. /**
  7086. * Tests if two bounding boxes are intersections
  7087. * @param box0 defines the first box to test
  7088. * @param box1 defines the second box to test
  7089. * @returns true if there is an intersection
  7090. */
  7091. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7092. /**
  7093. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7094. * @param minPoint defines the minimum vector of the bounding box
  7095. * @param maxPoint defines the maximum vector of the bounding box
  7096. * @param sphereCenter defines the sphere center
  7097. * @param sphereRadius defines the sphere radius
  7098. * @returns true if there is an intersection
  7099. */
  7100. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7101. /**
  7102. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7103. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7104. * @param frustumPlanes defines the frustum planes to test
  7105. * @return true if there is an inclusion
  7106. */
  7107. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7108. /**
  7109. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7110. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7111. * @param frustumPlanes defines the frustum planes to test
  7112. * @return true if there is an intersection
  7113. */
  7114. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7115. }
  7116. }
  7117. declare module BABYLON {
  7118. /** @hidden */
  7119. export class Collider {
  7120. /** Define if a collision was found */
  7121. collisionFound: boolean;
  7122. /**
  7123. * Define last intersection point in local space
  7124. */
  7125. intersectionPoint: Vector3;
  7126. /**
  7127. * Define last collided mesh
  7128. */
  7129. collidedMesh: Nullable<AbstractMesh>;
  7130. private _collisionPoint;
  7131. private _planeIntersectionPoint;
  7132. private _tempVector;
  7133. private _tempVector2;
  7134. private _tempVector3;
  7135. private _tempVector4;
  7136. private _edge;
  7137. private _baseToVertex;
  7138. private _destinationPoint;
  7139. private _slidePlaneNormal;
  7140. private _displacementVector;
  7141. /** @hidden */
  7142. _radius: Vector3;
  7143. /** @hidden */
  7144. _retry: number;
  7145. private _velocity;
  7146. private _basePoint;
  7147. private _epsilon;
  7148. /** @hidden */
  7149. _velocityWorldLength: number;
  7150. /** @hidden */
  7151. _basePointWorld: Vector3;
  7152. private _velocityWorld;
  7153. private _normalizedVelocity;
  7154. /** @hidden */
  7155. _initialVelocity: Vector3;
  7156. /** @hidden */
  7157. _initialPosition: Vector3;
  7158. private _nearestDistance;
  7159. private _collisionMask;
  7160. collisionMask: number;
  7161. /**
  7162. * Gets the plane normal used to compute the sliding response (in local space)
  7163. */
  7164. readonly slidePlaneNormal: Vector3;
  7165. /** @hidden */
  7166. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7167. /** @hidden */
  7168. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7169. /** @hidden */
  7170. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7171. /** @hidden */
  7172. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7173. /** @hidden */
  7174. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7175. /** @hidden */
  7176. _getResponse(pos: Vector3, vel: Vector3): void;
  7177. }
  7178. }
  7179. declare module BABYLON {
  7180. /**
  7181. * Interface for cullable objects
  7182. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7183. */
  7184. export interface ICullable {
  7185. /**
  7186. * Checks if the object or part of the object is in the frustum
  7187. * @param frustumPlanes Camera near/planes
  7188. * @returns true if the object is in frustum otherwise false
  7189. */
  7190. isInFrustum(frustumPlanes: Plane[]): boolean;
  7191. /**
  7192. * Checks if a cullable object (mesh...) is in the camera frustum
  7193. * Unlike isInFrustum this cheks the full bounding box
  7194. * @param frustumPlanes Camera near/planes
  7195. * @returns true if the object is in frustum otherwise false
  7196. */
  7197. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7198. }
  7199. /**
  7200. * Info for a bounding data of a mesh
  7201. */
  7202. export class BoundingInfo implements ICullable {
  7203. /**
  7204. * Bounding box for the mesh
  7205. */
  7206. readonly boundingBox: BoundingBox;
  7207. /**
  7208. * Bounding sphere for the mesh
  7209. */
  7210. readonly boundingSphere: BoundingSphere;
  7211. private _isLocked;
  7212. private static readonly TmpVector3;
  7213. /**
  7214. * Constructs bounding info
  7215. * @param minimum min vector of the bounding box/sphere
  7216. * @param maximum max vector of the bounding box/sphere
  7217. * @param worldMatrix defines the new world matrix
  7218. */
  7219. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7220. /**
  7221. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7222. * @param min defines the new minimum vector (in local space)
  7223. * @param max defines the new maximum vector (in local space)
  7224. * @param worldMatrix defines the new world matrix
  7225. */
  7226. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7227. /**
  7228. * min vector of the bounding box/sphere
  7229. */
  7230. readonly minimum: Vector3;
  7231. /**
  7232. * max vector of the bounding box/sphere
  7233. */
  7234. readonly maximum: Vector3;
  7235. /**
  7236. * If the info is locked and won't be updated to avoid perf overhead
  7237. */
  7238. isLocked: boolean;
  7239. /**
  7240. * Updates the bounding sphere and box
  7241. * @param world world matrix to be used to update
  7242. */
  7243. update(world: DeepImmutable<Matrix>): void;
  7244. /**
  7245. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7246. * @param center New center of the bounding info
  7247. * @param extend New extend of the bounding info
  7248. * @returns the current bounding info
  7249. */
  7250. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7251. /**
  7252. * Scale the current bounding info by applying a scale factor
  7253. * @param factor defines the scale factor to apply
  7254. * @returns the current bounding info
  7255. */
  7256. scale(factor: number): BoundingInfo;
  7257. /**
  7258. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7259. * @param frustumPlanes defines the frustum to test
  7260. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7261. * @returns true if the bounding info is in the frustum planes
  7262. */
  7263. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7264. /**
  7265. * Gets the world distance between the min and max points of the bounding box
  7266. */
  7267. readonly diagonalLength: number;
  7268. /**
  7269. * Checks if a cullable object (mesh...) is in the camera frustum
  7270. * Unlike isInFrustum this cheks the full bounding box
  7271. * @param frustumPlanes Camera near/planes
  7272. * @returns true if the object is in frustum otherwise false
  7273. */
  7274. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7275. /** @hidden */
  7276. _checkCollision(collider: Collider): boolean;
  7277. /**
  7278. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7279. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7280. * @param point the point to check intersection with
  7281. * @returns if the point intersects
  7282. */
  7283. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7284. /**
  7285. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7286. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7287. * @param boundingInfo the bounding info to check intersection with
  7288. * @param precise if the intersection should be done using OBB
  7289. * @returns if the bounding info intersects
  7290. */
  7291. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7292. }
  7293. }
  7294. declare module BABYLON {
  7295. /**
  7296. * Defines an array and its length.
  7297. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7298. */
  7299. export interface ISmartArrayLike<T> {
  7300. /**
  7301. * The data of the array.
  7302. */
  7303. data: Array<T>;
  7304. /**
  7305. * The active length of the array.
  7306. */
  7307. length: number;
  7308. }
  7309. /**
  7310. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7311. */
  7312. export class SmartArray<T> implements ISmartArrayLike<T> {
  7313. /**
  7314. * The full set of data from the array.
  7315. */
  7316. data: Array<T>;
  7317. /**
  7318. * The active length of the array.
  7319. */
  7320. length: number;
  7321. protected _id: number;
  7322. /**
  7323. * Instantiates a Smart Array.
  7324. * @param capacity defines the default capacity of the array.
  7325. */
  7326. constructor(capacity: number);
  7327. /**
  7328. * Pushes a value at the end of the active data.
  7329. * @param value defines the object to push in the array.
  7330. */
  7331. push(value: T): void;
  7332. /**
  7333. * Iterates over the active data and apply the lambda to them.
  7334. * @param func defines the action to apply on each value.
  7335. */
  7336. forEach(func: (content: T) => void): void;
  7337. /**
  7338. * Sorts the full sets of data.
  7339. * @param compareFn defines the comparison function to apply.
  7340. */
  7341. sort(compareFn: (a: T, b: T) => number): void;
  7342. /**
  7343. * Resets the active data to an empty array.
  7344. */
  7345. reset(): void;
  7346. /**
  7347. * Releases all the data from the array as well as the array.
  7348. */
  7349. dispose(): void;
  7350. /**
  7351. * Concats the active data with a given array.
  7352. * @param array defines the data to concatenate with.
  7353. */
  7354. concat(array: any): void;
  7355. /**
  7356. * Returns the position of a value in the active data.
  7357. * @param value defines the value to find the index for
  7358. * @returns the index if found in the active data otherwise -1
  7359. */
  7360. indexOf(value: T): number;
  7361. /**
  7362. * Returns whether an element is part of the active data.
  7363. * @param value defines the value to look for
  7364. * @returns true if found in the active data otherwise false
  7365. */
  7366. contains(value: T): boolean;
  7367. private static _GlobalId;
  7368. }
  7369. /**
  7370. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7371. * The data in this array can only be present once
  7372. */
  7373. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7374. private _duplicateId;
  7375. /**
  7376. * Pushes a value at the end of the active data.
  7377. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7378. * @param value defines the object to push in the array.
  7379. */
  7380. push(value: T): void;
  7381. /**
  7382. * Pushes a value at the end of the active data.
  7383. * If the data is already present, it won t be added again
  7384. * @param value defines the object to push in the array.
  7385. * @returns true if added false if it was already present
  7386. */
  7387. pushNoDuplicate(value: T): boolean;
  7388. /**
  7389. * Resets the active data to an empty array.
  7390. */
  7391. reset(): void;
  7392. /**
  7393. * Concats the active data with a given array.
  7394. * This ensures no dupplicate will be present in the result.
  7395. * @param array defines the data to concatenate with.
  7396. */
  7397. concatWithNoDuplicate(array: any): void;
  7398. }
  7399. }
  7400. declare module BABYLON {
  7401. /**
  7402. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7403. * separate meshes. This can be use to improve performances.
  7404. * @see http://doc.babylonjs.com/how_to/multi_materials
  7405. */
  7406. export class MultiMaterial extends Material {
  7407. private _subMaterials;
  7408. /**
  7409. * Gets or Sets the list of Materials used within the multi material.
  7410. * They need to be ordered according to the submeshes order in the associated mesh
  7411. */
  7412. subMaterials: Nullable<Material>[];
  7413. /**
  7414. * Function used to align with Node.getChildren()
  7415. * @returns the list of Materials used within the multi material
  7416. */
  7417. getChildren(): Nullable<Material>[];
  7418. /**
  7419. * Instantiates a new Multi Material
  7420. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7421. * separate meshes. This can be use to improve performances.
  7422. * @see http://doc.babylonjs.com/how_to/multi_materials
  7423. * @param name Define the name in the scene
  7424. * @param scene Define the scene the material belongs to
  7425. */
  7426. constructor(name: string, scene: Scene);
  7427. private _hookArray;
  7428. /**
  7429. * Get one of the submaterial by its index in the submaterials array
  7430. * @param index The index to look the sub material at
  7431. * @returns The Material if the index has been defined
  7432. */
  7433. getSubMaterial(index: number): Nullable<Material>;
  7434. /**
  7435. * Get the list of active textures for the whole sub materials list.
  7436. * @returns All the textures that will be used during the rendering
  7437. */
  7438. getActiveTextures(): BaseTexture[];
  7439. /**
  7440. * Gets the current class name of the material e.g. "MultiMaterial"
  7441. * Mainly use in serialization.
  7442. * @returns the class name
  7443. */
  7444. getClassName(): string;
  7445. /**
  7446. * Checks if the material is ready to render the requested sub mesh
  7447. * @param mesh Define the mesh the submesh belongs to
  7448. * @param subMesh Define the sub mesh to look readyness for
  7449. * @param useInstances Define whether or not the material is used with instances
  7450. * @returns true if ready, otherwise false
  7451. */
  7452. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7453. /**
  7454. * Clones the current material and its related sub materials
  7455. * @param name Define the name of the newly cloned material
  7456. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7457. * @returns the cloned material
  7458. */
  7459. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7460. /**
  7461. * Serializes the materials into a JSON representation.
  7462. * @returns the JSON representation
  7463. */
  7464. serialize(): any;
  7465. /**
  7466. * Dispose the material and release its associated resources
  7467. * @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)
  7468. * @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)
  7469. * @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)
  7470. */
  7471. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7472. /**
  7473. * Creates a MultiMaterial from parsed MultiMaterial data.
  7474. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7475. * @param scene defines the hosting scene
  7476. * @returns a new MultiMaterial
  7477. */
  7478. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7479. }
  7480. }
  7481. declare module BABYLON {
  7482. /**
  7483. * Class used to represent data loading progression
  7484. */
  7485. export class SceneLoaderFlags {
  7486. private static _ForceFullSceneLoadingForIncremental;
  7487. private static _ShowLoadingScreen;
  7488. private static _CleanBoneMatrixWeights;
  7489. private static _loggingLevel;
  7490. /**
  7491. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7492. */
  7493. static ForceFullSceneLoadingForIncremental: boolean;
  7494. /**
  7495. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7496. */
  7497. static ShowLoadingScreen: boolean;
  7498. /**
  7499. * Defines the current logging level (while loading the scene)
  7500. * @ignorenaming
  7501. */
  7502. static loggingLevel: number;
  7503. /**
  7504. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7505. */
  7506. static CleanBoneMatrixWeights: boolean;
  7507. }
  7508. }
  7509. declare module BABYLON {
  7510. /**
  7511. * 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.
  7512. * @see https://doc.babylonjs.com/how_to/transformnode
  7513. */
  7514. export class TransformNode extends Node {
  7515. /**
  7516. * Object will not rotate to face the camera
  7517. */
  7518. static BILLBOARDMODE_NONE: number;
  7519. /**
  7520. * Object will rotate to face the camera but only on the x axis
  7521. */
  7522. static BILLBOARDMODE_X: number;
  7523. /**
  7524. * Object will rotate to face the camera but only on the y axis
  7525. */
  7526. static BILLBOARDMODE_Y: number;
  7527. /**
  7528. * Object will rotate to face the camera but only on the z axis
  7529. */
  7530. static BILLBOARDMODE_Z: number;
  7531. /**
  7532. * Object will rotate to face the camera
  7533. */
  7534. static BILLBOARDMODE_ALL: number;
  7535. private _forward;
  7536. private _forwardInverted;
  7537. private _up;
  7538. private _right;
  7539. private _rightInverted;
  7540. private _position;
  7541. private _rotation;
  7542. private _rotationQuaternion;
  7543. protected _scaling: Vector3;
  7544. protected _isDirty: boolean;
  7545. private _transformToBoneReferal;
  7546. private _billboardMode;
  7547. /**
  7548. * Gets or sets the billboard mode. Default is 0.
  7549. *
  7550. * | Value | Type | Description |
  7551. * | --- | --- | --- |
  7552. * | 0 | BILLBOARDMODE_NONE | |
  7553. * | 1 | BILLBOARDMODE_X | |
  7554. * | 2 | BILLBOARDMODE_Y | |
  7555. * | 4 | BILLBOARDMODE_Z | |
  7556. * | 7 | BILLBOARDMODE_ALL | |
  7557. *
  7558. */
  7559. billboardMode: number;
  7560. private _preserveParentRotationForBillboard;
  7561. /**
  7562. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7563. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7564. */
  7565. preserveParentRotationForBillboard: boolean;
  7566. /**
  7567. * 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
  7568. */
  7569. scalingDeterminant: number;
  7570. private _infiniteDistance;
  7571. /**
  7572. * Gets or sets the distance of the object to max, often used by skybox
  7573. */
  7574. infiniteDistance: boolean;
  7575. /**
  7576. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7577. * By default the system will update normals to compensate
  7578. */
  7579. ignoreNonUniformScaling: boolean;
  7580. /**
  7581. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7582. */
  7583. reIntegrateRotationIntoRotationQuaternion: boolean;
  7584. /** @hidden */
  7585. _poseMatrix: Nullable<Matrix>;
  7586. /** @hidden */
  7587. _localMatrix: Matrix;
  7588. private _usePivotMatrix;
  7589. private _absolutePosition;
  7590. private _pivotMatrix;
  7591. private _pivotMatrixInverse;
  7592. protected _postMultiplyPivotMatrix: boolean;
  7593. protected _isWorldMatrixFrozen: boolean;
  7594. /** @hidden */
  7595. _indexInSceneTransformNodesArray: number;
  7596. /**
  7597. * An event triggered after the world matrix is updated
  7598. */
  7599. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7600. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7601. /**
  7602. * Gets a string identifying the name of the class
  7603. * @returns "TransformNode" string
  7604. */
  7605. getClassName(): string;
  7606. /**
  7607. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7608. */
  7609. position: Vector3;
  7610. /**
  7611. * 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)).
  7612. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7613. */
  7614. rotation: Vector3;
  7615. /**
  7616. * 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)).
  7617. */
  7618. scaling: Vector3;
  7619. /**
  7620. * 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).
  7621. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7622. */
  7623. rotationQuaternion: Nullable<Quaternion>;
  7624. /**
  7625. * The forward direction of that transform in world space.
  7626. */
  7627. readonly forward: Vector3;
  7628. /**
  7629. * The up direction of that transform in world space.
  7630. */
  7631. readonly up: Vector3;
  7632. /**
  7633. * The right direction of that transform in world space.
  7634. */
  7635. readonly right: Vector3;
  7636. /**
  7637. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7638. * @param matrix the matrix to copy the pose from
  7639. * @returns this TransformNode.
  7640. */
  7641. updatePoseMatrix(matrix: Matrix): TransformNode;
  7642. /**
  7643. * Returns the mesh Pose matrix.
  7644. * @returns the pose matrix
  7645. */
  7646. getPoseMatrix(): Matrix;
  7647. /** @hidden */
  7648. _isSynchronized(): boolean;
  7649. /** @hidden */
  7650. _initCache(): void;
  7651. /**
  7652. * Flag the transform node as dirty (Forcing it to update everything)
  7653. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7654. * @returns this transform node
  7655. */
  7656. markAsDirty(property: string): TransformNode;
  7657. /**
  7658. * Returns the current mesh absolute position.
  7659. * Returns a Vector3.
  7660. */
  7661. readonly absolutePosition: Vector3;
  7662. /**
  7663. * Sets a new matrix to apply before all other transformation
  7664. * @param matrix defines the transform matrix
  7665. * @returns the current TransformNode
  7666. */
  7667. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7668. /**
  7669. * Sets a new pivot matrix to the current node
  7670. * @param matrix defines the new pivot matrix to use
  7671. * @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
  7672. * @returns the current TransformNode
  7673. */
  7674. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7675. /**
  7676. * Returns the mesh pivot matrix.
  7677. * Default : Identity.
  7678. * @returns the matrix
  7679. */
  7680. getPivotMatrix(): Matrix;
  7681. /**
  7682. * Prevents the World matrix to be computed any longer.
  7683. * @returns the TransformNode.
  7684. */
  7685. freezeWorldMatrix(): TransformNode;
  7686. /**
  7687. * Allows back the World matrix computation.
  7688. * @returns the TransformNode.
  7689. */
  7690. unfreezeWorldMatrix(): this;
  7691. /**
  7692. * True if the World matrix has been frozen.
  7693. */
  7694. readonly isWorldMatrixFrozen: boolean;
  7695. /**
  7696. * Retuns the mesh absolute position in the World.
  7697. * @returns a Vector3.
  7698. */
  7699. getAbsolutePosition(): Vector3;
  7700. /**
  7701. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7702. * @param absolutePosition the absolute position to set
  7703. * @returns the TransformNode.
  7704. */
  7705. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7706. /**
  7707. * Sets the mesh position in its local space.
  7708. * @param vector3 the position to set in localspace
  7709. * @returns the TransformNode.
  7710. */
  7711. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7712. /**
  7713. * Returns the mesh position in the local space from the current World matrix values.
  7714. * @returns a new Vector3.
  7715. */
  7716. getPositionExpressedInLocalSpace(): Vector3;
  7717. /**
  7718. * Translates the mesh along the passed Vector3 in its local space.
  7719. * @param vector3 the distance to translate in localspace
  7720. * @returns the TransformNode.
  7721. */
  7722. locallyTranslate(vector3: Vector3): TransformNode;
  7723. private static _lookAtVectorCache;
  7724. /**
  7725. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7726. * @param targetPoint the position (must be in same space as current mesh) to look at
  7727. * @param yawCor optional yaw (y-axis) correction in radians
  7728. * @param pitchCor optional pitch (x-axis) correction in radians
  7729. * @param rollCor optional roll (z-axis) correction in radians
  7730. * @param space the choosen space of the target
  7731. * @returns the TransformNode.
  7732. */
  7733. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7734. /**
  7735. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7736. * This Vector3 is expressed in the World space.
  7737. * @param localAxis axis to rotate
  7738. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7739. */
  7740. getDirection(localAxis: Vector3): Vector3;
  7741. /**
  7742. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7743. * localAxis is expressed in the mesh local space.
  7744. * result is computed in the Wordl space from the mesh World matrix.
  7745. * @param localAxis axis to rotate
  7746. * @param result the resulting transformnode
  7747. * @returns this TransformNode.
  7748. */
  7749. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7750. /**
  7751. * Sets this transform node rotation to the given local axis.
  7752. * @param localAxis the axis in local space
  7753. * @param yawCor optional yaw (y-axis) correction in radians
  7754. * @param pitchCor optional pitch (x-axis) correction in radians
  7755. * @param rollCor optional roll (z-axis) correction in radians
  7756. * @returns this TransformNode
  7757. */
  7758. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7759. /**
  7760. * Sets a new pivot point to the current node
  7761. * @param point defines the new pivot point to use
  7762. * @param space defines if the point is in world or local space (local by default)
  7763. * @returns the current TransformNode
  7764. */
  7765. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7766. /**
  7767. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7768. * @returns the pivot point
  7769. */
  7770. getPivotPoint(): Vector3;
  7771. /**
  7772. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7773. * @param result the vector3 to store the result
  7774. * @returns this TransformNode.
  7775. */
  7776. getPivotPointToRef(result: Vector3): TransformNode;
  7777. /**
  7778. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7779. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7780. */
  7781. getAbsolutePivotPoint(): Vector3;
  7782. /**
  7783. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7784. * @param result vector3 to store the result
  7785. * @returns this TransformNode.
  7786. */
  7787. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7788. /**
  7789. * Defines the passed node as the parent of the current node.
  7790. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7791. * @see https://doc.babylonjs.com/how_to/parenting
  7792. * @param node the node ot set as the parent
  7793. * @returns this TransformNode.
  7794. */
  7795. setParent(node: Nullable<Node>): TransformNode;
  7796. private _nonUniformScaling;
  7797. /**
  7798. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7799. */
  7800. readonly nonUniformScaling: boolean;
  7801. /** @hidden */
  7802. _updateNonUniformScalingState(value: boolean): boolean;
  7803. /**
  7804. * Attach the current TransformNode to another TransformNode associated with a bone
  7805. * @param bone Bone affecting the TransformNode
  7806. * @param affectedTransformNode TransformNode associated with the bone
  7807. * @returns this object
  7808. */
  7809. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7810. /**
  7811. * Detach the transform node if its associated with a bone
  7812. * @returns this object
  7813. */
  7814. detachFromBone(): TransformNode;
  7815. private static _rotationAxisCache;
  7816. /**
  7817. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7818. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7819. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7820. * The passed axis is also normalized.
  7821. * @param axis the axis to rotate around
  7822. * @param amount the amount to rotate in radians
  7823. * @param space Space to rotate in (Default: local)
  7824. * @returns the TransformNode.
  7825. */
  7826. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7827. /**
  7828. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7829. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7830. * The passed axis is also normalized. .
  7831. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7832. * @param point the point to rotate around
  7833. * @param axis the axis to rotate around
  7834. * @param amount the amount to rotate in radians
  7835. * @returns the TransformNode
  7836. */
  7837. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7838. /**
  7839. * Translates the mesh along the axis vector for the passed distance in the given space.
  7840. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7841. * @param axis the axis to translate in
  7842. * @param distance the distance to translate
  7843. * @param space Space to rotate in (Default: local)
  7844. * @returns the TransformNode.
  7845. */
  7846. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7847. /**
  7848. * Adds a rotation step to the mesh current rotation.
  7849. * x, y, z are Euler angles expressed in radians.
  7850. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7851. * This means this rotation is made in the mesh local space only.
  7852. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7853. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7854. * ```javascript
  7855. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7856. * ```
  7857. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7858. * 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.
  7859. * @param x Rotation to add
  7860. * @param y Rotation to add
  7861. * @param z Rotation to add
  7862. * @returns the TransformNode.
  7863. */
  7864. addRotation(x: number, y: number, z: number): TransformNode;
  7865. /**
  7866. * @hidden
  7867. */
  7868. protected _getEffectiveParent(): Nullable<Node>;
  7869. /**
  7870. * Computes the world matrix of the node
  7871. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7872. * @returns the world matrix
  7873. */
  7874. computeWorldMatrix(force?: boolean): Matrix;
  7875. protected _afterComputeWorldMatrix(): void;
  7876. /**
  7877. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7878. * @param func callback function to add
  7879. *
  7880. * @returns the TransformNode.
  7881. */
  7882. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7883. /**
  7884. * Removes a registered callback function.
  7885. * @param func callback function to remove
  7886. * @returns the TransformNode.
  7887. */
  7888. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7889. /**
  7890. * Gets the position of the current mesh in camera space
  7891. * @param camera defines the camera to use
  7892. * @returns a position
  7893. */
  7894. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7895. /**
  7896. * Returns the distance from the mesh to the active camera
  7897. * @param camera defines the camera to use
  7898. * @returns the distance
  7899. */
  7900. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7901. /**
  7902. * Clone the current transform node
  7903. * @param name Name of the new clone
  7904. * @param newParent New parent for the clone
  7905. * @param doNotCloneChildren Do not clone children hierarchy
  7906. * @returns the new transform node
  7907. */
  7908. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7909. /**
  7910. * Serializes the objects information.
  7911. * @param currentSerializationObject defines the object to serialize in
  7912. * @returns the serialized object
  7913. */
  7914. serialize(currentSerializationObject?: any): any;
  7915. /**
  7916. * Returns a new TransformNode object parsed from the source provided.
  7917. * @param parsedTransformNode is the source.
  7918. * @param scene the scne the object belongs to
  7919. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7920. * @returns a new TransformNode object parsed from the source provided.
  7921. */
  7922. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7923. /**
  7924. * Get all child-transformNodes of this node
  7925. * @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
  7926. * @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
  7927. * @returns an array of TransformNode
  7928. */
  7929. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7930. /**
  7931. * Releases resources associated with this transform node.
  7932. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7933. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7934. */
  7935. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7936. }
  7937. }
  7938. declare module BABYLON {
  7939. /**
  7940. * Class used to override all child animations of a given target
  7941. */
  7942. export class AnimationPropertiesOverride {
  7943. /**
  7944. * Gets or sets a value indicating if animation blending must be used
  7945. */
  7946. enableBlending: boolean;
  7947. /**
  7948. * Gets or sets the blending speed to use when enableBlending is true
  7949. */
  7950. blendingSpeed: number;
  7951. /**
  7952. * Gets or sets the default loop mode to use
  7953. */
  7954. loopMode: number;
  7955. }
  7956. }
  7957. declare module BABYLON {
  7958. /**
  7959. * Class used to store bone information
  7960. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7961. */
  7962. export class Bone extends Node {
  7963. /**
  7964. * defines the bone name
  7965. */
  7966. name: string;
  7967. private static _tmpVecs;
  7968. private static _tmpQuat;
  7969. private static _tmpMats;
  7970. /**
  7971. * Gets the list of child bones
  7972. */
  7973. children: Bone[];
  7974. /** Gets the animations associated with this bone */
  7975. animations: Animation[];
  7976. /**
  7977. * Gets or sets bone length
  7978. */
  7979. length: number;
  7980. /**
  7981. * @hidden Internal only
  7982. * Set this value to map this bone to a different index in the transform matrices
  7983. * Set this value to -1 to exclude the bone from the transform matrices
  7984. */
  7985. _index: Nullable<number>;
  7986. private _skeleton;
  7987. private _localMatrix;
  7988. private _restPose;
  7989. private _baseMatrix;
  7990. private _absoluteTransform;
  7991. private _invertedAbsoluteTransform;
  7992. private _parent;
  7993. private _scalingDeterminant;
  7994. private _worldTransform;
  7995. private _localScaling;
  7996. private _localRotation;
  7997. private _localPosition;
  7998. private _needToDecompose;
  7999. private _needToCompose;
  8000. /** @hidden */
  8001. _linkedTransformNode: Nullable<TransformNode>;
  8002. /** @hidden */
  8003. _waitingTransformNodeId: Nullable<string>;
  8004. /** @hidden */
  8005. /** @hidden */
  8006. _matrix: Matrix;
  8007. /**
  8008. * Create a new bone
  8009. * @param name defines the bone name
  8010. * @param skeleton defines the parent skeleton
  8011. * @param parentBone defines the parent (can be null if the bone is the root)
  8012. * @param localMatrix defines the local matrix
  8013. * @param restPose defines the rest pose matrix
  8014. * @param baseMatrix defines the base matrix
  8015. * @param index defines index of the bone in the hiearchy
  8016. */
  8017. constructor(
  8018. /**
  8019. * defines the bone name
  8020. */
  8021. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8022. /**
  8023. * Gets the current object class name.
  8024. * @return the class name
  8025. */
  8026. getClassName(): string;
  8027. /**
  8028. * Gets the parent skeleton
  8029. * @returns a skeleton
  8030. */
  8031. getSkeleton(): Skeleton;
  8032. /**
  8033. * Gets parent bone
  8034. * @returns a bone or null if the bone is the root of the bone hierarchy
  8035. */
  8036. getParent(): Nullable<Bone>;
  8037. /**
  8038. * Returns an array containing the root bones
  8039. * @returns an array containing the root bones
  8040. */
  8041. getChildren(): Array<Bone>;
  8042. /**
  8043. * Sets the parent bone
  8044. * @param parent defines the parent (can be null if the bone is the root)
  8045. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8046. */
  8047. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8048. /**
  8049. * Gets the local matrix
  8050. * @returns a matrix
  8051. */
  8052. getLocalMatrix(): Matrix;
  8053. /**
  8054. * Gets the base matrix (initial matrix which remains unchanged)
  8055. * @returns a matrix
  8056. */
  8057. getBaseMatrix(): Matrix;
  8058. /**
  8059. * Gets the rest pose matrix
  8060. * @returns a matrix
  8061. */
  8062. getRestPose(): Matrix;
  8063. /**
  8064. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8065. */
  8066. getWorldMatrix(): Matrix;
  8067. /**
  8068. * Sets the local matrix to rest pose matrix
  8069. */
  8070. returnToRest(): void;
  8071. /**
  8072. * Gets the inverse of the absolute transform matrix.
  8073. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8074. * @returns a matrix
  8075. */
  8076. getInvertedAbsoluteTransform(): Matrix;
  8077. /**
  8078. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8079. * @returns a matrix
  8080. */
  8081. getAbsoluteTransform(): Matrix;
  8082. /**
  8083. * Links with the given transform node.
  8084. * The local matrix of this bone is copied from the transform node every frame.
  8085. * @param transformNode defines the transform node to link to
  8086. */
  8087. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8088. /** Gets or sets current position (in local space) */
  8089. position: Vector3;
  8090. /** Gets or sets current rotation (in local space) */
  8091. rotation: Vector3;
  8092. /** Gets or sets current rotation quaternion (in local space) */
  8093. rotationQuaternion: Quaternion;
  8094. /** Gets or sets current scaling (in local space) */
  8095. scaling: Vector3;
  8096. /**
  8097. * Gets the animation properties override
  8098. */
  8099. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8100. private _decompose;
  8101. private _compose;
  8102. /**
  8103. * Update the base and local matrices
  8104. * @param matrix defines the new base or local matrix
  8105. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8106. * @param updateLocalMatrix defines if the local matrix should be updated
  8107. */
  8108. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8109. /** @hidden */
  8110. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8111. /**
  8112. * Flag the bone as dirty (Forcing it to update everything)
  8113. */
  8114. markAsDirty(): void;
  8115. private _markAsDirtyAndCompose;
  8116. private _markAsDirtyAndDecompose;
  8117. /**
  8118. * Translate the bone in local or world space
  8119. * @param vec The amount to translate the bone
  8120. * @param space The space that the translation is in
  8121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8122. */
  8123. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8124. /**
  8125. * Set the postion of the bone in local or world space
  8126. * @param position The position to set the bone
  8127. * @param space The space that the position is in
  8128. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8129. */
  8130. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8131. /**
  8132. * Set the absolute position of the bone (world space)
  8133. * @param position The position to set the bone
  8134. * @param mesh The mesh that this bone is attached to
  8135. */
  8136. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8137. /**
  8138. * Scale the bone on the x, y and z axes (in local space)
  8139. * @param x The amount to scale the bone on the x axis
  8140. * @param y The amount to scale the bone on the y axis
  8141. * @param z The amount to scale the bone on the z axis
  8142. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8143. */
  8144. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8145. /**
  8146. * Set the bone scaling in local space
  8147. * @param scale defines the scaling vector
  8148. */
  8149. setScale(scale: Vector3): void;
  8150. /**
  8151. * Gets the current scaling in local space
  8152. * @returns the current scaling vector
  8153. */
  8154. getScale(): Vector3;
  8155. /**
  8156. * Gets the current scaling in local space and stores it in a target vector
  8157. * @param result defines the target vector
  8158. */
  8159. getScaleToRef(result: Vector3): void;
  8160. /**
  8161. * Set the yaw, pitch, and roll of the bone in local or world space
  8162. * @param yaw The rotation of the bone on the y axis
  8163. * @param pitch The rotation of the bone on the x axis
  8164. * @param roll The rotation of the bone on the z axis
  8165. * @param space The space that the axes of rotation are in
  8166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8167. */
  8168. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8169. /**
  8170. * Add a rotation to the bone on an axis in local or world space
  8171. * @param axis The axis to rotate the bone on
  8172. * @param amount The amount to rotate the bone
  8173. * @param space The space that the axis is in
  8174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8175. */
  8176. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8177. /**
  8178. * Set the rotation of the bone to a particular axis angle in local or world space
  8179. * @param axis The axis to rotate the bone on
  8180. * @param angle The angle that the bone should be rotated to
  8181. * @param space The space that the axis is in
  8182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8183. */
  8184. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8185. /**
  8186. * Set the euler rotation of the bone in local of world space
  8187. * @param rotation The euler rotation that the bone should be set to
  8188. * @param space The space that the rotation is in
  8189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8190. */
  8191. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8192. /**
  8193. * Set the quaternion rotation of the bone in local of world space
  8194. * @param quat The quaternion rotation that the bone should be set to
  8195. * @param space The space that the rotation is in
  8196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8197. */
  8198. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8199. /**
  8200. * Set the rotation matrix of the bone in local of world space
  8201. * @param rotMat The rotation matrix that the bone should be set to
  8202. * @param space The space that the rotation is in
  8203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8204. */
  8205. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8206. private _rotateWithMatrix;
  8207. private _getNegativeRotationToRef;
  8208. /**
  8209. * Get the position of the bone in local or world space
  8210. * @param space The space that the returned position is in
  8211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8212. * @returns The position of the bone
  8213. */
  8214. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8215. /**
  8216. * Copy the position of the bone to a vector3 in local or world space
  8217. * @param space The space that the returned position is in
  8218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8219. * @param result The vector3 to copy the position to
  8220. */
  8221. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8222. /**
  8223. * Get the absolute position of the bone (world space)
  8224. * @param mesh The mesh that this bone is attached to
  8225. * @returns The absolute position of the bone
  8226. */
  8227. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8228. /**
  8229. * Copy the absolute position of the bone (world space) to the result param
  8230. * @param mesh The mesh that this bone is attached to
  8231. * @param result The vector3 to copy the absolute position to
  8232. */
  8233. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8234. /**
  8235. * Compute the absolute transforms of this bone and its children
  8236. */
  8237. computeAbsoluteTransforms(): void;
  8238. /**
  8239. * Get the world direction from an axis that is in the local space of the bone
  8240. * @param localAxis The local direction that is used to compute the world direction
  8241. * @param mesh The mesh that this bone is attached to
  8242. * @returns The world direction
  8243. */
  8244. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8245. /**
  8246. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8247. * @param localAxis The local direction that is used to compute the world direction
  8248. * @param mesh The mesh that this bone is attached to
  8249. * @param result The vector3 that the world direction will be copied to
  8250. */
  8251. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8252. /**
  8253. * Get the euler rotation of the bone in local or world space
  8254. * @param space The space that the rotation should be in
  8255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8256. * @returns The euler rotation
  8257. */
  8258. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8259. /**
  8260. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8261. * @param space The space that the rotation should be in
  8262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8263. * @param result The vector3 that the rotation should be copied to
  8264. */
  8265. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8266. /**
  8267. * Get the quaternion rotation of the bone in either local or world space
  8268. * @param space The space that the rotation should be in
  8269. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8270. * @returns The quaternion rotation
  8271. */
  8272. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8273. /**
  8274. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8275. * @param space The space that the rotation should be in
  8276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8277. * @param result The quaternion that the rotation should be copied to
  8278. */
  8279. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8280. /**
  8281. * Get the rotation matrix of the bone in local or world space
  8282. * @param space The space that the rotation should be in
  8283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8284. * @returns The rotation matrix
  8285. */
  8286. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8287. /**
  8288. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8289. * @param space The space that the rotation should be in
  8290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8291. * @param result The quaternion that the rotation should be copied to
  8292. */
  8293. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8294. /**
  8295. * Get the world position of a point that is in the local space of the bone
  8296. * @param position The local position
  8297. * @param mesh The mesh that this bone is attached to
  8298. * @returns The world position
  8299. */
  8300. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8301. /**
  8302. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8303. * @param position The local position
  8304. * @param mesh The mesh that this bone is attached to
  8305. * @param result The vector3 that the world position should be copied to
  8306. */
  8307. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8308. /**
  8309. * Get the local position of a point that is in world space
  8310. * @param position The world position
  8311. * @param mesh The mesh that this bone is attached to
  8312. * @returns The local position
  8313. */
  8314. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8315. /**
  8316. * Get the local position of a point that is in world space and copy it to the result param
  8317. * @param position The world position
  8318. * @param mesh The mesh that this bone is attached to
  8319. * @param result The vector3 that the local position should be copied to
  8320. */
  8321. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8322. }
  8323. }
  8324. declare module BABYLON {
  8325. /**
  8326. * Enum that determines the text-wrapping mode to use.
  8327. */
  8328. export enum InspectableType {
  8329. /**
  8330. * Checkbox for booleans
  8331. */
  8332. Checkbox = 0,
  8333. /**
  8334. * Sliders for numbers
  8335. */
  8336. Slider = 1,
  8337. /**
  8338. * Vector3
  8339. */
  8340. Vector3 = 2,
  8341. /**
  8342. * Quaternions
  8343. */
  8344. Quaternion = 3,
  8345. /**
  8346. * Color3
  8347. */
  8348. Color3 = 4
  8349. }
  8350. /**
  8351. * Interface used to define custom inspectable properties.
  8352. * This interface is used by the inspector to display custom property grids
  8353. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8354. */
  8355. export interface IInspectable {
  8356. /**
  8357. * Gets the label to display
  8358. */
  8359. label: string;
  8360. /**
  8361. * Gets the name of the property to edit
  8362. */
  8363. propertyName: string;
  8364. /**
  8365. * Gets the type of the editor to use
  8366. */
  8367. type: InspectableType;
  8368. /**
  8369. * Gets the minimum value of the property when using in "slider" mode
  8370. */
  8371. min?: number;
  8372. /**
  8373. * Gets the maximum value of the property when using in "slider" mode
  8374. */
  8375. max?: number;
  8376. /**
  8377. * Gets the setp to use when using in "slider" mode
  8378. */
  8379. step?: number;
  8380. }
  8381. }
  8382. declare module BABYLON {
  8383. /**
  8384. * This represents the required contract to create a new type of texture loader.
  8385. */
  8386. export interface IInternalTextureLoader {
  8387. /**
  8388. * Defines wether the loader supports cascade loading the different faces.
  8389. */
  8390. supportCascades: boolean;
  8391. /**
  8392. * This returns if the loader support the current file information.
  8393. * @param extension defines the file extension of the file being loaded
  8394. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8395. * @param fallback defines the fallback internal texture if any
  8396. * @param isBase64 defines whether the texture is encoded as a base64
  8397. * @param isBuffer defines whether the texture data are stored as a buffer
  8398. * @returns true if the loader can load the specified file
  8399. */
  8400. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8401. /**
  8402. * Transform the url before loading if required.
  8403. * @param rootUrl the url of the texture
  8404. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8405. * @returns the transformed texture
  8406. */
  8407. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8408. /**
  8409. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8410. * @param rootUrl the url of the texture
  8411. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8412. * @returns the fallback texture
  8413. */
  8414. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8415. /**
  8416. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8417. * @param data contains the texture data
  8418. * @param texture defines the BabylonJS internal texture
  8419. * @param createPolynomials will be true if polynomials have been requested
  8420. * @param onLoad defines the callback to trigger once the texture is ready
  8421. * @param onError defines the callback to trigger in case of error
  8422. */
  8423. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8424. /**
  8425. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8426. * @param data contains the texture data
  8427. * @param texture defines the BabylonJS internal texture
  8428. * @param callback defines the method to call once ready to upload
  8429. */
  8430. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8431. }
  8432. }
  8433. declare module BABYLON {
  8434. interface Engine {
  8435. /**
  8436. * Creates a depth stencil cube texture.
  8437. * This is only available in WebGL 2.
  8438. * @param size The size of face edge in the cube texture.
  8439. * @param options The options defining the cube texture.
  8440. * @returns The cube texture
  8441. */
  8442. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8443. /**
  8444. * Creates a cube texture
  8445. * @param rootUrl defines the url where the files to load is located
  8446. * @param scene defines the current scene
  8447. * @param files defines the list of files to load (1 per face)
  8448. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8449. * @param onLoad defines an optional callback raised when the texture is loaded
  8450. * @param onError defines an optional callback raised if there is an issue to load the texture
  8451. * @param format defines the format of the data
  8452. * @param forcedExtension defines the extension to use to pick the right loader
  8453. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8454. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8455. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8456. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8457. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8458. * @returns the cube texture as an InternalTexture
  8459. */
  8460. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  8461. /**
  8462. * Creates a cube texture
  8463. * @param rootUrl defines the url where the files to load is located
  8464. * @param scene defines the current scene
  8465. * @param files defines the list of files to load (1 per face)
  8466. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8467. * @param onLoad defines an optional callback raised when the texture is loaded
  8468. * @param onError defines an optional callback raised if there is an issue to load the texture
  8469. * @param format defines the format of the data
  8470. * @param forcedExtension defines the extension to use to pick the right loader
  8471. * @returns the cube texture as an InternalTexture
  8472. */
  8473. 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 | undefined, forcedExtension: any): InternalTexture;
  8474. /**
  8475. * Creates a cube texture
  8476. * @param rootUrl defines the url where the files to load is located
  8477. * @param scene defines the current scene
  8478. * @param files defines the list of files to load (1 per face)
  8479. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8480. * @param onLoad defines an optional callback raised when the texture is loaded
  8481. * @param onError defines an optional callback raised if there is an issue to load the texture
  8482. * @param format defines the format of the data
  8483. * @param forcedExtension defines the extension to use to pick the right loader
  8484. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8485. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8486. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8487. * @returns the cube texture as an InternalTexture
  8488. */
  8489. 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 | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  8490. /** @hidden */
  8491. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8492. /** @hidden */
  8493. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8494. /** @hidden */
  8495. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8496. /** @hidden */
  8497. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8498. }
  8499. }
  8500. declare module BABYLON {
  8501. /**
  8502. * Class for creating a cube texture
  8503. */
  8504. export class CubeTexture extends BaseTexture {
  8505. private _delayedOnLoad;
  8506. /**
  8507. * The url of the texture
  8508. */
  8509. url: string;
  8510. /**
  8511. * Gets or sets the center of the bounding box associated with the cube texture.
  8512. * It must define where the camera used to render the texture was set
  8513. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8514. */
  8515. boundingBoxPosition: Vector3;
  8516. private _boundingBoxSize;
  8517. /**
  8518. * Gets or sets the size of the bounding box associated with the cube texture
  8519. * When defined, the cubemap will switch to local mode
  8520. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8521. * @example https://www.babylonjs-playground.com/#RNASML
  8522. */
  8523. /**
  8524. * Returns the bounding box size
  8525. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8526. */
  8527. boundingBoxSize: Vector3;
  8528. protected _rotationY: number;
  8529. /**
  8530. * Sets texture matrix rotation angle around Y axis in radians.
  8531. */
  8532. /**
  8533. * Gets texture matrix rotation angle around Y axis radians.
  8534. */
  8535. rotationY: number;
  8536. /**
  8537. * Are mip maps generated for this texture or not.
  8538. */
  8539. readonly noMipmap: boolean;
  8540. private _noMipmap;
  8541. private _files;
  8542. private _extensions;
  8543. private _textureMatrix;
  8544. private _format;
  8545. private _createPolynomials;
  8546. /** @hidden */
  8547. _prefiltered: boolean;
  8548. /**
  8549. * Creates a cube texture from an array of image urls
  8550. * @param files defines an array of image urls
  8551. * @param scene defines the hosting scene
  8552. * @param noMipmap specifies if mip maps are not used
  8553. * @returns a cube texture
  8554. */
  8555. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8556. /**
  8557. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8558. * @param url defines the url of the prefiltered texture
  8559. * @param scene defines the scene the texture is attached to
  8560. * @param forcedExtension defines the extension of the file if different from the url
  8561. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8562. * @return the prefiltered texture
  8563. */
  8564. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8565. /**
  8566. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8567. * as prefiltered data.
  8568. * @param rootUrl defines the url of the texture or the root name of the six images
  8569. * @param scene defines the scene the texture is attached to
  8570. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8571. * @param noMipmap defines if mipmaps should be created or not
  8572. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8573. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8574. * @param onError defines a callback triggered in case of error during load
  8575. * @param format defines the internal format to use for the texture once loaded
  8576. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8577. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8578. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8579. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8580. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8581. * @return the cube texture
  8582. */
  8583. 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);
  8584. /**
  8585. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8586. */
  8587. readonly isPrefiltered: boolean;
  8588. /**
  8589. * Get the current class name of the texture useful for serialization or dynamic coding.
  8590. * @returns "CubeTexture"
  8591. */
  8592. getClassName(): string;
  8593. /**
  8594. * Update the url (and optional buffer) of this texture if url was null during construction.
  8595. * @param url the url of the texture
  8596. * @param forcedExtension defines the extension to use
  8597. * @param onLoad callback called when the texture is loaded (defaults to null)
  8598. */
  8599. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8600. /**
  8601. * Delays loading of the cube texture
  8602. * @param forcedExtension defines the extension to use
  8603. */
  8604. delayLoad(forcedExtension?: string): void;
  8605. /**
  8606. * Returns the reflection texture matrix
  8607. * @returns the reflection texture matrix
  8608. */
  8609. getReflectionTextureMatrix(): Matrix;
  8610. /**
  8611. * Sets the reflection texture matrix
  8612. * @param value Reflection texture matrix
  8613. */
  8614. setReflectionTextureMatrix(value: Matrix): void;
  8615. /**
  8616. * Parses text to create a cube texture
  8617. * @param parsedTexture define the serialized text to read from
  8618. * @param scene defines the hosting scene
  8619. * @param rootUrl defines the root url of the cube texture
  8620. * @returns a cube texture
  8621. */
  8622. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8623. /**
  8624. * Makes a clone, or deep copy, of the cube texture
  8625. * @returns a new cube texture
  8626. */
  8627. clone(): CubeTexture;
  8628. }
  8629. }
  8630. declare module BABYLON {
  8631. /** @hidden */
  8632. export var postprocessVertexShader: {
  8633. name: string;
  8634. shader: string;
  8635. };
  8636. }
  8637. declare module BABYLON {
  8638. /**
  8639. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8640. * This is the base of the follow, arc rotate cameras and Free camera
  8641. * @see http://doc.babylonjs.com/features/cameras
  8642. */
  8643. export class TargetCamera extends Camera {
  8644. private static _RigCamTransformMatrix;
  8645. private static _TargetTransformMatrix;
  8646. private static _TargetFocalPoint;
  8647. /**
  8648. * Define the current direction the camera is moving to
  8649. */
  8650. cameraDirection: Vector3;
  8651. /**
  8652. * Define the current rotation the camera is rotating to
  8653. */
  8654. cameraRotation: Vector2;
  8655. /**
  8656. * When set, the up vector of the camera will be updated by the rotation of the camera
  8657. */
  8658. updateUpVectorFromRotation: boolean;
  8659. private _tmpQuaternion;
  8660. /**
  8661. * Define the current rotation of the camera
  8662. */
  8663. rotation: Vector3;
  8664. /**
  8665. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8666. */
  8667. rotationQuaternion: Quaternion;
  8668. /**
  8669. * Define the current speed of the camera
  8670. */
  8671. speed: number;
  8672. /**
  8673. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8674. * around all axis.
  8675. */
  8676. noRotationConstraint: boolean;
  8677. /**
  8678. * Define the current target of the camera as an object or a position.
  8679. */
  8680. lockedTarget: any;
  8681. /** @hidden */
  8682. _currentTarget: Vector3;
  8683. /** @hidden */
  8684. _initialFocalDistance: number;
  8685. /** @hidden */
  8686. _viewMatrix: Matrix;
  8687. /** @hidden */
  8688. _camMatrix: Matrix;
  8689. /** @hidden */
  8690. _cameraTransformMatrix: Matrix;
  8691. /** @hidden */
  8692. _cameraRotationMatrix: Matrix;
  8693. /** @hidden */
  8694. _referencePoint: Vector3;
  8695. /** @hidden */
  8696. _transformedReferencePoint: Vector3;
  8697. protected _globalCurrentTarget: Vector3;
  8698. protected _globalCurrentUpVector: Vector3;
  8699. /** @hidden */
  8700. _reset: () => void;
  8701. private _defaultUp;
  8702. /**
  8703. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8704. * This is the base of the follow, arc rotate cameras and Free camera
  8705. * @see http://doc.babylonjs.com/features/cameras
  8706. * @param name Defines the name of the camera in the scene
  8707. * @param position Defines the start position of the camera in the scene
  8708. * @param scene Defines the scene the camera belongs to
  8709. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8710. */
  8711. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8712. /**
  8713. * Gets the position in front of the camera at a given distance.
  8714. * @param distance The distance from the camera we want the position to be
  8715. * @returns the position
  8716. */
  8717. getFrontPosition(distance: number): Vector3;
  8718. /** @hidden */
  8719. _getLockedTargetPosition(): Nullable<Vector3>;
  8720. private _storedPosition;
  8721. private _storedRotation;
  8722. private _storedRotationQuaternion;
  8723. /**
  8724. * Store current camera state of the camera (fov, position, rotation, etc..)
  8725. * @returns the camera
  8726. */
  8727. storeState(): Camera;
  8728. /**
  8729. * Restored camera state. You must call storeState() first
  8730. * @returns whether it was successful or not
  8731. * @hidden
  8732. */
  8733. _restoreStateValues(): boolean;
  8734. /** @hidden */
  8735. _initCache(): void;
  8736. /** @hidden */
  8737. _updateCache(ignoreParentClass?: boolean): void;
  8738. /** @hidden */
  8739. _isSynchronizedViewMatrix(): boolean;
  8740. /** @hidden */
  8741. _computeLocalCameraSpeed(): number;
  8742. /**
  8743. * Defines the target the camera should look at.
  8744. * This will automatically adapt alpha beta and radius to fit within the new target.
  8745. * @param target Defines the new target as a Vector or a mesh
  8746. */
  8747. setTarget(target: Vector3): void;
  8748. /**
  8749. * Return the current target position of the camera. This value is expressed in local space.
  8750. * @returns the target position
  8751. */
  8752. getTarget(): Vector3;
  8753. /** @hidden */
  8754. _decideIfNeedsToMove(): boolean;
  8755. /** @hidden */
  8756. _updatePosition(): void;
  8757. /** @hidden */
  8758. _checkInputs(): void;
  8759. protected _updateCameraRotationMatrix(): void;
  8760. /**
  8761. * 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)
  8762. * @returns the current camera
  8763. */
  8764. private _rotateUpVectorWithCameraRotationMatrix;
  8765. private _cachedRotationZ;
  8766. private _cachedQuaternionRotationZ;
  8767. /** @hidden */
  8768. _getViewMatrix(): Matrix;
  8769. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8770. /**
  8771. * @hidden
  8772. */
  8773. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8774. /**
  8775. * @hidden
  8776. */
  8777. _updateRigCameras(): void;
  8778. private _getRigCamPositionAndTarget;
  8779. /**
  8780. * Gets the current object class name.
  8781. * @return the class name
  8782. */
  8783. getClassName(): string;
  8784. }
  8785. }
  8786. declare module BABYLON {
  8787. /**
  8788. * @ignore
  8789. * This is a list of all the different input types that are available in the application.
  8790. * Fo instance: ArcRotateCameraGamepadInput...
  8791. */
  8792. export var CameraInputTypes: {};
  8793. /**
  8794. * This is the contract to implement in order to create a new input class.
  8795. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8796. */
  8797. export interface ICameraInput<TCamera extends Camera> {
  8798. /**
  8799. * Defines the camera the input is attached to.
  8800. */
  8801. camera: Nullable<TCamera>;
  8802. /**
  8803. * Gets the class name of the current intput.
  8804. * @returns the class name
  8805. */
  8806. getClassName(): string;
  8807. /**
  8808. * Get the friendly name associated with the input class.
  8809. * @returns the input friendly name
  8810. */
  8811. getSimpleName(): string;
  8812. /**
  8813. * Attach the input controls to a specific dom element to get the input from.
  8814. * @param element Defines the element the controls should be listened from
  8815. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8816. */
  8817. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8818. /**
  8819. * Detach the current controls from the specified dom element.
  8820. * @param element Defines the element to stop listening the inputs from
  8821. */
  8822. detachControl(element: Nullable<HTMLElement>): void;
  8823. /**
  8824. * Update the current camera state depending on the inputs that have been used this frame.
  8825. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8826. */
  8827. checkInputs?: () => void;
  8828. }
  8829. /**
  8830. * Represents a map of input types to input instance or input index to input instance.
  8831. */
  8832. export interface CameraInputsMap<TCamera extends Camera> {
  8833. /**
  8834. * Accessor to the input by input type.
  8835. */
  8836. [name: string]: ICameraInput<TCamera>;
  8837. /**
  8838. * Accessor to the input by input index.
  8839. */
  8840. [idx: number]: ICameraInput<TCamera>;
  8841. }
  8842. /**
  8843. * This represents the input manager used within a camera.
  8844. * It helps dealing with all the different kind of input attached to a camera.
  8845. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8846. */
  8847. export class CameraInputsManager<TCamera extends Camera> {
  8848. /**
  8849. * Defines the list of inputs attahed to the camera.
  8850. */
  8851. attached: CameraInputsMap<TCamera>;
  8852. /**
  8853. * Defines the dom element the camera is collecting inputs from.
  8854. * This is null if the controls have not been attached.
  8855. */
  8856. attachedElement: Nullable<HTMLElement>;
  8857. /**
  8858. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8859. */
  8860. noPreventDefault: boolean;
  8861. /**
  8862. * Defined the camera the input manager belongs to.
  8863. */
  8864. camera: TCamera;
  8865. /**
  8866. * Update the current camera state depending on the inputs that have been used this frame.
  8867. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8868. */
  8869. checkInputs: () => void;
  8870. /**
  8871. * Instantiate a new Camera Input Manager.
  8872. * @param camera Defines the camera the input manager blongs to
  8873. */
  8874. constructor(camera: TCamera);
  8875. /**
  8876. * Add an input method to a camera
  8877. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8878. * @param input camera input method
  8879. */
  8880. add(input: ICameraInput<TCamera>): void;
  8881. /**
  8882. * Remove a specific input method from a camera
  8883. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8884. * @param inputToRemove camera input method
  8885. */
  8886. remove(inputToRemove: ICameraInput<TCamera>): void;
  8887. /**
  8888. * Remove a specific input type from a camera
  8889. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8890. * @param inputType the type of the input to remove
  8891. */
  8892. removeByType(inputType: string): void;
  8893. private _addCheckInputs;
  8894. /**
  8895. * Attach the input controls to the currently attached dom element to listen the events from.
  8896. * @param input Defines the input to attach
  8897. */
  8898. attachInput(input: ICameraInput<TCamera>): void;
  8899. /**
  8900. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8901. * @param element Defines the dom element to collect the events from
  8902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8903. */
  8904. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8905. /**
  8906. * Detach the current manager inputs controls from a specific dom element.
  8907. * @param element Defines the dom element to collect the events from
  8908. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8909. */
  8910. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8911. /**
  8912. * Rebuild the dynamic inputCheck function from the current list of
  8913. * defined inputs in the manager.
  8914. */
  8915. rebuildInputCheck(): void;
  8916. /**
  8917. * Remove all attached input methods from a camera
  8918. */
  8919. clear(): void;
  8920. /**
  8921. * Serialize the current input manager attached to a camera.
  8922. * This ensures than once parsed,
  8923. * the input associated to the camera will be identical to the current ones
  8924. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8925. */
  8926. serialize(serializedCamera: any): void;
  8927. /**
  8928. * Parses an input manager serialized JSON to restore the previous list of inputs
  8929. * and states associated to a camera.
  8930. * @param parsedCamera Defines the JSON to parse
  8931. */
  8932. parse(parsedCamera: any): void;
  8933. }
  8934. }
  8935. declare module BABYLON {
  8936. /**
  8937. * Gather the list of keyboard event types as constants.
  8938. */
  8939. export class KeyboardEventTypes {
  8940. /**
  8941. * The keydown event is fired when a key becomes active (pressed).
  8942. */
  8943. static readonly KEYDOWN: number;
  8944. /**
  8945. * The keyup event is fired when a key has been released.
  8946. */
  8947. static readonly KEYUP: number;
  8948. }
  8949. /**
  8950. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8951. */
  8952. export class KeyboardInfo {
  8953. /**
  8954. * Defines the type of event (KeyboardEventTypes)
  8955. */
  8956. type: number;
  8957. /**
  8958. * Defines the related dom event
  8959. */
  8960. event: KeyboardEvent;
  8961. /**
  8962. * Instantiates a new keyboard info.
  8963. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8964. * @param type Defines the type of event (KeyboardEventTypes)
  8965. * @param event Defines the related dom event
  8966. */
  8967. constructor(
  8968. /**
  8969. * Defines the type of event (KeyboardEventTypes)
  8970. */
  8971. type: number,
  8972. /**
  8973. * Defines the related dom event
  8974. */
  8975. event: KeyboardEvent);
  8976. }
  8977. /**
  8978. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8979. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8980. */
  8981. export class KeyboardInfoPre extends KeyboardInfo {
  8982. /**
  8983. * Defines the type of event (KeyboardEventTypes)
  8984. */
  8985. type: number;
  8986. /**
  8987. * Defines the related dom event
  8988. */
  8989. event: KeyboardEvent;
  8990. /**
  8991. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8992. */
  8993. skipOnPointerObservable: boolean;
  8994. /**
  8995. * Instantiates a new keyboard pre info.
  8996. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8997. * @param type Defines the type of event (KeyboardEventTypes)
  8998. * @param event Defines the related dom event
  8999. */
  9000. constructor(
  9001. /**
  9002. * Defines the type of event (KeyboardEventTypes)
  9003. */
  9004. type: number,
  9005. /**
  9006. * Defines the related dom event
  9007. */
  9008. event: KeyboardEvent);
  9009. }
  9010. }
  9011. declare module BABYLON {
  9012. /**
  9013. * Manage the keyboard inputs to control the movement of a free camera.
  9014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9015. */
  9016. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9017. /**
  9018. * Defines the camera the input is attached to.
  9019. */
  9020. camera: FreeCamera;
  9021. /**
  9022. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9023. */
  9024. keysUp: number[];
  9025. /**
  9026. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9027. */
  9028. keysDown: number[];
  9029. /**
  9030. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9031. */
  9032. keysLeft: number[];
  9033. /**
  9034. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9035. */
  9036. keysRight: number[];
  9037. private _keys;
  9038. private _onCanvasBlurObserver;
  9039. private _onKeyboardObserver;
  9040. private _engine;
  9041. private _scene;
  9042. /**
  9043. * Attach the input controls to a specific dom element to get the input from.
  9044. * @param element Defines the element the controls should be listened from
  9045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9046. */
  9047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9048. /**
  9049. * Detach the current controls from the specified dom element.
  9050. * @param element Defines the element to stop listening the inputs from
  9051. */
  9052. detachControl(element: Nullable<HTMLElement>): void;
  9053. /**
  9054. * Update the current camera state depending on the inputs that have been used this frame.
  9055. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9056. */
  9057. checkInputs(): void;
  9058. /**
  9059. * Gets the class name of the current intput.
  9060. * @returns the class name
  9061. */
  9062. getClassName(): string;
  9063. /** @hidden */
  9064. _onLostFocus(): void;
  9065. /**
  9066. * Get the friendly name associated with the input class.
  9067. * @returns the input friendly name
  9068. */
  9069. getSimpleName(): string;
  9070. }
  9071. }
  9072. declare module BABYLON {
  9073. /**
  9074. * Interface describing all the common properties and methods a shadow light needs to implement.
  9075. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9076. * as well as binding the different shadow properties to the effects.
  9077. */
  9078. export interface IShadowLight extends Light {
  9079. /**
  9080. * The light id in the scene (used in scene.findLighById for instance)
  9081. */
  9082. id: string;
  9083. /**
  9084. * The position the shdow will be casted from.
  9085. */
  9086. position: Vector3;
  9087. /**
  9088. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9089. */
  9090. direction: Vector3;
  9091. /**
  9092. * The transformed position. Position of the light in world space taking parenting in account.
  9093. */
  9094. transformedPosition: Vector3;
  9095. /**
  9096. * The transformed direction. Direction of the light in world space taking parenting in account.
  9097. */
  9098. transformedDirection: Vector3;
  9099. /**
  9100. * The friendly name of the light in the scene.
  9101. */
  9102. name: string;
  9103. /**
  9104. * Defines the shadow projection clipping minimum z value.
  9105. */
  9106. shadowMinZ: number;
  9107. /**
  9108. * Defines the shadow projection clipping maximum z value.
  9109. */
  9110. shadowMaxZ: number;
  9111. /**
  9112. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9113. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9114. */
  9115. computeTransformedInformation(): boolean;
  9116. /**
  9117. * Gets the scene the light belongs to.
  9118. * @returns The scene
  9119. */
  9120. getScene(): Scene;
  9121. /**
  9122. * Callback defining a custom Projection Matrix Builder.
  9123. * This can be used to override the default projection matrix computation.
  9124. */
  9125. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9126. /**
  9127. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9128. * @param matrix The materix to updated with the projection information
  9129. * @param viewMatrix The transform matrix of the light
  9130. * @param renderList The list of mesh to render in the map
  9131. * @returns The current light
  9132. */
  9133. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9134. /**
  9135. * Gets the current depth scale used in ESM.
  9136. * @returns The scale
  9137. */
  9138. getDepthScale(): number;
  9139. /**
  9140. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9141. * @returns true if a cube texture needs to be use
  9142. */
  9143. needCube(): boolean;
  9144. /**
  9145. * Detects if the projection matrix requires to be recomputed this frame.
  9146. * @returns true if it requires to be recomputed otherwise, false.
  9147. */
  9148. needProjectionMatrixCompute(): boolean;
  9149. /**
  9150. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9151. */
  9152. forceProjectionMatrixCompute(): void;
  9153. /**
  9154. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9155. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9156. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9157. */
  9158. getShadowDirection(faceIndex?: number): Vector3;
  9159. /**
  9160. * Gets the minZ used for shadow according to both the scene and the light.
  9161. * @param activeCamera The camera we are returning the min for
  9162. * @returns the depth min z
  9163. */
  9164. getDepthMinZ(activeCamera: Camera): number;
  9165. /**
  9166. * Gets the maxZ used for shadow according to both the scene and the light.
  9167. * @param activeCamera The camera we are returning the max for
  9168. * @returns the depth max z
  9169. */
  9170. getDepthMaxZ(activeCamera: Camera): number;
  9171. }
  9172. /**
  9173. * Base implementation IShadowLight
  9174. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9175. */
  9176. export abstract class ShadowLight extends Light implements IShadowLight {
  9177. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9178. protected _position: Vector3;
  9179. protected _setPosition(value: Vector3): void;
  9180. /**
  9181. * Sets the position the shadow will be casted from. Also use as the light position for both
  9182. * point and spot lights.
  9183. */
  9184. /**
  9185. * Sets the position the shadow will be casted from. Also use as the light position for both
  9186. * point and spot lights.
  9187. */
  9188. position: Vector3;
  9189. protected _direction: Vector3;
  9190. protected _setDirection(value: Vector3): void;
  9191. /**
  9192. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9193. * Also use as the light direction on spot and directional lights.
  9194. */
  9195. /**
  9196. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9197. * Also use as the light direction on spot and directional lights.
  9198. */
  9199. direction: Vector3;
  9200. private _shadowMinZ;
  9201. /**
  9202. * Gets the shadow projection clipping minimum z value.
  9203. */
  9204. /**
  9205. * Sets the shadow projection clipping minimum z value.
  9206. */
  9207. shadowMinZ: number;
  9208. private _shadowMaxZ;
  9209. /**
  9210. * Sets the shadow projection clipping maximum z value.
  9211. */
  9212. /**
  9213. * Gets the shadow projection clipping maximum z value.
  9214. */
  9215. shadowMaxZ: number;
  9216. /**
  9217. * Callback defining a custom Projection Matrix Builder.
  9218. * This can be used to override the default projection matrix computation.
  9219. */
  9220. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9221. /**
  9222. * The transformed position. Position of the light in world space taking parenting in account.
  9223. */
  9224. transformedPosition: Vector3;
  9225. /**
  9226. * The transformed direction. Direction of the light in world space taking parenting in account.
  9227. */
  9228. transformedDirection: Vector3;
  9229. private _needProjectionMatrixCompute;
  9230. /**
  9231. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9232. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9233. */
  9234. computeTransformedInformation(): boolean;
  9235. /**
  9236. * Return the depth scale used for the shadow map.
  9237. * @returns the depth scale.
  9238. */
  9239. getDepthScale(): number;
  9240. /**
  9241. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9242. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9243. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9244. */
  9245. getShadowDirection(faceIndex?: number): Vector3;
  9246. /**
  9247. * Returns the ShadowLight absolute position in the World.
  9248. * @returns the position vector in world space
  9249. */
  9250. getAbsolutePosition(): Vector3;
  9251. /**
  9252. * Sets the ShadowLight direction toward the passed target.
  9253. * @param target The point to target in local space
  9254. * @returns the updated ShadowLight direction
  9255. */
  9256. setDirectionToTarget(target: Vector3): Vector3;
  9257. /**
  9258. * Returns the light rotation in euler definition.
  9259. * @returns the x y z rotation in local space.
  9260. */
  9261. getRotation(): Vector3;
  9262. /**
  9263. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9264. * @returns true if a cube texture needs to be use
  9265. */
  9266. needCube(): boolean;
  9267. /**
  9268. * Detects if the projection matrix requires to be recomputed this frame.
  9269. * @returns true if it requires to be recomputed otherwise, false.
  9270. */
  9271. needProjectionMatrixCompute(): boolean;
  9272. /**
  9273. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9274. */
  9275. forceProjectionMatrixCompute(): void;
  9276. /** @hidden */
  9277. _initCache(): void;
  9278. /** @hidden */
  9279. _isSynchronized(): boolean;
  9280. /**
  9281. * Computes the world matrix of the node
  9282. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9283. * @returns the world matrix
  9284. */
  9285. computeWorldMatrix(force?: boolean): Matrix;
  9286. /**
  9287. * Gets the minZ used for shadow according to both the scene and the light.
  9288. * @param activeCamera The camera we are returning the min for
  9289. * @returns the depth min z
  9290. */
  9291. getDepthMinZ(activeCamera: Camera): number;
  9292. /**
  9293. * Gets the maxZ used for shadow according to both the scene and the light.
  9294. * @param activeCamera The camera we are returning the max for
  9295. * @returns the depth max z
  9296. */
  9297. getDepthMaxZ(activeCamera: Camera): number;
  9298. /**
  9299. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9300. * @param matrix The materix to updated with the projection information
  9301. * @param viewMatrix The transform matrix of the light
  9302. * @param renderList The list of mesh to render in the map
  9303. * @returns The current light
  9304. */
  9305. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9306. }
  9307. }
  9308. declare module BABYLON {
  9309. /**
  9310. * "Static Class" containing the most commonly used helper while dealing with material for
  9311. * rendering purpose.
  9312. *
  9313. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9314. *
  9315. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9316. */
  9317. export class MaterialHelper {
  9318. /**
  9319. * Bind the current view position to an effect.
  9320. * @param effect The effect to be bound
  9321. * @param scene The scene the eyes position is used from
  9322. */
  9323. static BindEyePosition(effect: Effect, scene: Scene): void;
  9324. /**
  9325. * Helps preparing the defines values about the UVs in used in the effect.
  9326. * UVs are shared as much as we can accross channels in the shaders.
  9327. * @param texture The texture we are preparing the UVs for
  9328. * @param defines The defines to update
  9329. * @param key The channel key "diffuse", "specular"... used in the shader
  9330. */
  9331. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9332. /**
  9333. * Binds a texture matrix value to its corrsponding uniform
  9334. * @param texture The texture to bind the matrix for
  9335. * @param uniformBuffer The uniform buffer receivin the data
  9336. * @param key The channel key "diffuse", "specular"... used in the shader
  9337. */
  9338. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9339. /**
  9340. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9341. * @param mesh defines the current mesh
  9342. * @param scene defines the current scene
  9343. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9344. * @param pointsCloud defines if point cloud rendering has to be turned on
  9345. * @param fogEnabled defines if fog has to be turned on
  9346. * @param alphaTest defines if alpha testing has to be turned on
  9347. * @param defines defines the current list of defines
  9348. */
  9349. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9350. /**
  9351. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9352. * @param scene defines the current scene
  9353. * @param engine defines the current engine
  9354. * @param defines specifies the list of active defines
  9355. * @param useInstances defines if instances have to be turned on
  9356. * @param useClipPlane defines if clip plane have to be turned on
  9357. */
  9358. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9359. /**
  9360. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9361. * @param mesh The mesh containing the geometry data we will draw
  9362. * @param defines The defines to update
  9363. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9364. * @param useBones Precise whether bones should be used or not (override mesh info)
  9365. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9366. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9367. * @returns false if defines are considered not dirty and have not been checked
  9368. */
  9369. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9370. /**
  9371. * Prepares the defines related to multiview
  9372. * @param scene The scene we are intending to draw
  9373. * @param defines The defines to update
  9374. */
  9375. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9376. /**
  9377. * Prepares the defines related to the light information passed in parameter
  9378. * @param scene The scene we are intending to draw
  9379. * @param mesh The mesh the effect is compiling for
  9380. * @param defines The defines to update
  9381. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9382. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9383. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9384. * @returns true if normals will be required for the rest of the effect
  9385. */
  9386. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9387. /**
  9388. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9389. * that won t be acctive due to defines being turned off.
  9390. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9391. * @param samplersList The samplers list
  9392. * @param defines The defines helping in the list generation
  9393. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9394. */
  9395. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9396. /**
  9397. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9398. * @param defines The defines to update while falling back
  9399. * @param fallbacks The authorized effect fallbacks
  9400. * @param maxSimultaneousLights The maximum number of lights allowed
  9401. * @param rank the current rank of the Effect
  9402. * @returns The newly affected rank
  9403. */
  9404. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9405. /**
  9406. * Prepares the list of attributes required for morph targets according to the effect defines.
  9407. * @param attribs The current list of supported attribs
  9408. * @param mesh The mesh to prepare the morph targets attributes for
  9409. * @param defines The current Defines of the effect
  9410. */
  9411. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9412. /**
  9413. * Prepares the list of attributes required for bones according to the effect defines.
  9414. * @param attribs The current list of supported attribs
  9415. * @param mesh The mesh to prepare the bones attributes for
  9416. * @param defines The current Defines of the effect
  9417. * @param fallbacks The current efffect fallback strategy
  9418. */
  9419. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9420. /**
  9421. * Prepares the list of attributes required for instances according to the effect defines.
  9422. * @param attribs The current list of supported attribs
  9423. * @param defines The current Defines of the effect
  9424. */
  9425. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9426. /**
  9427. * Binds the light shadow information to the effect for the given mesh.
  9428. * @param light The light containing the generator
  9429. * @param scene The scene the lights belongs to
  9430. * @param mesh The mesh we are binding the information to render
  9431. * @param lightIndex The light index in the effect used to render the mesh
  9432. * @param effect The effect we are binding the data to
  9433. */
  9434. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9435. /**
  9436. * Binds the light information to the effect.
  9437. * @param light The light containing the generator
  9438. * @param effect The effect we are binding the data to
  9439. * @param lightIndex The light index in the effect used to render
  9440. */
  9441. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9442. /**
  9443. * Binds the lights information from the scene to the effect for the given mesh.
  9444. * @param scene The scene the lights belongs to
  9445. * @param mesh The mesh we are binding the information to render
  9446. * @param effect The effect we are binding the data to
  9447. * @param defines The generated defines for the effect
  9448. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9449. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9450. */
  9451. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9452. private static _tempFogColor;
  9453. /**
  9454. * Binds the fog information from the scene to the effect for the given mesh.
  9455. * @param scene The scene the lights belongs to
  9456. * @param mesh The mesh we are binding the information to render
  9457. * @param effect The effect we are binding the data to
  9458. * @param linearSpace Defines if the fog effect is applied in linear space
  9459. */
  9460. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9461. /**
  9462. * Binds the bones information from the mesh to the effect.
  9463. * @param mesh The mesh we are binding the information to render
  9464. * @param effect The effect we are binding the data to
  9465. */
  9466. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9467. /**
  9468. * Binds the morph targets information from the mesh to the effect.
  9469. * @param abstractMesh The mesh we are binding the information to render
  9470. * @param effect The effect we are binding the data to
  9471. */
  9472. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9473. /**
  9474. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9475. * @param defines The generated defines used in the effect
  9476. * @param effect The effect we are binding the data to
  9477. * @param scene The scene we are willing to render with logarithmic scale for
  9478. */
  9479. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9480. /**
  9481. * Binds the clip plane information from the scene to the effect.
  9482. * @param scene The scene the clip plane information are extracted from
  9483. * @param effect The effect we are binding the data to
  9484. */
  9485. static BindClipPlane(effect: Effect, scene: Scene): void;
  9486. }
  9487. }
  9488. declare module BABYLON {
  9489. /** @hidden */
  9490. export var kernelBlurVaryingDeclaration: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module BABYLON {
  9496. /** @hidden */
  9497. export var kernelBlurFragment: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module BABYLON {
  9503. /** @hidden */
  9504. export var kernelBlurFragment2: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module BABYLON {
  9510. /** @hidden */
  9511. export var kernelBlurPixelShader: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module BABYLON {
  9517. /** @hidden */
  9518. export var kernelBlurVertex: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module BABYLON {
  9524. /** @hidden */
  9525. export var kernelBlurVertexShader: {
  9526. name: string;
  9527. shader: string;
  9528. };
  9529. }
  9530. declare module BABYLON {
  9531. /**
  9532. * The Blur Post Process which blurs an image based on a kernel and direction.
  9533. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9534. */
  9535. export class BlurPostProcess extends PostProcess {
  9536. /** The direction in which to blur the image. */
  9537. direction: Vector2;
  9538. private blockCompilation;
  9539. protected _kernel: number;
  9540. protected _idealKernel: number;
  9541. protected _packedFloat: boolean;
  9542. private _staticDefines;
  9543. /**
  9544. * Sets the length in pixels of the blur sample region
  9545. */
  9546. /**
  9547. * Gets the length in pixels of the blur sample region
  9548. */
  9549. kernel: number;
  9550. /**
  9551. * Sets wether or not the blur needs to unpack/repack floats
  9552. */
  9553. /**
  9554. * Gets wether or not the blur is unpacking/repacking floats
  9555. */
  9556. packedFloat: boolean;
  9557. /**
  9558. * Creates a new instance BlurPostProcess
  9559. * @param name The name of the effect.
  9560. * @param direction The direction in which to blur the image.
  9561. * @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.
  9562. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9563. * @param camera The camera to apply the render pass to.
  9564. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9565. * @param engine The engine which the post process will be applied. (default: current engine)
  9566. * @param reusable If the post process can be reused on the same frame. (default: false)
  9567. * @param textureType Type of textures used when performing the post process. (default: 0)
  9568. * @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)
  9569. */
  9570. constructor(name: string,
  9571. /** The direction in which to blur the image. */
  9572. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9573. /**
  9574. * Updates the effect with the current post process compile time values and recompiles the shader.
  9575. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9576. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9577. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9578. * @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
  9579. * @param onCompiled Called when the shader has been compiled.
  9580. * @param onError Called if there is an error when compiling a shader.
  9581. */
  9582. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9583. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9584. /**
  9585. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9586. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9587. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9588. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9589. * The gaps between physical kernels are compensated for in the weighting of the samples
  9590. * @param idealKernel Ideal blur kernel.
  9591. * @return Nearest best kernel.
  9592. */
  9593. protected _nearestBestKernel(idealKernel: number): number;
  9594. /**
  9595. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9596. * @param x The point on the Gaussian distribution to sample.
  9597. * @return the value of the Gaussian function at x.
  9598. */
  9599. protected _gaussianWeight(x: number): number;
  9600. /**
  9601. * Generates a string that can be used as a floating point number in GLSL.
  9602. * @param x Value to print.
  9603. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9604. * @return GLSL float string.
  9605. */
  9606. protected _glslFloat(x: number, decimalFigures?: number): string;
  9607. }
  9608. }
  9609. declare module BABYLON {
  9610. /** @hidden */
  9611. export var shadowMapPixelShader: {
  9612. name: string;
  9613. shader: string;
  9614. };
  9615. }
  9616. declare module BABYLON {
  9617. /** @hidden */
  9618. export var bonesDeclaration: {
  9619. name: string;
  9620. shader: string;
  9621. };
  9622. }
  9623. declare module BABYLON {
  9624. /** @hidden */
  9625. export var morphTargetsVertexGlobalDeclaration: {
  9626. name: string;
  9627. shader: string;
  9628. };
  9629. }
  9630. declare module BABYLON {
  9631. /** @hidden */
  9632. export var morphTargetsVertexDeclaration: {
  9633. name: string;
  9634. shader: string;
  9635. };
  9636. }
  9637. declare module BABYLON {
  9638. /** @hidden */
  9639. export var instancesDeclaration: {
  9640. name: string;
  9641. shader: string;
  9642. };
  9643. }
  9644. declare module BABYLON {
  9645. /** @hidden */
  9646. export var helperFunctions: {
  9647. name: string;
  9648. shader: string;
  9649. };
  9650. }
  9651. declare module BABYLON {
  9652. /** @hidden */
  9653. export var morphTargetsVertex: {
  9654. name: string;
  9655. shader: string;
  9656. };
  9657. }
  9658. declare module BABYLON {
  9659. /** @hidden */
  9660. export var instancesVertex: {
  9661. name: string;
  9662. shader: string;
  9663. };
  9664. }
  9665. declare module BABYLON {
  9666. /** @hidden */
  9667. export var bonesVertex: {
  9668. name: string;
  9669. shader: string;
  9670. };
  9671. }
  9672. declare module BABYLON {
  9673. /** @hidden */
  9674. export var shadowMapVertexShader: {
  9675. name: string;
  9676. shader: string;
  9677. };
  9678. }
  9679. declare module BABYLON {
  9680. /** @hidden */
  9681. export var depthBoxBlurPixelShader: {
  9682. name: string;
  9683. shader: string;
  9684. };
  9685. }
  9686. declare module BABYLON {
  9687. /**
  9688. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9689. */
  9690. export interface ICustomShaderOptions {
  9691. /**
  9692. * Gets or sets the custom shader name to use
  9693. */
  9694. shaderName: string;
  9695. /**
  9696. * The list of attribute names used in the shader
  9697. */
  9698. attributes?: string[];
  9699. /**
  9700. * The list of unifrom names used in the shader
  9701. */
  9702. uniforms?: string[];
  9703. /**
  9704. * The list of sampler names used in the shader
  9705. */
  9706. samplers?: string[];
  9707. /**
  9708. * The list of defines used in the shader
  9709. */
  9710. defines?: string[];
  9711. }
  9712. /**
  9713. * Interface to implement to create a shadow generator compatible with BJS.
  9714. */
  9715. export interface IShadowGenerator {
  9716. /**
  9717. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9718. * @returns The render target texture if present otherwise, null
  9719. */
  9720. getShadowMap(): Nullable<RenderTargetTexture>;
  9721. /**
  9722. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9723. * @returns The render target texture if the shadow map is present otherwise, null
  9724. */
  9725. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9726. /**
  9727. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9728. * @param subMesh The submesh we want to render in the shadow map
  9729. * @param useInstances Defines wether will draw in the map using instances
  9730. * @returns true if ready otherwise, false
  9731. */
  9732. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9733. /**
  9734. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9735. * @param defines Defines of the material we want to update
  9736. * @param lightIndex Index of the light in the enabled light list of the material
  9737. */
  9738. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9739. /**
  9740. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9741. * defined in the generator but impacting the effect).
  9742. * It implies the unifroms available on the materials are the standard BJS ones.
  9743. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9744. * @param effect The effect we are binfing the information for
  9745. */
  9746. bindShadowLight(lightIndex: string, effect: Effect): void;
  9747. /**
  9748. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9749. * (eq to shadow prjection matrix * light transform matrix)
  9750. * @returns The transform matrix used to create the shadow map
  9751. */
  9752. getTransformMatrix(): Matrix;
  9753. /**
  9754. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9755. * Cube and 2D textures for instance.
  9756. */
  9757. recreateShadowMap(): void;
  9758. /**
  9759. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9760. * @param onCompiled Callback triggered at the and of the effects compilation
  9761. * @param options Sets of optional options forcing the compilation with different modes
  9762. */
  9763. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9764. useInstances: boolean;
  9765. }>): void;
  9766. /**
  9767. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9768. * @param options Sets of optional options forcing the compilation with different modes
  9769. * @returns A promise that resolves when the compilation completes
  9770. */
  9771. forceCompilationAsync(options?: Partial<{
  9772. useInstances: boolean;
  9773. }>): Promise<void>;
  9774. /**
  9775. * Serializes the shadow generator setup to a json object.
  9776. * @returns The serialized JSON object
  9777. */
  9778. serialize(): any;
  9779. /**
  9780. * Disposes the Shadow map and related Textures and effects.
  9781. */
  9782. dispose(): void;
  9783. }
  9784. /**
  9785. * Default implementation IShadowGenerator.
  9786. * This is the main object responsible of generating shadows in the framework.
  9787. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9788. */
  9789. export class ShadowGenerator implements IShadowGenerator {
  9790. /**
  9791. * Shadow generator mode None: no filtering applied.
  9792. */
  9793. static readonly FILTER_NONE: number;
  9794. /**
  9795. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9796. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9797. */
  9798. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9799. /**
  9800. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9801. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9802. */
  9803. static readonly FILTER_POISSONSAMPLING: number;
  9804. /**
  9805. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9806. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9807. */
  9808. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9809. /**
  9810. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9811. * edge artifacts on steep falloff.
  9812. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9813. */
  9814. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9815. /**
  9816. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9817. * edge artifacts on steep falloff.
  9818. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9819. */
  9820. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9821. /**
  9822. * Shadow generator mode PCF: Percentage Closer Filtering
  9823. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9824. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9825. */
  9826. static readonly FILTER_PCF: number;
  9827. /**
  9828. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9829. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9830. * Contact Hardening
  9831. */
  9832. static readonly FILTER_PCSS: number;
  9833. /**
  9834. * Reserved for PCF and PCSS
  9835. * Highest Quality.
  9836. *
  9837. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9838. *
  9839. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9840. */
  9841. static readonly QUALITY_HIGH: number;
  9842. /**
  9843. * Reserved for PCF and PCSS
  9844. * Good tradeoff for quality/perf cross devices
  9845. *
  9846. * Execute PCF on a 3*3 kernel.
  9847. *
  9848. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9849. */
  9850. static readonly QUALITY_MEDIUM: number;
  9851. /**
  9852. * Reserved for PCF and PCSS
  9853. * The lowest quality but the fastest.
  9854. *
  9855. * Execute PCF on a 1*1 kernel.
  9856. *
  9857. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9858. */
  9859. static readonly QUALITY_LOW: number;
  9860. /** Gets or sets the custom shader name to use */
  9861. customShaderOptions: ICustomShaderOptions;
  9862. /**
  9863. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9864. */
  9865. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9866. /**
  9867. * Observable triggered before a mesh is rendered in the shadow map.
  9868. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9869. */
  9870. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9871. private _bias;
  9872. /**
  9873. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9874. */
  9875. /**
  9876. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9877. */
  9878. bias: number;
  9879. private _normalBias;
  9880. /**
  9881. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9882. */
  9883. /**
  9884. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9885. */
  9886. normalBias: number;
  9887. private _blurBoxOffset;
  9888. /**
  9889. * Gets the blur box offset: offset applied during the blur pass.
  9890. * Only useful if useKernelBlur = false
  9891. */
  9892. /**
  9893. * Sets the blur box offset: offset applied during the blur pass.
  9894. * Only useful if useKernelBlur = false
  9895. */
  9896. blurBoxOffset: number;
  9897. private _blurScale;
  9898. /**
  9899. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9900. * 2 means half of the size.
  9901. */
  9902. /**
  9903. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9904. * 2 means half of the size.
  9905. */
  9906. blurScale: number;
  9907. private _blurKernel;
  9908. /**
  9909. * Gets the blur kernel: kernel size of the blur pass.
  9910. * Only useful if useKernelBlur = true
  9911. */
  9912. /**
  9913. * Sets the blur kernel: kernel size of the blur pass.
  9914. * Only useful if useKernelBlur = true
  9915. */
  9916. blurKernel: number;
  9917. private _useKernelBlur;
  9918. /**
  9919. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9920. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9921. */
  9922. /**
  9923. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9924. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9925. */
  9926. useKernelBlur: boolean;
  9927. private _depthScale;
  9928. /**
  9929. * Gets the depth scale used in ESM mode.
  9930. */
  9931. /**
  9932. * Sets the depth scale used in ESM mode.
  9933. * This can override the scale stored on the light.
  9934. */
  9935. depthScale: number;
  9936. private _filter;
  9937. /**
  9938. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9939. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9940. */
  9941. /**
  9942. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9943. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9944. */
  9945. filter: number;
  9946. /**
  9947. * Gets if the current filter is set to Poisson Sampling.
  9948. */
  9949. /**
  9950. * Sets the current filter to Poisson Sampling.
  9951. */
  9952. usePoissonSampling: boolean;
  9953. /**
  9954. * Gets if the current filter is set to ESM.
  9955. */
  9956. /**
  9957. * Sets the current filter is to ESM.
  9958. */
  9959. useExponentialShadowMap: boolean;
  9960. /**
  9961. * Gets if the current filter is set to filtered ESM.
  9962. */
  9963. /**
  9964. * Gets if the current filter is set to filtered ESM.
  9965. */
  9966. useBlurExponentialShadowMap: boolean;
  9967. /**
  9968. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9969. * exponential to prevent steep falloff artifacts).
  9970. */
  9971. /**
  9972. * Sets the current filter to "close ESM" (using the inverse of the
  9973. * exponential to prevent steep falloff artifacts).
  9974. */
  9975. useCloseExponentialShadowMap: boolean;
  9976. /**
  9977. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9978. * exponential to prevent steep falloff artifacts).
  9979. */
  9980. /**
  9981. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9982. * exponential to prevent steep falloff artifacts).
  9983. */
  9984. useBlurCloseExponentialShadowMap: boolean;
  9985. /**
  9986. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9987. */
  9988. /**
  9989. * Sets the current filter to "PCF" (percentage closer filtering).
  9990. */
  9991. usePercentageCloserFiltering: boolean;
  9992. private _filteringQuality;
  9993. /**
  9994. * Gets the PCF or PCSS Quality.
  9995. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9996. */
  9997. /**
  9998. * Sets the PCF or PCSS Quality.
  9999. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10000. */
  10001. filteringQuality: number;
  10002. /**
  10003. * Gets if the current filter is set to "PCSS" (contact hardening).
  10004. */
  10005. /**
  10006. * Sets the current filter to "PCSS" (contact hardening).
  10007. */
  10008. useContactHardeningShadow: boolean;
  10009. private _contactHardeningLightSizeUVRatio;
  10010. /**
  10011. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10012. * Using a ratio helps keeping shape stability independently of the map size.
  10013. *
  10014. * It does not account for the light projection as it was having too much
  10015. * instability during the light setup or during light position changes.
  10016. *
  10017. * Only valid if useContactHardeningShadow is true.
  10018. */
  10019. /**
  10020. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10021. * Using a ratio helps keeping shape stability independently of the map size.
  10022. *
  10023. * It does not account for the light projection as it was having too much
  10024. * instability during the light setup or during light position changes.
  10025. *
  10026. * Only valid if useContactHardeningShadow is true.
  10027. */
  10028. contactHardeningLightSizeUVRatio: number;
  10029. private _darkness;
  10030. /**
  10031. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10032. * 0 means strongest and 1 would means no shadow.
  10033. * @returns the darkness.
  10034. */
  10035. getDarkness(): number;
  10036. /**
  10037. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10038. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10039. * @returns the shadow generator allowing fluent coding.
  10040. */
  10041. setDarkness(darkness: number): ShadowGenerator;
  10042. private _transparencyShadow;
  10043. /**
  10044. * Sets the ability to have transparent shadow (boolean).
  10045. * @param transparent True if transparent else False
  10046. * @returns the shadow generator allowing fluent coding
  10047. */
  10048. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10049. private _shadowMap;
  10050. private _shadowMap2;
  10051. /**
  10052. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10053. * @returns The render target texture if present otherwise, null
  10054. */
  10055. getShadowMap(): Nullable<RenderTargetTexture>;
  10056. /**
  10057. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10058. * @returns The render target texture if the shadow map is present otherwise, null
  10059. */
  10060. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10061. /**
  10062. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10063. * @param mesh Mesh to add
  10064. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10065. * @returns the Shadow Generator itself
  10066. */
  10067. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10068. /**
  10069. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10070. * @param mesh Mesh to remove
  10071. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10072. * @returns the Shadow Generator itself
  10073. */
  10074. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10075. /**
  10076. * Controls the extent to which the shadows fade out at the edge of the frustum
  10077. * Used only by directionals and spots
  10078. */
  10079. frustumEdgeFalloff: number;
  10080. private _light;
  10081. /**
  10082. * Returns the associated light object.
  10083. * @returns the light generating the shadow
  10084. */
  10085. getLight(): IShadowLight;
  10086. /**
  10087. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10088. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10089. * It might on the other hand introduce peter panning.
  10090. */
  10091. forceBackFacesOnly: boolean;
  10092. private _scene;
  10093. private _lightDirection;
  10094. private _effect;
  10095. private _viewMatrix;
  10096. private _projectionMatrix;
  10097. private _transformMatrix;
  10098. private _cachedPosition;
  10099. private _cachedDirection;
  10100. private _cachedDefines;
  10101. private _currentRenderID;
  10102. private _boxBlurPostprocess;
  10103. private _kernelBlurXPostprocess;
  10104. private _kernelBlurYPostprocess;
  10105. private _blurPostProcesses;
  10106. private _mapSize;
  10107. private _currentFaceIndex;
  10108. private _currentFaceIndexCache;
  10109. private _textureType;
  10110. private _defaultTextureMatrix;
  10111. /** @hidden */
  10112. static _SceneComponentInitialization: (scene: Scene) => void;
  10113. /**
  10114. * Creates a ShadowGenerator object.
  10115. * A ShadowGenerator is the required tool to use the shadows.
  10116. * Each light casting shadows needs to use its own ShadowGenerator.
  10117. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10118. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10119. * @param light The light object generating the shadows.
  10120. * @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.
  10121. */
  10122. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10123. private _initializeGenerator;
  10124. private _initializeShadowMap;
  10125. private _initializeBlurRTTAndPostProcesses;
  10126. private _renderForShadowMap;
  10127. private _renderSubMeshForShadowMap;
  10128. private _applyFilterValues;
  10129. /**
  10130. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10131. * @param onCompiled Callback triggered at the and of the effects compilation
  10132. * @param options Sets of optional options forcing the compilation with different modes
  10133. */
  10134. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10135. useInstances: boolean;
  10136. }>): void;
  10137. /**
  10138. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10139. * @param options Sets of optional options forcing the compilation with different modes
  10140. * @returns A promise that resolves when the compilation completes
  10141. */
  10142. forceCompilationAsync(options?: Partial<{
  10143. useInstances: boolean;
  10144. }>): Promise<void>;
  10145. /**
  10146. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10147. * @param subMesh The submesh we want to render in the shadow map
  10148. * @param useInstances Defines wether will draw in the map using instances
  10149. * @returns true if ready otherwise, false
  10150. */
  10151. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10152. /**
  10153. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10154. * @param defines Defines of the material we want to update
  10155. * @param lightIndex Index of the light in the enabled light list of the material
  10156. */
  10157. prepareDefines(defines: any, lightIndex: number): void;
  10158. /**
  10159. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10160. * defined in the generator but impacting the effect).
  10161. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10162. * @param effect The effect we are binfing the information for
  10163. */
  10164. bindShadowLight(lightIndex: string, effect: Effect): void;
  10165. /**
  10166. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10167. * (eq to shadow prjection matrix * light transform matrix)
  10168. * @returns The transform matrix used to create the shadow map
  10169. */
  10170. getTransformMatrix(): Matrix;
  10171. /**
  10172. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10173. * Cube and 2D textures for instance.
  10174. */
  10175. recreateShadowMap(): void;
  10176. private _disposeBlurPostProcesses;
  10177. private _disposeRTTandPostProcesses;
  10178. /**
  10179. * Disposes the ShadowGenerator.
  10180. * Returns nothing.
  10181. */
  10182. dispose(): void;
  10183. /**
  10184. * Serializes the shadow generator setup to a json object.
  10185. * @returns The serialized JSON object
  10186. */
  10187. serialize(): any;
  10188. /**
  10189. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10190. * @param parsedShadowGenerator The JSON object to parse
  10191. * @param scene The scene to create the shadow map for
  10192. * @returns The parsed shadow generator
  10193. */
  10194. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10195. }
  10196. }
  10197. declare module BABYLON {
  10198. /**
  10199. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10200. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10201. * 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.
  10202. */
  10203. export abstract class Light extends Node {
  10204. /**
  10205. * Falloff Default: light is falling off following the material specification:
  10206. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10207. */
  10208. static readonly FALLOFF_DEFAULT: number;
  10209. /**
  10210. * Falloff Physical: light is falling off following the inverse squared distance law.
  10211. */
  10212. static readonly FALLOFF_PHYSICAL: number;
  10213. /**
  10214. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10215. * to enhance interoperability with other engines.
  10216. */
  10217. static readonly FALLOFF_GLTF: number;
  10218. /**
  10219. * Falloff Standard: light is falling off like in the standard material
  10220. * to enhance interoperability with other materials.
  10221. */
  10222. static readonly FALLOFF_STANDARD: number;
  10223. /**
  10224. * If every light affecting the material is in this lightmapMode,
  10225. * material.lightmapTexture adds or multiplies
  10226. * (depends on material.useLightmapAsShadowmap)
  10227. * after every other light calculations.
  10228. */
  10229. static readonly LIGHTMAP_DEFAULT: number;
  10230. /**
  10231. * material.lightmapTexture as only diffuse lighting from this light
  10232. * adds only specular lighting from this light
  10233. * adds dynamic shadows
  10234. */
  10235. static readonly LIGHTMAP_SPECULAR: number;
  10236. /**
  10237. * material.lightmapTexture as only lighting
  10238. * no light calculation from this light
  10239. * only adds dynamic shadows from this light
  10240. */
  10241. static readonly LIGHTMAP_SHADOWSONLY: number;
  10242. /**
  10243. * Each light type uses the default quantity according to its type:
  10244. * point/spot lights use luminous intensity
  10245. * directional lights use illuminance
  10246. */
  10247. static readonly INTENSITYMODE_AUTOMATIC: number;
  10248. /**
  10249. * lumen (lm)
  10250. */
  10251. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10252. /**
  10253. * candela (lm/sr)
  10254. */
  10255. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10256. /**
  10257. * lux (lm/m^2)
  10258. */
  10259. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10260. /**
  10261. * nit (cd/m^2)
  10262. */
  10263. static readonly INTENSITYMODE_LUMINANCE: number;
  10264. /**
  10265. * Light type const id of the point light.
  10266. */
  10267. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10268. /**
  10269. * Light type const id of the directional light.
  10270. */
  10271. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10272. /**
  10273. * Light type const id of the spot light.
  10274. */
  10275. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10276. /**
  10277. * Light type const id of the hemispheric light.
  10278. */
  10279. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10280. /**
  10281. * Diffuse gives the basic color to an object.
  10282. */
  10283. diffuse: Color3;
  10284. /**
  10285. * Specular produces a highlight color on an object.
  10286. * Note: This is note affecting PBR materials.
  10287. */
  10288. specular: Color3;
  10289. /**
  10290. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10291. * falling off base on range or angle.
  10292. * This can be set to any values in Light.FALLOFF_x.
  10293. *
  10294. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10295. * other types of materials.
  10296. */
  10297. falloffType: number;
  10298. /**
  10299. * Strength of the light.
  10300. * Note: By default it is define in the framework own unit.
  10301. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10302. */
  10303. intensity: number;
  10304. private _range;
  10305. protected _inverseSquaredRange: number;
  10306. /**
  10307. * Defines how far from the source the light is impacting in scene units.
  10308. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10309. */
  10310. /**
  10311. * Defines how far from the source the light is impacting in scene units.
  10312. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10313. */
  10314. range: number;
  10315. /**
  10316. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10317. * of light.
  10318. */
  10319. private _photometricScale;
  10320. private _intensityMode;
  10321. /**
  10322. * Gets the photometric scale used to interpret the intensity.
  10323. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10324. */
  10325. /**
  10326. * Sets the photometric scale used to interpret the intensity.
  10327. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10328. */
  10329. intensityMode: number;
  10330. private _radius;
  10331. /**
  10332. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10333. */
  10334. /**
  10335. * sets the light radius used by PBR Materials to simulate soft area lights.
  10336. */
  10337. radius: number;
  10338. private _renderPriority;
  10339. /**
  10340. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10341. * exceeding the number allowed of the materials.
  10342. */
  10343. renderPriority: number;
  10344. private _shadowEnabled;
  10345. /**
  10346. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10347. * the current shadow generator.
  10348. */
  10349. /**
  10350. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10351. * the current shadow generator.
  10352. */
  10353. shadowEnabled: boolean;
  10354. private _includedOnlyMeshes;
  10355. /**
  10356. * Gets the only meshes impacted by this light.
  10357. */
  10358. /**
  10359. * Sets the only meshes impacted by this light.
  10360. */
  10361. includedOnlyMeshes: AbstractMesh[];
  10362. private _excludedMeshes;
  10363. /**
  10364. * Gets the meshes not impacted by this light.
  10365. */
  10366. /**
  10367. * Sets the meshes not impacted by this light.
  10368. */
  10369. excludedMeshes: AbstractMesh[];
  10370. private _excludeWithLayerMask;
  10371. /**
  10372. * Gets the layer id use to find what meshes are not impacted by the light.
  10373. * Inactive if 0
  10374. */
  10375. /**
  10376. * Sets the layer id use to find what meshes are not impacted by the light.
  10377. * Inactive if 0
  10378. */
  10379. excludeWithLayerMask: number;
  10380. private _includeOnlyWithLayerMask;
  10381. /**
  10382. * Gets the layer id use to find what meshes are impacted by the light.
  10383. * Inactive if 0
  10384. */
  10385. /**
  10386. * Sets the layer id use to find what meshes are impacted by the light.
  10387. * Inactive if 0
  10388. */
  10389. includeOnlyWithLayerMask: number;
  10390. private _lightmapMode;
  10391. /**
  10392. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10393. */
  10394. /**
  10395. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10396. */
  10397. lightmapMode: number;
  10398. /**
  10399. * Shadow generator associted to the light.
  10400. * @hidden Internal use only.
  10401. */
  10402. _shadowGenerator: Nullable<IShadowGenerator>;
  10403. /**
  10404. * @hidden Internal use only.
  10405. */
  10406. _excludedMeshesIds: string[];
  10407. /**
  10408. * @hidden Internal use only.
  10409. */
  10410. _includedOnlyMeshesIds: string[];
  10411. /**
  10412. * The current light unifom buffer.
  10413. * @hidden Internal use only.
  10414. */
  10415. _uniformBuffer: UniformBuffer;
  10416. /**
  10417. * Creates a Light object in the scene.
  10418. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10419. * @param name The firendly name of the light
  10420. * @param scene The scene the light belongs too
  10421. */
  10422. constructor(name: string, scene: Scene);
  10423. protected abstract _buildUniformLayout(): void;
  10424. /**
  10425. * Sets the passed Effect "effect" with the Light information.
  10426. * @param effect The effect to update
  10427. * @param lightIndex The index of the light in the effect to update
  10428. * @returns The light
  10429. */
  10430. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10431. /**
  10432. * Returns the string "Light".
  10433. * @returns the class name
  10434. */
  10435. getClassName(): string;
  10436. /** @hidden */
  10437. readonly _isLight: boolean;
  10438. /**
  10439. * Converts the light information to a readable string for debug purpose.
  10440. * @param fullDetails Supports for multiple levels of logging within scene loading
  10441. * @returns the human readable light info
  10442. */
  10443. toString(fullDetails?: boolean): string;
  10444. /** @hidden */
  10445. protected _syncParentEnabledState(): void;
  10446. /**
  10447. * Set the enabled state of this node.
  10448. * @param value - the new enabled state
  10449. */
  10450. setEnabled(value: boolean): void;
  10451. /**
  10452. * Returns the Light associated shadow generator if any.
  10453. * @return the associated shadow generator.
  10454. */
  10455. getShadowGenerator(): Nullable<IShadowGenerator>;
  10456. /**
  10457. * Returns a Vector3, the absolute light position in the World.
  10458. * @returns the world space position of the light
  10459. */
  10460. getAbsolutePosition(): Vector3;
  10461. /**
  10462. * Specifies if the light will affect the passed mesh.
  10463. * @param mesh The mesh to test against the light
  10464. * @return true the mesh is affected otherwise, false.
  10465. */
  10466. canAffectMesh(mesh: AbstractMesh): boolean;
  10467. /**
  10468. * Sort function to order lights for rendering.
  10469. * @param a First Light object to compare to second.
  10470. * @param b Second Light object to compare first.
  10471. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10472. */
  10473. static CompareLightsPriority(a: Light, b: Light): number;
  10474. /**
  10475. * Releases resources associated with this node.
  10476. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10477. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10478. */
  10479. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10480. /**
  10481. * Returns the light type ID (integer).
  10482. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10483. */
  10484. getTypeID(): number;
  10485. /**
  10486. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10487. * @returns the scaled intensity in intensity mode unit
  10488. */
  10489. getScaledIntensity(): number;
  10490. /**
  10491. * Returns a new Light object, named "name", from the current one.
  10492. * @param name The name of the cloned light
  10493. * @returns the new created light
  10494. */
  10495. clone(name: string): Nullable<Light>;
  10496. /**
  10497. * Serializes the current light into a Serialization object.
  10498. * @returns the serialized object.
  10499. */
  10500. serialize(): any;
  10501. /**
  10502. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10503. * This new light is named "name" and added to the passed scene.
  10504. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10505. * @param name The friendly name of the light
  10506. * @param scene The scene the new light will belong to
  10507. * @returns the constructor function
  10508. */
  10509. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10510. /**
  10511. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10512. * @param parsedLight The JSON representation of the light
  10513. * @param scene The scene to create the parsed light in
  10514. * @returns the created light after parsing
  10515. */
  10516. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10517. private _hookArrayForExcluded;
  10518. private _hookArrayForIncludedOnly;
  10519. private _resyncMeshes;
  10520. /**
  10521. * Forces the meshes to update their light related information in their rendering used effects
  10522. * @hidden Internal Use Only
  10523. */
  10524. _markMeshesAsLightDirty(): void;
  10525. /**
  10526. * Recomputes the cached photometric scale if needed.
  10527. */
  10528. private _computePhotometricScale;
  10529. /**
  10530. * Returns the Photometric Scale according to the light type and intensity mode.
  10531. */
  10532. private _getPhotometricScale;
  10533. /**
  10534. * Reorder the light in the scene according to their defined priority.
  10535. * @hidden Internal Use Only
  10536. */
  10537. _reorderLightsInScene(): void;
  10538. /**
  10539. * Prepares the list of defines specific to the light type.
  10540. * @param defines the list of defines
  10541. * @param lightIndex defines the index of the light for the effect
  10542. */
  10543. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10544. }
  10545. }
  10546. declare module BABYLON {
  10547. /**
  10548. * Interface used to define Action
  10549. */
  10550. export interface IAction {
  10551. /**
  10552. * Trigger for the action
  10553. */
  10554. trigger: number;
  10555. /** Options of the trigger */
  10556. triggerOptions: any;
  10557. /**
  10558. * Gets the trigger parameters
  10559. * @returns the trigger parameters
  10560. */
  10561. getTriggerParameter(): any;
  10562. /**
  10563. * Internal only - executes current action event
  10564. * @hidden
  10565. */
  10566. _executeCurrent(evt?: ActionEvent): void;
  10567. /**
  10568. * Serialize placeholder for child classes
  10569. * @param parent of child
  10570. * @returns the serialized object
  10571. */
  10572. serialize(parent: any): any;
  10573. /**
  10574. * Internal only
  10575. * @hidden
  10576. */
  10577. _prepare(): void;
  10578. /**
  10579. * Internal only - manager for action
  10580. * @hidden
  10581. */
  10582. _actionManager: AbstractActionManager;
  10583. }
  10584. /**
  10585. * The action to be carried out following a trigger
  10586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10587. */
  10588. export class Action implements IAction {
  10589. /** the trigger, with or without parameters, for the action */
  10590. triggerOptions: any;
  10591. /**
  10592. * Trigger for the action
  10593. */
  10594. trigger: number;
  10595. /**
  10596. * Internal only - manager for action
  10597. * @hidden
  10598. */
  10599. _actionManager: ActionManager;
  10600. private _nextActiveAction;
  10601. private _child;
  10602. private _condition?;
  10603. private _triggerParameter;
  10604. /**
  10605. * An event triggered prior to action being executed.
  10606. */
  10607. onBeforeExecuteObservable: Observable<Action>;
  10608. /**
  10609. * Creates a new Action
  10610. * @param triggerOptions the trigger, with or without parameters, for the action
  10611. * @param condition an optional determinant of action
  10612. */
  10613. constructor(
  10614. /** the trigger, with or without parameters, for the action */
  10615. triggerOptions: any, condition?: Condition);
  10616. /**
  10617. * Internal only
  10618. * @hidden
  10619. */
  10620. _prepare(): void;
  10621. /**
  10622. * Gets the trigger parameters
  10623. * @returns the trigger parameters
  10624. */
  10625. getTriggerParameter(): any;
  10626. /**
  10627. * Internal only - executes current action event
  10628. * @hidden
  10629. */
  10630. _executeCurrent(evt?: ActionEvent): void;
  10631. /**
  10632. * Execute placeholder for child classes
  10633. * @param evt optional action event
  10634. */
  10635. execute(evt?: ActionEvent): void;
  10636. /**
  10637. * Skips to next active action
  10638. */
  10639. skipToNextActiveAction(): void;
  10640. /**
  10641. * Adds action to chain of actions, may be a DoNothingAction
  10642. * @param action defines the next action to execute
  10643. * @returns The action passed in
  10644. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10645. */
  10646. then(action: Action): Action;
  10647. /**
  10648. * Internal only
  10649. * @hidden
  10650. */
  10651. _getProperty(propertyPath: string): string;
  10652. /**
  10653. * Internal only
  10654. * @hidden
  10655. */
  10656. _getEffectiveTarget(target: any, propertyPath: string): any;
  10657. /**
  10658. * Serialize placeholder for child classes
  10659. * @param parent of child
  10660. * @returns the serialized object
  10661. */
  10662. serialize(parent: any): any;
  10663. /**
  10664. * Internal only called by serialize
  10665. * @hidden
  10666. */
  10667. protected _serialize(serializedAction: any, parent?: any): any;
  10668. /**
  10669. * Internal only
  10670. * @hidden
  10671. */
  10672. static _SerializeValueAsString: (value: any) => string;
  10673. /**
  10674. * Internal only
  10675. * @hidden
  10676. */
  10677. static _GetTargetProperty: (target: Scene | Node) => {
  10678. name: string;
  10679. targetType: string;
  10680. value: string;
  10681. };
  10682. }
  10683. }
  10684. declare module BABYLON {
  10685. /**
  10686. * A Condition applied to an Action
  10687. */
  10688. export class Condition {
  10689. /**
  10690. * Internal only - manager for action
  10691. * @hidden
  10692. */
  10693. _actionManager: ActionManager;
  10694. /**
  10695. * Internal only
  10696. * @hidden
  10697. */
  10698. _evaluationId: number;
  10699. /**
  10700. * Internal only
  10701. * @hidden
  10702. */
  10703. _currentResult: boolean;
  10704. /**
  10705. * Creates a new Condition
  10706. * @param actionManager the manager of the action the condition is applied to
  10707. */
  10708. constructor(actionManager: ActionManager);
  10709. /**
  10710. * Check if the current condition is valid
  10711. * @returns a boolean
  10712. */
  10713. isValid(): boolean;
  10714. /**
  10715. * Internal only
  10716. * @hidden
  10717. */
  10718. _getProperty(propertyPath: string): string;
  10719. /**
  10720. * Internal only
  10721. * @hidden
  10722. */
  10723. _getEffectiveTarget(target: any, propertyPath: string): any;
  10724. /**
  10725. * Serialize placeholder for child classes
  10726. * @returns the serialized object
  10727. */
  10728. serialize(): any;
  10729. /**
  10730. * Internal only
  10731. * @hidden
  10732. */
  10733. protected _serialize(serializedCondition: any): any;
  10734. }
  10735. /**
  10736. * Defines specific conditional operators as extensions of Condition
  10737. */
  10738. export class ValueCondition extends Condition {
  10739. /** path to specify the property of the target the conditional operator uses */
  10740. propertyPath: string;
  10741. /** the value compared by the conditional operator against the current value of the property */
  10742. value: any;
  10743. /** the conditional operator, default ValueCondition.IsEqual */
  10744. operator: number;
  10745. /**
  10746. * Internal only
  10747. * @hidden
  10748. */
  10749. private static _IsEqual;
  10750. /**
  10751. * Internal only
  10752. * @hidden
  10753. */
  10754. private static _IsDifferent;
  10755. /**
  10756. * Internal only
  10757. * @hidden
  10758. */
  10759. private static _IsGreater;
  10760. /**
  10761. * Internal only
  10762. * @hidden
  10763. */
  10764. private static _IsLesser;
  10765. /**
  10766. * returns the number for IsEqual
  10767. */
  10768. static readonly IsEqual: number;
  10769. /**
  10770. * Returns the number for IsDifferent
  10771. */
  10772. static readonly IsDifferent: number;
  10773. /**
  10774. * Returns the number for IsGreater
  10775. */
  10776. static readonly IsGreater: number;
  10777. /**
  10778. * Returns the number for IsLesser
  10779. */
  10780. static readonly IsLesser: number;
  10781. /**
  10782. * Internal only The action manager for the condition
  10783. * @hidden
  10784. */
  10785. _actionManager: ActionManager;
  10786. /**
  10787. * Internal only
  10788. * @hidden
  10789. */
  10790. private _target;
  10791. /**
  10792. * Internal only
  10793. * @hidden
  10794. */
  10795. private _effectiveTarget;
  10796. /**
  10797. * Internal only
  10798. * @hidden
  10799. */
  10800. private _property;
  10801. /**
  10802. * Creates a new ValueCondition
  10803. * @param actionManager manager for the action the condition applies to
  10804. * @param target for the action
  10805. * @param propertyPath path to specify the property of the target the conditional operator uses
  10806. * @param value the value compared by the conditional operator against the current value of the property
  10807. * @param operator the conditional operator, default ValueCondition.IsEqual
  10808. */
  10809. constructor(actionManager: ActionManager, target: any,
  10810. /** path to specify the property of the target the conditional operator uses */
  10811. propertyPath: string,
  10812. /** the value compared by the conditional operator against the current value of the property */
  10813. value: any,
  10814. /** the conditional operator, default ValueCondition.IsEqual */
  10815. operator?: number);
  10816. /**
  10817. * Compares the given value with the property value for the specified conditional operator
  10818. * @returns the result of the comparison
  10819. */
  10820. isValid(): boolean;
  10821. /**
  10822. * Serialize the ValueCondition into a JSON compatible object
  10823. * @returns serialization object
  10824. */
  10825. serialize(): any;
  10826. /**
  10827. * Gets the name of the conditional operator for the ValueCondition
  10828. * @param operator the conditional operator
  10829. * @returns the name
  10830. */
  10831. static GetOperatorName(operator: number): string;
  10832. }
  10833. /**
  10834. * Defines a predicate condition as an extension of Condition
  10835. */
  10836. export class PredicateCondition extends Condition {
  10837. /** defines the predicate function used to validate the condition */
  10838. predicate: () => boolean;
  10839. /**
  10840. * Internal only - manager for action
  10841. * @hidden
  10842. */
  10843. _actionManager: ActionManager;
  10844. /**
  10845. * Creates a new PredicateCondition
  10846. * @param actionManager manager for the action the condition applies to
  10847. * @param predicate defines the predicate function used to validate the condition
  10848. */
  10849. constructor(actionManager: ActionManager,
  10850. /** defines the predicate function used to validate the condition */
  10851. predicate: () => boolean);
  10852. /**
  10853. * @returns the validity of the predicate condition
  10854. */
  10855. isValid(): boolean;
  10856. }
  10857. /**
  10858. * Defines a state condition as an extension of Condition
  10859. */
  10860. export class StateCondition extends Condition {
  10861. /** Value to compare with target state */
  10862. value: string;
  10863. /**
  10864. * Internal only - manager for action
  10865. * @hidden
  10866. */
  10867. _actionManager: ActionManager;
  10868. /**
  10869. * Internal only
  10870. * @hidden
  10871. */
  10872. private _target;
  10873. /**
  10874. * Creates a new StateCondition
  10875. * @param actionManager manager for the action the condition applies to
  10876. * @param target of the condition
  10877. * @param value to compare with target state
  10878. */
  10879. constructor(actionManager: ActionManager, target: any,
  10880. /** Value to compare with target state */
  10881. value: string);
  10882. /**
  10883. * Gets a boolean indicating if the current condition is met
  10884. * @returns the validity of the state
  10885. */
  10886. isValid(): boolean;
  10887. /**
  10888. * Serialize the StateCondition into a JSON compatible object
  10889. * @returns serialization object
  10890. */
  10891. serialize(): any;
  10892. }
  10893. }
  10894. declare module BABYLON {
  10895. /**
  10896. * This defines an action responsible to toggle a boolean once triggered.
  10897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10898. */
  10899. export class SwitchBooleanAction extends Action {
  10900. /**
  10901. * The path to the boolean property in the target object
  10902. */
  10903. propertyPath: string;
  10904. private _target;
  10905. private _effectiveTarget;
  10906. private _property;
  10907. /**
  10908. * Instantiate the action
  10909. * @param triggerOptions defines the trigger options
  10910. * @param target defines the object containing the boolean
  10911. * @param propertyPath defines the path to the boolean property in the target object
  10912. * @param condition defines the trigger related conditions
  10913. */
  10914. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10915. /** @hidden */
  10916. _prepare(): void;
  10917. /**
  10918. * Execute the action toggle the boolean value.
  10919. */
  10920. execute(): void;
  10921. /**
  10922. * Serializes the actions and its related information.
  10923. * @param parent defines the object to serialize in
  10924. * @returns the serialized object
  10925. */
  10926. serialize(parent: any): any;
  10927. }
  10928. /**
  10929. * This defines an action responsible to set a the state field of the target
  10930. * to a desired value once triggered.
  10931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10932. */
  10933. export class SetStateAction extends Action {
  10934. /**
  10935. * The value to store in the state field.
  10936. */
  10937. value: string;
  10938. private _target;
  10939. /**
  10940. * Instantiate the action
  10941. * @param triggerOptions defines the trigger options
  10942. * @param target defines the object containing the state property
  10943. * @param value defines the value to store in the state field
  10944. * @param condition defines the trigger related conditions
  10945. */
  10946. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10947. /**
  10948. * Execute the action and store the value on the target state property.
  10949. */
  10950. execute(): void;
  10951. /**
  10952. * Serializes the actions and its related information.
  10953. * @param parent defines the object to serialize in
  10954. * @returns the serialized object
  10955. */
  10956. serialize(parent: any): any;
  10957. }
  10958. /**
  10959. * This defines an action responsible to set a property of the target
  10960. * to a desired value once triggered.
  10961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10962. */
  10963. export class SetValueAction extends Action {
  10964. /**
  10965. * The path of the property to set in the target.
  10966. */
  10967. propertyPath: string;
  10968. /**
  10969. * The value to set in the property
  10970. */
  10971. value: any;
  10972. private _target;
  10973. private _effectiveTarget;
  10974. private _property;
  10975. /**
  10976. * Instantiate the action
  10977. * @param triggerOptions defines the trigger options
  10978. * @param target defines the object containing the property
  10979. * @param propertyPath defines the path of the property to set in the target
  10980. * @param value defines the value to set in the property
  10981. * @param condition defines the trigger related conditions
  10982. */
  10983. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10984. /** @hidden */
  10985. _prepare(): void;
  10986. /**
  10987. * Execute the action and set the targetted property to the desired value.
  10988. */
  10989. execute(): void;
  10990. /**
  10991. * Serializes the actions and its related information.
  10992. * @param parent defines the object to serialize in
  10993. * @returns the serialized object
  10994. */
  10995. serialize(parent: any): any;
  10996. }
  10997. /**
  10998. * This defines an action responsible to increment the target value
  10999. * to a desired value once triggered.
  11000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11001. */
  11002. export class IncrementValueAction extends Action {
  11003. /**
  11004. * The path of the property to increment in the target.
  11005. */
  11006. propertyPath: string;
  11007. /**
  11008. * The value we should increment the property by.
  11009. */
  11010. value: any;
  11011. private _target;
  11012. private _effectiveTarget;
  11013. private _property;
  11014. /**
  11015. * Instantiate the action
  11016. * @param triggerOptions defines the trigger options
  11017. * @param target defines the object containing the property
  11018. * @param propertyPath defines the path of the property to increment in the target
  11019. * @param value defines the value value we should increment the property by
  11020. * @param condition defines the trigger related conditions
  11021. */
  11022. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11023. /** @hidden */
  11024. _prepare(): void;
  11025. /**
  11026. * Execute the action and increment the target of the value amount.
  11027. */
  11028. execute(): void;
  11029. /**
  11030. * Serializes the actions and its related information.
  11031. * @param parent defines the object to serialize in
  11032. * @returns the serialized object
  11033. */
  11034. serialize(parent: any): any;
  11035. }
  11036. /**
  11037. * This defines an action responsible to start an animation once triggered.
  11038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11039. */
  11040. export class PlayAnimationAction extends Action {
  11041. /**
  11042. * Where the animation should start (animation frame)
  11043. */
  11044. from: number;
  11045. /**
  11046. * Where the animation should stop (animation frame)
  11047. */
  11048. to: number;
  11049. /**
  11050. * Define if the animation should loop or stop after the first play.
  11051. */
  11052. loop?: boolean;
  11053. private _target;
  11054. /**
  11055. * Instantiate the action
  11056. * @param triggerOptions defines the trigger options
  11057. * @param target defines the target animation or animation name
  11058. * @param from defines from where the animation should start (animation frame)
  11059. * @param end defines where the animation should stop (animation frame)
  11060. * @param loop defines if the animation should loop or stop after the first play
  11061. * @param condition defines the trigger related conditions
  11062. */
  11063. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11064. /** @hidden */
  11065. _prepare(): void;
  11066. /**
  11067. * Execute the action and play the animation.
  11068. */
  11069. execute(): void;
  11070. /**
  11071. * Serializes the actions and its related information.
  11072. * @param parent defines the object to serialize in
  11073. * @returns the serialized object
  11074. */
  11075. serialize(parent: any): any;
  11076. }
  11077. /**
  11078. * This defines an action responsible to stop an animation once triggered.
  11079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11080. */
  11081. export class StopAnimationAction extends Action {
  11082. private _target;
  11083. /**
  11084. * Instantiate the action
  11085. * @param triggerOptions defines the trigger options
  11086. * @param target defines the target animation or animation name
  11087. * @param condition defines the trigger related conditions
  11088. */
  11089. constructor(triggerOptions: any, target: any, condition?: Condition);
  11090. /** @hidden */
  11091. _prepare(): void;
  11092. /**
  11093. * Execute the action and stop the animation.
  11094. */
  11095. execute(): void;
  11096. /**
  11097. * Serializes the actions and its related information.
  11098. * @param parent defines the object to serialize in
  11099. * @returns the serialized object
  11100. */
  11101. serialize(parent: any): any;
  11102. }
  11103. /**
  11104. * This defines an action responsible that does nothing once triggered.
  11105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11106. */
  11107. export class DoNothingAction extends Action {
  11108. /**
  11109. * Instantiate the action
  11110. * @param triggerOptions defines the trigger options
  11111. * @param condition defines the trigger related conditions
  11112. */
  11113. constructor(triggerOptions?: any, condition?: Condition);
  11114. /**
  11115. * Execute the action and do nothing.
  11116. */
  11117. execute(): void;
  11118. /**
  11119. * Serializes the actions and its related information.
  11120. * @param parent defines the object to serialize in
  11121. * @returns the serialized object
  11122. */
  11123. serialize(parent: any): any;
  11124. }
  11125. /**
  11126. * This defines an action responsible to trigger several actions once triggered.
  11127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11128. */
  11129. export class CombineAction extends Action {
  11130. /**
  11131. * The list of aggregated animations to run.
  11132. */
  11133. children: Action[];
  11134. /**
  11135. * Instantiate the action
  11136. * @param triggerOptions defines the trigger options
  11137. * @param children defines the list of aggregated animations to run
  11138. * @param condition defines the trigger related conditions
  11139. */
  11140. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11141. /** @hidden */
  11142. _prepare(): void;
  11143. /**
  11144. * Execute the action and executes all the aggregated actions.
  11145. */
  11146. execute(evt: ActionEvent): void;
  11147. /**
  11148. * Serializes the actions and its related information.
  11149. * @param parent defines the object to serialize in
  11150. * @returns the serialized object
  11151. */
  11152. serialize(parent: any): any;
  11153. }
  11154. /**
  11155. * This defines an action responsible to run code (external event) once triggered.
  11156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11157. */
  11158. export class ExecuteCodeAction extends Action {
  11159. /**
  11160. * The callback function to run.
  11161. */
  11162. func: (evt: ActionEvent) => void;
  11163. /**
  11164. * Instantiate the action
  11165. * @param triggerOptions defines the trigger options
  11166. * @param func defines the callback function to run
  11167. * @param condition defines the trigger related conditions
  11168. */
  11169. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11170. /**
  11171. * Execute the action and run the attached code.
  11172. */
  11173. execute(evt: ActionEvent): void;
  11174. }
  11175. /**
  11176. * This defines an action responsible to set the parent property of the target once triggered.
  11177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11178. */
  11179. export class SetParentAction extends Action {
  11180. private _parent;
  11181. private _target;
  11182. /**
  11183. * Instantiate the action
  11184. * @param triggerOptions defines the trigger options
  11185. * @param target defines the target containing the parent property
  11186. * @param parent defines from where the animation should start (animation frame)
  11187. * @param condition defines the trigger related conditions
  11188. */
  11189. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11190. /** @hidden */
  11191. _prepare(): void;
  11192. /**
  11193. * Execute the action and set the parent property.
  11194. */
  11195. execute(): void;
  11196. /**
  11197. * Serializes the actions and its related information.
  11198. * @param parent defines the object to serialize in
  11199. * @returns the serialized object
  11200. */
  11201. serialize(parent: any): any;
  11202. }
  11203. }
  11204. declare module BABYLON {
  11205. /**
  11206. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11207. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11209. */
  11210. export class ActionManager extends AbstractActionManager {
  11211. /**
  11212. * Nothing
  11213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11214. */
  11215. static readonly NothingTrigger: number;
  11216. /**
  11217. * On pick
  11218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11219. */
  11220. static readonly OnPickTrigger: number;
  11221. /**
  11222. * On left pick
  11223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11224. */
  11225. static readonly OnLeftPickTrigger: number;
  11226. /**
  11227. * On right pick
  11228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11229. */
  11230. static readonly OnRightPickTrigger: number;
  11231. /**
  11232. * On center pick
  11233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11234. */
  11235. static readonly OnCenterPickTrigger: number;
  11236. /**
  11237. * On pick down
  11238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11239. */
  11240. static readonly OnPickDownTrigger: number;
  11241. /**
  11242. * On double pick
  11243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11244. */
  11245. static readonly OnDoublePickTrigger: number;
  11246. /**
  11247. * On pick up
  11248. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11249. */
  11250. static readonly OnPickUpTrigger: number;
  11251. /**
  11252. * On pick out.
  11253. * This trigger will only be raised if you also declared a OnPickDown
  11254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11255. */
  11256. static readonly OnPickOutTrigger: number;
  11257. /**
  11258. * On long press
  11259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11260. */
  11261. static readonly OnLongPressTrigger: number;
  11262. /**
  11263. * On pointer over
  11264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11265. */
  11266. static readonly OnPointerOverTrigger: number;
  11267. /**
  11268. * On pointer out
  11269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11270. */
  11271. static readonly OnPointerOutTrigger: number;
  11272. /**
  11273. * On every frame
  11274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11275. */
  11276. static readonly OnEveryFrameTrigger: number;
  11277. /**
  11278. * On intersection enter
  11279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11280. */
  11281. static readonly OnIntersectionEnterTrigger: number;
  11282. /**
  11283. * On intersection exit
  11284. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11285. */
  11286. static readonly OnIntersectionExitTrigger: number;
  11287. /**
  11288. * On key down
  11289. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11290. */
  11291. static readonly OnKeyDownTrigger: number;
  11292. /**
  11293. * On key up
  11294. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11295. */
  11296. static readonly OnKeyUpTrigger: number;
  11297. private _scene;
  11298. /**
  11299. * Creates a new action manager
  11300. * @param scene defines the hosting scene
  11301. */
  11302. constructor(scene: Scene);
  11303. /**
  11304. * Releases all associated resources
  11305. */
  11306. dispose(): void;
  11307. /**
  11308. * Gets hosting scene
  11309. * @returns the hosting scene
  11310. */
  11311. getScene(): Scene;
  11312. /**
  11313. * Does this action manager handles actions of any of the given triggers
  11314. * @param triggers defines the triggers to be tested
  11315. * @return a boolean indicating whether one (or more) of the triggers is handled
  11316. */
  11317. hasSpecificTriggers(triggers: number[]): boolean;
  11318. /**
  11319. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11320. * speed.
  11321. * @param triggerA defines the trigger to be tested
  11322. * @param triggerB defines the trigger to be tested
  11323. * @return a boolean indicating whether one (or more) of the triggers is handled
  11324. */
  11325. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11326. /**
  11327. * Does this action manager handles actions of a given trigger
  11328. * @param trigger defines the trigger to be tested
  11329. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11330. * @return whether the trigger is handled
  11331. */
  11332. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11333. /**
  11334. * Does this action manager has pointer triggers
  11335. */
  11336. readonly hasPointerTriggers: boolean;
  11337. /**
  11338. * Does this action manager has pick triggers
  11339. */
  11340. readonly hasPickTriggers: boolean;
  11341. /**
  11342. * Registers an action to this action manager
  11343. * @param action defines the action to be registered
  11344. * @return the action amended (prepared) after registration
  11345. */
  11346. registerAction(action: IAction): Nullable<IAction>;
  11347. /**
  11348. * Unregisters an action to this action manager
  11349. * @param action defines the action to be unregistered
  11350. * @return a boolean indicating whether the action has been unregistered
  11351. */
  11352. unregisterAction(action: IAction): Boolean;
  11353. /**
  11354. * Process a specific trigger
  11355. * @param trigger defines the trigger to process
  11356. * @param evt defines the event details to be processed
  11357. */
  11358. processTrigger(trigger: number, evt?: IActionEvent): void;
  11359. /** @hidden */
  11360. _getEffectiveTarget(target: any, propertyPath: string): any;
  11361. /** @hidden */
  11362. _getProperty(propertyPath: string): string;
  11363. /**
  11364. * Serialize this manager to a JSON object
  11365. * @param name defines the property name to store this manager
  11366. * @returns a JSON representation of this manager
  11367. */
  11368. serialize(name: string): any;
  11369. /**
  11370. * Creates a new ActionManager from a JSON data
  11371. * @param parsedActions defines the JSON data to read from
  11372. * @param object defines the hosting mesh
  11373. * @param scene defines the hosting scene
  11374. */
  11375. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11376. /**
  11377. * Get a trigger name by index
  11378. * @param trigger defines the trigger index
  11379. * @returns a trigger name
  11380. */
  11381. static GetTriggerName(trigger: number): string;
  11382. }
  11383. }
  11384. declare module BABYLON {
  11385. /**
  11386. * Class representing a ray with position and direction
  11387. */
  11388. export class Ray {
  11389. /** origin point */
  11390. origin: Vector3;
  11391. /** direction */
  11392. direction: Vector3;
  11393. /** length of the ray */
  11394. length: number;
  11395. private static readonly TmpVector3;
  11396. private _tmpRay;
  11397. /**
  11398. * Creates a new ray
  11399. * @param origin origin point
  11400. * @param direction direction
  11401. * @param length length of the ray
  11402. */
  11403. constructor(
  11404. /** origin point */
  11405. origin: Vector3,
  11406. /** direction */
  11407. direction: Vector3,
  11408. /** length of the ray */
  11409. length?: number);
  11410. /**
  11411. * Checks if the ray intersects a box
  11412. * @param minimum bound of the box
  11413. * @param maximum bound of the box
  11414. * @param intersectionTreshold extra extend to be added to the box in all direction
  11415. * @returns if the box was hit
  11416. */
  11417. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11418. /**
  11419. * Checks if the ray intersects a box
  11420. * @param box the bounding box to check
  11421. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11422. * @returns if the box was hit
  11423. */
  11424. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11425. /**
  11426. * If the ray hits a sphere
  11427. * @param sphere the bounding sphere to check
  11428. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11429. * @returns true if it hits the sphere
  11430. */
  11431. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11432. /**
  11433. * If the ray hits a triange
  11434. * @param vertex0 triangle vertex
  11435. * @param vertex1 triangle vertex
  11436. * @param vertex2 triangle vertex
  11437. * @returns intersection information if hit
  11438. */
  11439. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11440. /**
  11441. * Checks if ray intersects a plane
  11442. * @param plane the plane to check
  11443. * @returns the distance away it was hit
  11444. */
  11445. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11446. /**
  11447. * Checks if ray intersects a mesh
  11448. * @param mesh the mesh to check
  11449. * @param fastCheck if only the bounding box should checked
  11450. * @returns picking info of the intersecton
  11451. */
  11452. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11453. /**
  11454. * Checks if ray intersects a mesh
  11455. * @param meshes the meshes to check
  11456. * @param fastCheck if only the bounding box should checked
  11457. * @param results array to store result in
  11458. * @returns Array of picking infos
  11459. */
  11460. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11461. private _comparePickingInfo;
  11462. private static smallnum;
  11463. private static rayl;
  11464. /**
  11465. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11466. * @param sega the first point of the segment to test the intersection against
  11467. * @param segb the second point of the segment to test the intersection against
  11468. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11469. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11470. */
  11471. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11472. /**
  11473. * Update the ray from viewport position
  11474. * @param x position
  11475. * @param y y position
  11476. * @param viewportWidth viewport width
  11477. * @param viewportHeight viewport height
  11478. * @param world world matrix
  11479. * @param view view matrix
  11480. * @param projection projection matrix
  11481. * @returns this ray updated
  11482. */
  11483. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11484. /**
  11485. * Creates a ray with origin and direction of 0,0,0
  11486. * @returns the new ray
  11487. */
  11488. static Zero(): Ray;
  11489. /**
  11490. * Creates a new ray from screen space and viewport
  11491. * @param x position
  11492. * @param y y position
  11493. * @param viewportWidth viewport width
  11494. * @param viewportHeight viewport height
  11495. * @param world world matrix
  11496. * @param view view matrix
  11497. * @param projection projection matrix
  11498. * @returns new ray
  11499. */
  11500. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11501. /**
  11502. * 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
  11503. * transformed to the given world matrix.
  11504. * @param origin The origin point
  11505. * @param end The end point
  11506. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11507. * @returns the new ray
  11508. */
  11509. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11510. /**
  11511. * Transforms a ray by a matrix
  11512. * @param ray ray to transform
  11513. * @param matrix matrix to apply
  11514. * @returns the resulting new ray
  11515. */
  11516. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11517. /**
  11518. * Transforms a ray by a matrix
  11519. * @param ray ray to transform
  11520. * @param matrix matrix to apply
  11521. * @param result ray to store result in
  11522. */
  11523. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11524. /**
  11525. * Unproject a ray from screen space to object space
  11526. * @param sourceX defines the screen space x coordinate to use
  11527. * @param sourceY defines the screen space y coordinate to use
  11528. * @param viewportWidth defines the current width of the viewport
  11529. * @param viewportHeight defines the current height of the viewport
  11530. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11531. * @param view defines the view matrix to use
  11532. * @param projection defines the projection matrix to use
  11533. */
  11534. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11535. }
  11536. /**
  11537. * Type used to define predicate used to select faces when a mesh intersection is detected
  11538. */
  11539. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11540. interface Scene {
  11541. /** @hidden */
  11542. _tempPickingRay: Nullable<Ray>;
  11543. /** @hidden */
  11544. _cachedRayForTransform: Ray;
  11545. /** @hidden */
  11546. _pickWithRayInverseMatrix: Matrix;
  11547. /** @hidden */
  11548. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11549. /** @hidden */
  11550. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11551. }
  11552. }
  11553. declare module BABYLON {
  11554. /**
  11555. * Groups all the scene component constants in one place to ease maintenance.
  11556. * @hidden
  11557. */
  11558. export class SceneComponentConstants {
  11559. static readonly NAME_EFFECTLAYER: string;
  11560. static readonly NAME_LAYER: string;
  11561. static readonly NAME_LENSFLARESYSTEM: string;
  11562. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11563. static readonly NAME_PARTICLESYSTEM: string;
  11564. static readonly NAME_GAMEPAD: string;
  11565. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11566. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11567. static readonly NAME_DEPTHRENDERER: string;
  11568. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11569. static readonly NAME_SPRITE: string;
  11570. static readonly NAME_OUTLINERENDERER: string;
  11571. static readonly NAME_PROCEDURALTEXTURE: string;
  11572. static readonly NAME_SHADOWGENERATOR: string;
  11573. static readonly NAME_OCTREE: string;
  11574. static readonly NAME_PHYSICSENGINE: string;
  11575. static readonly NAME_AUDIO: string;
  11576. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11577. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11578. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11579. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11580. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11581. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11582. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11583. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11584. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11585. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11586. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11587. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11588. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11589. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11590. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11591. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11592. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11593. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11594. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11595. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11596. static readonly STEP_AFTERRENDER_AUDIO: number;
  11597. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11598. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11599. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11600. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11601. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11602. static readonly STEP_POINTERMOVE_SPRITE: number;
  11603. static readonly STEP_POINTERDOWN_SPRITE: number;
  11604. static readonly STEP_POINTERUP_SPRITE: number;
  11605. }
  11606. /**
  11607. * This represents a scene component.
  11608. *
  11609. * This is used to decouple the dependency the scene is having on the different workloads like
  11610. * layers, post processes...
  11611. */
  11612. export interface ISceneComponent {
  11613. /**
  11614. * The name of the component. Each component must have a unique name.
  11615. */
  11616. name: string;
  11617. /**
  11618. * The scene the component belongs to.
  11619. */
  11620. scene: Scene;
  11621. /**
  11622. * Register the component to one instance of a scene.
  11623. */
  11624. register(): void;
  11625. /**
  11626. * Rebuilds the elements related to this component in case of
  11627. * context lost for instance.
  11628. */
  11629. rebuild(): void;
  11630. /**
  11631. * Disposes the component and the associated ressources.
  11632. */
  11633. dispose(): void;
  11634. }
  11635. /**
  11636. * This represents a SERIALIZABLE scene component.
  11637. *
  11638. * This extends Scene Component to add Serialization methods on top.
  11639. */
  11640. export interface ISceneSerializableComponent extends ISceneComponent {
  11641. /**
  11642. * Adds all the element from the container to the scene
  11643. * @param container the container holding the elements
  11644. */
  11645. addFromContainer(container: AbstractScene): void;
  11646. /**
  11647. * Removes all the elements in the container from the scene
  11648. * @param container contains the elements to remove
  11649. * @param dispose if the removed element should be disposed (default: false)
  11650. */
  11651. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11652. /**
  11653. * Serializes the component data to the specified json object
  11654. * @param serializationObject The object to serialize to
  11655. */
  11656. serialize(serializationObject: any): void;
  11657. }
  11658. /**
  11659. * Strong typing of a Mesh related stage step action
  11660. */
  11661. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11662. /**
  11663. * Strong typing of a Evaluate Sub Mesh related stage step action
  11664. */
  11665. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11666. /**
  11667. * Strong typing of a Active Mesh related stage step action
  11668. */
  11669. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11670. /**
  11671. * Strong typing of a Camera related stage step action
  11672. */
  11673. export type CameraStageAction = (camera: Camera) => void;
  11674. /**
  11675. * Strong typing of a Camera Frame buffer related stage step action
  11676. */
  11677. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11678. /**
  11679. * Strong typing of a Render Target related stage step action
  11680. */
  11681. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11682. /**
  11683. * Strong typing of a RenderingGroup related stage step action
  11684. */
  11685. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11686. /**
  11687. * Strong typing of a Mesh Render related stage step action
  11688. */
  11689. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11690. /**
  11691. * Strong typing of a simple stage step action
  11692. */
  11693. export type SimpleStageAction = () => void;
  11694. /**
  11695. * Strong typing of a render target action.
  11696. */
  11697. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11698. /**
  11699. * Strong typing of a pointer move action.
  11700. */
  11701. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11702. /**
  11703. * Strong typing of a pointer up/down action.
  11704. */
  11705. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11706. /**
  11707. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11708. * @hidden
  11709. */
  11710. export class Stage<T extends Function> extends Array<{
  11711. index: number;
  11712. component: ISceneComponent;
  11713. action: T;
  11714. }> {
  11715. /**
  11716. * Hide ctor from the rest of the world.
  11717. * @param items The items to add.
  11718. */
  11719. private constructor();
  11720. /**
  11721. * Creates a new Stage.
  11722. * @returns A new instance of a Stage
  11723. */
  11724. static Create<T extends Function>(): Stage<T>;
  11725. /**
  11726. * Registers a step in an ordered way in the targeted stage.
  11727. * @param index Defines the position to register the step in
  11728. * @param component Defines the component attached to the step
  11729. * @param action Defines the action to launch during the step
  11730. */
  11731. registerStep(index: number, component: ISceneComponent, action: T): void;
  11732. /**
  11733. * Clears all the steps from the stage.
  11734. */
  11735. clear(): void;
  11736. }
  11737. }
  11738. declare module BABYLON {
  11739. interface Scene {
  11740. /** @hidden */
  11741. _pointerOverSprite: Nullable<Sprite>;
  11742. /** @hidden */
  11743. _pickedDownSprite: Nullable<Sprite>;
  11744. /** @hidden */
  11745. _tempSpritePickingRay: Nullable<Ray>;
  11746. /**
  11747. * All of the sprite managers added to this scene
  11748. * @see http://doc.babylonjs.com/babylon101/sprites
  11749. */
  11750. spriteManagers: Array<ISpriteManager>;
  11751. /**
  11752. * An event triggered when sprites rendering is about to start
  11753. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11754. */
  11755. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11756. /**
  11757. * An event triggered when sprites rendering is done
  11758. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11759. */
  11760. onAfterSpritesRenderingObservable: Observable<Scene>;
  11761. /** @hidden */
  11762. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11763. /** Launch a ray to try to pick a sprite in the scene
  11764. * @param x position on screen
  11765. * @param y position on screen
  11766. * @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
  11767. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11768. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11769. * @returns a PickingInfo
  11770. */
  11771. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11772. /** Use the given ray to pick a sprite in the scene
  11773. * @param ray The ray (in world space) to use to pick meshes
  11774. * @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
  11775. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11776. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11777. * @returns a PickingInfo
  11778. */
  11779. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11780. /**
  11781. * Force the sprite under the pointer
  11782. * @param sprite defines the sprite to use
  11783. */
  11784. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11785. /**
  11786. * Gets the sprite under the pointer
  11787. * @returns a Sprite or null if no sprite is under the pointer
  11788. */
  11789. getPointerOverSprite(): Nullable<Sprite>;
  11790. }
  11791. /**
  11792. * Defines the sprite scene component responsible to manage sprites
  11793. * in a given scene.
  11794. */
  11795. export class SpriteSceneComponent implements ISceneComponent {
  11796. /**
  11797. * The component name helpfull to identify the component in the list of scene components.
  11798. */
  11799. readonly name: string;
  11800. /**
  11801. * The scene the component belongs to.
  11802. */
  11803. scene: Scene;
  11804. /** @hidden */
  11805. private _spritePredicate;
  11806. /**
  11807. * Creates a new instance of the component for the given scene
  11808. * @param scene Defines the scene to register the component in
  11809. */
  11810. constructor(scene: Scene);
  11811. /**
  11812. * Registers the component in a given scene
  11813. */
  11814. register(): void;
  11815. /**
  11816. * Rebuilds the elements related to this component in case of
  11817. * context lost for instance.
  11818. */
  11819. rebuild(): void;
  11820. /**
  11821. * Disposes the component and the associated ressources.
  11822. */
  11823. dispose(): void;
  11824. private _pickSpriteButKeepRay;
  11825. private _pointerMove;
  11826. private _pointerDown;
  11827. private _pointerUp;
  11828. }
  11829. }
  11830. declare module BABYLON {
  11831. /** @hidden */
  11832. export var fogFragmentDeclaration: {
  11833. name: string;
  11834. shader: string;
  11835. };
  11836. }
  11837. declare module BABYLON {
  11838. /** @hidden */
  11839. export var fogFragment: {
  11840. name: string;
  11841. shader: string;
  11842. };
  11843. }
  11844. declare module BABYLON {
  11845. /** @hidden */
  11846. export var spritesPixelShader: {
  11847. name: string;
  11848. shader: string;
  11849. };
  11850. }
  11851. declare module BABYLON {
  11852. /** @hidden */
  11853. export var fogVertexDeclaration: {
  11854. name: string;
  11855. shader: string;
  11856. };
  11857. }
  11858. declare module BABYLON {
  11859. /** @hidden */
  11860. export var spritesVertexShader: {
  11861. name: string;
  11862. shader: string;
  11863. };
  11864. }
  11865. declare module BABYLON {
  11866. /**
  11867. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11868. */
  11869. export interface ISpriteManager extends IDisposable {
  11870. /**
  11871. * Restricts the camera to viewing objects with the same layerMask.
  11872. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11873. */
  11874. layerMask: number;
  11875. /**
  11876. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11877. */
  11878. isPickable: boolean;
  11879. /**
  11880. * Specifies the rendering group id for this mesh (0 by default)
  11881. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11882. */
  11883. renderingGroupId: number;
  11884. /**
  11885. * Defines the list of sprites managed by the manager.
  11886. */
  11887. sprites: Array<Sprite>;
  11888. /**
  11889. * Tests the intersection of a sprite with a specific ray.
  11890. * @param ray The ray we are sending to test the collision
  11891. * @param camera The camera space we are sending rays in
  11892. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11893. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11894. * @returns picking info or null.
  11895. */
  11896. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11897. /**
  11898. * Renders the list of sprites on screen.
  11899. */
  11900. render(): void;
  11901. }
  11902. /**
  11903. * Class used to manage multiple sprites on the same spritesheet
  11904. * @see http://doc.babylonjs.com/babylon101/sprites
  11905. */
  11906. export class SpriteManager implements ISpriteManager {
  11907. /** defines the manager's name */
  11908. name: string;
  11909. /** Gets the list of sprites */
  11910. sprites: Sprite[];
  11911. /** Gets or sets the rendering group id (0 by default) */
  11912. renderingGroupId: number;
  11913. /** Gets or sets camera layer mask */
  11914. layerMask: number;
  11915. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11916. fogEnabled: boolean;
  11917. /** Gets or sets a boolean indicating if the sprites are pickable */
  11918. isPickable: boolean;
  11919. /** Defines the default width of a cell in the spritesheet */
  11920. cellWidth: number;
  11921. /** Defines the default height of a cell in the spritesheet */
  11922. cellHeight: number;
  11923. /**
  11924. * An event triggered when the manager is disposed.
  11925. */
  11926. onDisposeObservable: Observable<SpriteManager>;
  11927. private _onDisposeObserver;
  11928. /**
  11929. * Callback called when the manager is disposed
  11930. */
  11931. onDispose: () => void;
  11932. private _capacity;
  11933. private _spriteTexture;
  11934. private _epsilon;
  11935. private _scene;
  11936. private _vertexData;
  11937. private _buffer;
  11938. private _vertexBuffers;
  11939. private _indexBuffer;
  11940. private _effectBase;
  11941. private _effectFog;
  11942. /**
  11943. * Gets or sets the spritesheet texture
  11944. */
  11945. texture: Texture;
  11946. /**
  11947. * Creates a new sprite manager
  11948. * @param name defines the manager's name
  11949. * @param imgUrl defines the sprite sheet url
  11950. * @param capacity defines the maximum allowed number of sprites
  11951. * @param cellSize defines the size of a sprite cell
  11952. * @param scene defines the hosting scene
  11953. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11954. * @param samplingMode defines the smapling mode to use with spritesheet
  11955. */
  11956. constructor(
  11957. /** defines the manager's name */
  11958. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11959. private _appendSpriteVertex;
  11960. /**
  11961. * Intersects the sprites with a ray
  11962. * @param ray defines the ray to intersect with
  11963. * @param camera defines the current active camera
  11964. * @param predicate defines a predicate used to select candidate sprites
  11965. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11966. * @returns null if no hit or a PickingInfo
  11967. */
  11968. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11969. /**
  11970. * Render all child sprites
  11971. */
  11972. render(): void;
  11973. /**
  11974. * Release associated resources
  11975. */
  11976. dispose(): void;
  11977. }
  11978. }
  11979. declare module BABYLON {
  11980. /**
  11981. * Class used to represent a sprite
  11982. * @see http://doc.babylonjs.com/babylon101/sprites
  11983. */
  11984. export class Sprite {
  11985. /** defines the name */
  11986. name: string;
  11987. /** Gets or sets the current world position */
  11988. position: Vector3;
  11989. /** Gets or sets the main color */
  11990. color: Color4;
  11991. /** Gets or sets the width */
  11992. width: number;
  11993. /** Gets or sets the height */
  11994. height: number;
  11995. /** Gets or sets rotation angle */
  11996. angle: number;
  11997. /** Gets or sets the cell index in the sprite sheet */
  11998. cellIndex: number;
  11999. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12000. invertU: number;
  12001. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12002. invertV: number;
  12003. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12004. disposeWhenFinishedAnimating: boolean;
  12005. /** Gets the list of attached animations */
  12006. animations: Animation[];
  12007. /** Gets or sets a boolean indicating if the sprite can be picked */
  12008. isPickable: boolean;
  12009. /**
  12010. * Gets or sets the associated action manager
  12011. */
  12012. actionManager: Nullable<ActionManager>;
  12013. private _animationStarted;
  12014. private _loopAnimation;
  12015. private _fromIndex;
  12016. private _toIndex;
  12017. private _delay;
  12018. private _direction;
  12019. private _manager;
  12020. private _time;
  12021. private _onAnimationEnd;
  12022. /**
  12023. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12024. */
  12025. isVisible: boolean;
  12026. /**
  12027. * Gets or sets the sprite size
  12028. */
  12029. size: number;
  12030. /**
  12031. * Creates a new Sprite
  12032. * @param name defines the name
  12033. * @param manager defines the manager
  12034. */
  12035. constructor(
  12036. /** defines the name */
  12037. name: string, manager: ISpriteManager);
  12038. /**
  12039. * Starts an animation
  12040. * @param from defines the initial key
  12041. * @param to defines the end key
  12042. * @param loop defines if the animation must loop
  12043. * @param delay defines the start delay (in ms)
  12044. * @param onAnimationEnd defines a callback to call when animation ends
  12045. */
  12046. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12047. /** Stops current animation (if any) */
  12048. stopAnimation(): void;
  12049. /** @hidden */
  12050. _animate(deltaTime: number): void;
  12051. /** Release associated resources */
  12052. dispose(): void;
  12053. }
  12054. }
  12055. declare module BABYLON {
  12056. /**
  12057. * Information about the result of picking within a scene
  12058. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12059. */
  12060. export class PickingInfo {
  12061. /** @hidden */
  12062. _pickingUnavailable: boolean;
  12063. /**
  12064. * If the pick collided with an object
  12065. */
  12066. hit: boolean;
  12067. /**
  12068. * Distance away where the pick collided
  12069. */
  12070. distance: number;
  12071. /**
  12072. * The location of pick collision
  12073. */
  12074. pickedPoint: Nullable<Vector3>;
  12075. /**
  12076. * The mesh corresponding the the pick collision
  12077. */
  12078. pickedMesh: Nullable<AbstractMesh>;
  12079. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12080. bu: number;
  12081. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12082. bv: number;
  12083. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12084. faceId: number;
  12085. /** Id of the the submesh that was picked */
  12086. subMeshId: number;
  12087. /** If a sprite was picked, this will be the sprite the pick collided with */
  12088. pickedSprite: Nullable<Sprite>;
  12089. /**
  12090. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12091. */
  12092. originMesh: Nullable<AbstractMesh>;
  12093. /**
  12094. * The ray that was used to perform the picking.
  12095. */
  12096. ray: Nullable<Ray>;
  12097. /**
  12098. * Gets the normal correspodning to the face the pick collided with
  12099. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12100. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12101. * @returns The normal correspodning to the face the pick collided with
  12102. */
  12103. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12104. /**
  12105. * Gets the texture coordinates of where the pick occured
  12106. * @returns the vector containing the coordnates of the texture
  12107. */
  12108. getTextureCoordinates(): Nullable<Vector2>;
  12109. }
  12110. }
  12111. declare module BABYLON {
  12112. /**
  12113. * Gather the list of pointer event types as constants.
  12114. */
  12115. export class PointerEventTypes {
  12116. /**
  12117. * 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.
  12118. */
  12119. static readonly POINTERDOWN: number;
  12120. /**
  12121. * The pointerup event is fired when a pointer is no longer active.
  12122. */
  12123. static readonly POINTERUP: number;
  12124. /**
  12125. * The pointermove event is fired when a pointer changes coordinates.
  12126. */
  12127. static readonly POINTERMOVE: number;
  12128. /**
  12129. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12130. */
  12131. static readonly POINTERWHEEL: number;
  12132. /**
  12133. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12134. */
  12135. static readonly POINTERPICK: number;
  12136. /**
  12137. * The pointertap event is fired when a the object has been touched and released without drag.
  12138. */
  12139. static readonly POINTERTAP: number;
  12140. /**
  12141. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12142. */
  12143. static readonly POINTERDOUBLETAP: number;
  12144. }
  12145. /**
  12146. * Base class of pointer info types.
  12147. */
  12148. export class PointerInfoBase {
  12149. /**
  12150. * Defines the type of event (PointerEventTypes)
  12151. */
  12152. type: number;
  12153. /**
  12154. * Defines the related dom event
  12155. */
  12156. event: PointerEvent | MouseWheelEvent;
  12157. /**
  12158. * Instantiates the base class of pointers info.
  12159. * @param type Defines the type of event (PointerEventTypes)
  12160. * @param event Defines the related dom event
  12161. */
  12162. constructor(
  12163. /**
  12164. * Defines the type of event (PointerEventTypes)
  12165. */
  12166. type: number,
  12167. /**
  12168. * Defines the related dom event
  12169. */
  12170. event: PointerEvent | MouseWheelEvent);
  12171. }
  12172. /**
  12173. * This class is used to store pointer related info for the onPrePointerObservable event.
  12174. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12175. */
  12176. export class PointerInfoPre extends PointerInfoBase {
  12177. /**
  12178. * Ray from a pointer if availible (eg. 6dof controller)
  12179. */
  12180. ray: Nullable<Ray>;
  12181. /**
  12182. * Defines the local position of the pointer on the canvas.
  12183. */
  12184. localPosition: Vector2;
  12185. /**
  12186. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12187. */
  12188. skipOnPointerObservable: boolean;
  12189. /**
  12190. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12191. * @param type Defines the type of event (PointerEventTypes)
  12192. * @param event Defines the related dom event
  12193. * @param localX Defines the local x coordinates of the pointer when the event occured
  12194. * @param localY Defines the local y coordinates of the pointer when the event occured
  12195. */
  12196. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12197. }
  12198. /**
  12199. * This type contains all the data related to a pointer event in Babylon.js.
  12200. * 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.
  12201. */
  12202. export class PointerInfo extends PointerInfoBase {
  12203. /**
  12204. * Defines the picking info associated to the info (if any)\
  12205. */
  12206. pickInfo: Nullable<PickingInfo>;
  12207. /**
  12208. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12209. * @param type Defines the type of event (PointerEventTypes)
  12210. * @param event Defines the related dom event
  12211. * @param pickInfo Defines the picking info associated to the info (if any)\
  12212. */
  12213. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12214. /**
  12215. * Defines the picking info associated to the info (if any)\
  12216. */
  12217. pickInfo: Nullable<PickingInfo>);
  12218. }
  12219. /**
  12220. * Data relating to a touch event on the screen.
  12221. */
  12222. export interface PointerTouch {
  12223. /**
  12224. * X coordinate of touch.
  12225. */
  12226. x: number;
  12227. /**
  12228. * Y coordinate of touch.
  12229. */
  12230. y: number;
  12231. /**
  12232. * Id of touch. Unique for each finger.
  12233. */
  12234. pointerId: number;
  12235. /**
  12236. * Event type passed from DOM.
  12237. */
  12238. type: any;
  12239. }
  12240. }
  12241. declare module BABYLON {
  12242. /**
  12243. * Manage the mouse inputs to control the movement of a free camera.
  12244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12245. */
  12246. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12247. /**
  12248. * Define if touch is enabled in the mouse input
  12249. */
  12250. touchEnabled: boolean;
  12251. /**
  12252. * Defines the camera the input is attached to.
  12253. */
  12254. camera: FreeCamera;
  12255. /**
  12256. * Defines the buttons associated with the input to handle camera move.
  12257. */
  12258. buttons: number[];
  12259. /**
  12260. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12261. */
  12262. angularSensibility: number;
  12263. private _pointerInput;
  12264. private _onMouseMove;
  12265. private _observer;
  12266. private previousPosition;
  12267. /**
  12268. * Observable for when a pointer move event occurs containing the move offset
  12269. */
  12270. onPointerMovedObservable: Observable<{
  12271. offsetX: number;
  12272. offsetY: number;
  12273. }>;
  12274. /**
  12275. * @hidden
  12276. * If the camera should be rotated automatically based on pointer movement
  12277. */
  12278. _allowCameraRotation: boolean;
  12279. /**
  12280. * Manage the mouse inputs to control the movement of a free camera.
  12281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12282. * @param touchEnabled Defines if touch is enabled or not
  12283. */
  12284. constructor(
  12285. /**
  12286. * Define if touch is enabled in the mouse input
  12287. */
  12288. touchEnabled?: boolean);
  12289. /**
  12290. * Attach the input controls to a specific dom element to get the input from.
  12291. * @param element Defines the element the controls should be listened from
  12292. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12293. */
  12294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12295. /**
  12296. * Called on JS contextmenu event.
  12297. * Override this method to provide functionality.
  12298. */
  12299. protected onContextMenu(evt: PointerEvent): void;
  12300. /**
  12301. * Detach the current controls from the specified dom element.
  12302. * @param element Defines the element to stop listening the inputs from
  12303. */
  12304. detachControl(element: Nullable<HTMLElement>): void;
  12305. /**
  12306. * Gets the class name of the current intput.
  12307. * @returns the class name
  12308. */
  12309. getClassName(): string;
  12310. /**
  12311. * Get the friendly name associated with the input class.
  12312. * @returns the input friendly name
  12313. */
  12314. getSimpleName(): string;
  12315. }
  12316. }
  12317. declare module BABYLON {
  12318. /**
  12319. * Manage the touch inputs to control the movement of a free camera.
  12320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12321. */
  12322. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12323. /**
  12324. * Defines the camera the input is attached to.
  12325. */
  12326. camera: FreeCamera;
  12327. /**
  12328. * Defines the touch sensibility for rotation.
  12329. * The higher the faster.
  12330. */
  12331. touchAngularSensibility: number;
  12332. /**
  12333. * Defines the touch sensibility for move.
  12334. * The higher the faster.
  12335. */
  12336. touchMoveSensibility: number;
  12337. private _offsetX;
  12338. private _offsetY;
  12339. private _pointerPressed;
  12340. private _pointerInput;
  12341. private _observer;
  12342. private _onLostFocus;
  12343. /**
  12344. * Attach the input controls to a specific dom element to get the input from.
  12345. * @param element Defines the element the controls should be listened from
  12346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12347. */
  12348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12349. /**
  12350. * Detach the current controls from the specified dom element.
  12351. * @param element Defines the element to stop listening the inputs from
  12352. */
  12353. detachControl(element: Nullable<HTMLElement>): void;
  12354. /**
  12355. * Update the current camera state depending on the inputs that have been used this frame.
  12356. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12357. */
  12358. checkInputs(): void;
  12359. /**
  12360. * Gets the class name of the current intput.
  12361. * @returns the class name
  12362. */
  12363. getClassName(): string;
  12364. /**
  12365. * Get the friendly name associated with the input class.
  12366. * @returns the input friendly name
  12367. */
  12368. getSimpleName(): string;
  12369. }
  12370. }
  12371. declare module BABYLON {
  12372. /**
  12373. * Default Inputs manager for the FreeCamera.
  12374. * It groups all the default supported inputs for ease of use.
  12375. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12376. */
  12377. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12378. /**
  12379. * @hidden
  12380. */
  12381. _mouseInput: Nullable<FreeCameraMouseInput>;
  12382. /**
  12383. * Instantiates a new FreeCameraInputsManager.
  12384. * @param camera Defines the camera the inputs belong to
  12385. */
  12386. constructor(camera: FreeCamera);
  12387. /**
  12388. * Add keyboard input support to the input manager.
  12389. * @returns the current input manager
  12390. */
  12391. addKeyboard(): FreeCameraInputsManager;
  12392. /**
  12393. * Add mouse input support to the input manager.
  12394. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12395. * @returns the current input manager
  12396. */
  12397. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12398. /**
  12399. * Removes the mouse input support from the manager
  12400. * @returns the current input manager
  12401. */
  12402. removeMouse(): FreeCameraInputsManager;
  12403. /**
  12404. * Add touch input support to the input manager.
  12405. * @returns the current input manager
  12406. */
  12407. addTouch(): FreeCameraInputsManager;
  12408. /**
  12409. * Remove all attached input methods from a camera
  12410. */
  12411. clear(): void;
  12412. }
  12413. }
  12414. declare module BABYLON {
  12415. /**
  12416. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12417. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12418. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12419. */
  12420. export class FreeCamera extends TargetCamera {
  12421. /**
  12422. * Define the collision ellipsoid of the camera.
  12423. * This is helpful to simulate a camera body like the player body around the camera
  12424. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12425. */
  12426. ellipsoid: Vector3;
  12427. /**
  12428. * Define an offset for the position of the ellipsoid around the camera.
  12429. * This can be helpful to determine the center of the body near the gravity center of the body
  12430. * instead of its head.
  12431. */
  12432. ellipsoidOffset: Vector3;
  12433. /**
  12434. * Enable or disable collisions of the camera with the rest of the scene objects.
  12435. */
  12436. checkCollisions: boolean;
  12437. /**
  12438. * Enable or disable gravity on the camera.
  12439. */
  12440. applyGravity: boolean;
  12441. /**
  12442. * Define the input manager associated to the camera.
  12443. */
  12444. inputs: FreeCameraInputsManager;
  12445. /**
  12446. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12447. * Higher values reduce sensitivity.
  12448. */
  12449. /**
  12450. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12451. * Higher values reduce sensitivity.
  12452. */
  12453. angularSensibility: number;
  12454. /**
  12455. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12456. */
  12457. keysUp: number[];
  12458. /**
  12459. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12460. */
  12461. keysDown: number[];
  12462. /**
  12463. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12464. */
  12465. keysLeft: number[];
  12466. /**
  12467. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12468. */
  12469. keysRight: number[];
  12470. /**
  12471. * Event raised when the camera collide with a mesh in the scene.
  12472. */
  12473. onCollide: (collidedMesh: AbstractMesh) => void;
  12474. private _collider;
  12475. private _needMoveForGravity;
  12476. private _oldPosition;
  12477. private _diffPosition;
  12478. private _newPosition;
  12479. /** @hidden */
  12480. _localDirection: Vector3;
  12481. /** @hidden */
  12482. _transformedDirection: Vector3;
  12483. /**
  12484. * Instantiates a Free Camera.
  12485. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12486. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12487. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12488. * @param name Define the name of the camera in the scene
  12489. * @param position Define the start position of the camera in the scene
  12490. * @param scene Define the scene the camera belongs to
  12491. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12492. */
  12493. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12494. /**
  12495. * Attached controls to the current camera.
  12496. * @param element Defines the element the controls should be listened from
  12497. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12498. */
  12499. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12500. /**
  12501. * Detach the current controls from the camera.
  12502. * The camera will stop reacting to inputs.
  12503. * @param element Defines the element to stop listening the inputs from
  12504. */
  12505. detachControl(element: HTMLElement): void;
  12506. private _collisionMask;
  12507. /**
  12508. * Define a collision mask to limit the list of object the camera can collide with
  12509. */
  12510. collisionMask: number;
  12511. /** @hidden */
  12512. _collideWithWorld(displacement: Vector3): void;
  12513. private _onCollisionPositionChange;
  12514. /** @hidden */
  12515. _checkInputs(): void;
  12516. /** @hidden */
  12517. _decideIfNeedsToMove(): boolean;
  12518. /** @hidden */
  12519. _updatePosition(): void;
  12520. /**
  12521. * Destroy the camera and release the current resources hold by it.
  12522. */
  12523. dispose(): void;
  12524. /**
  12525. * Gets the current object class name.
  12526. * @return the class name
  12527. */
  12528. getClassName(): string;
  12529. }
  12530. }
  12531. declare module BABYLON {
  12532. /**
  12533. * Represents a gamepad control stick position
  12534. */
  12535. export class StickValues {
  12536. /**
  12537. * The x component of the control stick
  12538. */
  12539. x: number;
  12540. /**
  12541. * The y component of the control stick
  12542. */
  12543. y: number;
  12544. /**
  12545. * Initializes the gamepad x and y control stick values
  12546. * @param x The x component of the gamepad control stick value
  12547. * @param y The y component of the gamepad control stick value
  12548. */
  12549. constructor(
  12550. /**
  12551. * The x component of the control stick
  12552. */
  12553. x: number,
  12554. /**
  12555. * The y component of the control stick
  12556. */
  12557. y: number);
  12558. }
  12559. /**
  12560. * An interface which manages callbacks for gamepad button changes
  12561. */
  12562. export interface GamepadButtonChanges {
  12563. /**
  12564. * Called when a gamepad has been changed
  12565. */
  12566. changed: boolean;
  12567. /**
  12568. * Called when a gamepad press event has been triggered
  12569. */
  12570. pressChanged: boolean;
  12571. /**
  12572. * Called when a touch event has been triggered
  12573. */
  12574. touchChanged: boolean;
  12575. /**
  12576. * Called when a value has changed
  12577. */
  12578. valueChanged: boolean;
  12579. }
  12580. /**
  12581. * Represents a gamepad
  12582. */
  12583. export class Gamepad {
  12584. /**
  12585. * The id of the gamepad
  12586. */
  12587. id: string;
  12588. /**
  12589. * The index of the gamepad
  12590. */
  12591. index: number;
  12592. /**
  12593. * The browser gamepad
  12594. */
  12595. browserGamepad: any;
  12596. /**
  12597. * Specifies what type of gamepad this represents
  12598. */
  12599. type: number;
  12600. private _leftStick;
  12601. private _rightStick;
  12602. /** @hidden */
  12603. _isConnected: boolean;
  12604. private _leftStickAxisX;
  12605. private _leftStickAxisY;
  12606. private _rightStickAxisX;
  12607. private _rightStickAxisY;
  12608. /**
  12609. * Triggered when the left control stick has been changed
  12610. */
  12611. private _onleftstickchanged;
  12612. /**
  12613. * Triggered when the right control stick has been changed
  12614. */
  12615. private _onrightstickchanged;
  12616. /**
  12617. * Represents a gamepad controller
  12618. */
  12619. static GAMEPAD: number;
  12620. /**
  12621. * Represents a generic controller
  12622. */
  12623. static GENERIC: number;
  12624. /**
  12625. * Represents an XBox controller
  12626. */
  12627. static XBOX: number;
  12628. /**
  12629. * Represents a pose-enabled controller
  12630. */
  12631. static POSE_ENABLED: number;
  12632. /**
  12633. * Specifies whether the left control stick should be Y-inverted
  12634. */
  12635. protected _invertLeftStickY: boolean;
  12636. /**
  12637. * Specifies if the gamepad has been connected
  12638. */
  12639. readonly isConnected: boolean;
  12640. /**
  12641. * Initializes the gamepad
  12642. * @param id The id of the gamepad
  12643. * @param index The index of the gamepad
  12644. * @param browserGamepad The browser gamepad
  12645. * @param leftStickX The x component of the left joystick
  12646. * @param leftStickY The y component of the left joystick
  12647. * @param rightStickX The x component of the right joystick
  12648. * @param rightStickY The y component of the right joystick
  12649. */
  12650. constructor(
  12651. /**
  12652. * The id of the gamepad
  12653. */
  12654. id: string,
  12655. /**
  12656. * The index of the gamepad
  12657. */
  12658. index: number,
  12659. /**
  12660. * The browser gamepad
  12661. */
  12662. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12663. /**
  12664. * Callback triggered when the left joystick has changed
  12665. * @param callback
  12666. */
  12667. onleftstickchanged(callback: (values: StickValues) => void): void;
  12668. /**
  12669. * Callback triggered when the right joystick has changed
  12670. * @param callback
  12671. */
  12672. onrightstickchanged(callback: (values: StickValues) => void): void;
  12673. /**
  12674. * Gets the left joystick
  12675. */
  12676. /**
  12677. * Sets the left joystick values
  12678. */
  12679. leftStick: StickValues;
  12680. /**
  12681. * Gets the right joystick
  12682. */
  12683. /**
  12684. * Sets the right joystick value
  12685. */
  12686. rightStick: StickValues;
  12687. /**
  12688. * Updates the gamepad joystick positions
  12689. */
  12690. update(): void;
  12691. /**
  12692. * Disposes the gamepad
  12693. */
  12694. dispose(): void;
  12695. }
  12696. /**
  12697. * Represents a generic gamepad
  12698. */
  12699. export class GenericPad extends Gamepad {
  12700. private _buttons;
  12701. private _onbuttondown;
  12702. private _onbuttonup;
  12703. /**
  12704. * Observable triggered when a button has been pressed
  12705. */
  12706. onButtonDownObservable: Observable<number>;
  12707. /**
  12708. * Observable triggered when a button has been released
  12709. */
  12710. onButtonUpObservable: Observable<number>;
  12711. /**
  12712. * Callback triggered when a button has been pressed
  12713. * @param callback Called when a button has been pressed
  12714. */
  12715. onbuttondown(callback: (buttonPressed: number) => void): void;
  12716. /**
  12717. * Callback triggered when a button has been released
  12718. * @param callback Called when a button has been released
  12719. */
  12720. onbuttonup(callback: (buttonReleased: number) => void): void;
  12721. /**
  12722. * Initializes the generic gamepad
  12723. * @param id The id of the generic gamepad
  12724. * @param index The index of the generic gamepad
  12725. * @param browserGamepad The browser gamepad
  12726. */
  12727. constructor(id: string, index: number, browserGamepad: any);
  12728. private _setButtonValue;
  12729. /**
  12730. * Updates the generic gamepad
  12731. */
  12732. update(): void;
  12733. /**
  12734. * Disposes the generic gamepad
  12735. */
  12736. dispose(): void;
  12737. }
  12738. }
  12739. declare module BABYLON {
  12740. /**
  12741. * Defines the types of pose enabled controllers that are supported
  12742. */
  12743. export enum PoseEnabledControllerType {
  12744. /**
  12745. * HTC Vive
  12746. */
  12747. VIVE = 0,
  12748. /**
  12749. * Oculus Rift
  12750. */
  12751. OCULUS = 1,
  12752. /**
  12753. * Windows mixed reality
  12754. */
  12755. WINDOWS = 2,
  12756. /**
  12757. * Samsung gear VR
  12758. */
  12759. GEAR_VR = 3,
  12760. /**
  12761. * Google Daydream
  12762. */
  12763. DAYDREAM = 4,
  12764. /**
  12765. * Generic
  12766. */
  12767. GENERIC = 5
  12768. }
  12769. /**
  12770. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12771. */
  12772. export interface MutableGamepadButton {
  12773. /**
  12774. * Value of the button/trigger
  12775. */
  12776. value: number;
  12777. /**
  12778. * If the button/trigger is currently touched
  12779. */
  12780. touched: boolean;
  12781. /**
  12782. * If the button/trigger is currently pressed
  12783. */
  12784. pressed: boolean;
  12785. }
  12786. /**
  12787. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12788. * @hidden
  12789. */
  12790. export interface ExtendedGamepadButton extends GamepadButton {
  12791. /**
  12792. * If the button/trigger is currently pressed
  12793. */
  12794. readonly pressed: boolean;
  12795. /**
  12796. * If the button/trigger is currently touched
  12797. */
  12798. readonly touched: boolean;
  12799. /**
  12800. * Value of the button/trigger
  12801. */
  12802. readonly value: number;
  12803. }
  12804. /** @hidden */
  12805. export interface _GamePadFactory {
  12806. /**
  12807. * Returns wether or not the current gamepad can be created for this type of controller.
  12808. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12809. * @returns true if it can be created, otherwise false
  12810. */
  12811. canCreate(gamepadInfo: any): boolean;
  12812. /**
  12813. * Creates a new instance of the Gamepad.
  12814. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12815. * @returns the new gamepad instance
  12816. */
  12817. create(gamepadInfo: any): Gamepad;
  12818. }
  12819. /**
  12820. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12821. */
  12822. export class PoseEnabledControllerHelper {
  12823. /** @hidden */
  12824. static _ControllerFactories: _GamePadFactory[];
  12825. /** @hidden */
  12826. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12827. /**
  12828. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12829. * @param vrGamepad the gamepad to initialized
  12830. * @returns a vr controller of the type the gamepad identified as
  12831. */
  12832. static InitiateController(vrGamepad: any): Gamepad;
  12833. }
  12834. /**
  12835. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12836. */
  12837. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12838. private _deviceRoomPosition;
  12839. private _deviceRoomRotationQuaternion;
  12840. /**
  12841. * The device position in babylon space
  12842. */
  12843. devicePosition: Vector3;
  12844. /**
  12845. * The device rotation in babylon space
  12846. */
  12847. deviceRotationQuaternion: Quaternion;
  12848. /**
  12849. * The scale factor of the device in babylon space
  12850. */
  12851. deviceScaleFactor: number;
  12852. /**
  12853. * (Likely devicePosition should be used instead) The device position in its room space
  12854. */
  12855. position: Vector3;
  12856. /**
  12857. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12858. */
  12859. rotationQuaternion: Quaternion;
  12860. /**
  12861. * The type of controller (Eg. Windows mixed reality)
  12862. */
  12863. controllerType: PoseEnabledControllerType;
  12864. protected _calculatedPosition: Vector3;
  12865. private _calculatedRotation;
  12866. /**
  12867. * The raw pose from the device
  12868. */
  12869. rawPose: DevicePose;
  12870. private _trackPosition;
  12871. private _maxRotationDistFromHeadset;
  12872. private _draggedRoomRotation;
  12873. /**
  12874. * @hidden
  12875. */
  12876. _disableTrackPosition(fixedPosition: Vector3): void;
  12877. /**
  12878. * Internal, the mesh attached to the controller
  12879. * @hidden
  12880. */
  12881. _mesh: Nullable<AbstractMesh>;
  12882. private _poseControlledCamera;
  12883. private _leftHandSystemQuaternion;
  12884. /**
  12885. * Internal, matrix used to convert room space to babylon space
  12886. * @hidden
  12887. */
  12888. _deviceToWorld: Matrix;
  12889. /**
  12890. * Node to be used when casting a ray from the controller
  12891. * @hidden
  12892. */
  12893. _pointingPoseNode: Nullable<TransformNode>;
  12894. /**
  12895. * Name of the child mesh that can be used to cast a ray from the controller
  12896. */
  12897. static readonly POINTING_POSE: string;
  12898. /**
  12899. * Creates a new PoseEnabledController from a gamepad
  12900. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12901. */
  12902. constructor(browserGamepad: any);
  12903. private _workingMatrix;
  12904. /**
  12905. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12906. */
  12907. update(): void;
  12908. /**
  12909. * Updates only the pose device and mesh without doing any button event checking
  12910. */
  12911. protected _updatePoseAndMesh(): void;
  12912. /**
  12913. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12914. * @param poseData raw pose fromthe device
  12915. */
  12916. updateFromDevice(poseData: DevicePose): void;
  12917. /**
  12918. * @hidden
  12919. */
  12920. _meshAttachedObservable: Observable<AbstractMesh>;
  12921. /**
  12922. * Attaches a mesh to the controller
  12923. * @param mesh the mesh to be attached
  12924. */
  12925. attachToMesh(mesh: AbstractMesh): void;
  12926. /**
  12927. * Attaches the controllers mesh to a camera
  12928. * @param camera the camera the mesh should be attached to
  12929. */
  12930. attachToPoseControlledCamera(camera: TargetCamera): void;
  12931. /**
  12932. * Disposes of the controller
  12933. */
  12934. dispose(): void;
  12935. /**
  12936. * The mesh that is attached to the controller
  12937. */
  12938. readonly mesh: Nullable<AbstractMesh>;
  12939. /**
  12940. * Gets the ray of the controller in the direction the controller is pointing
  12941. * @param length the length the resulting ray should be
  12942. * @returns a ray in the direction the controller is pointing
  12943. */
  12944. getForwardRay(length?: number): Ray;
  12945. }
  12946. }
  12947. declare module BABYLON {
  12948. /**
  12949. * Defines the WebVRController object that represents controllers tracked in 3D space
  12950. */
  12951. export abstract class WebVRController extends PoseEnabledController {
  12952. /**
  12953. * Internal, the default controller model for the controller
  12954. */
  12955. protected _defaultModel: AbstractMesh;
  12956. /**
  12957. * Fired when the trigger state has changed
  12958. */
  12959. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12960. /**
  12961. * Fired when the main button state has changed
  12962. */
  12963. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12964. /**
  12965. * Fired when the secondary button state has changed
  12966. */
  12967. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12968. /**
  12969. * Fired when the pad state has changed
  12970. */
  12971. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12972. /**
  12973. * Fired when controllers stick values have changed
  12974. */
  12975. onPadValuesChangedObservable: Observable<StickValues>;
  12976. /**
  12977. * Array of button availible on the controller
  12978. */
  12979. protected _buttons: Array<MutableGamepadButton>;
  12980. private _onButtonStateChange;
  12981. /**
  12982. * Fired when a controller button's state has changed
  12983. * @param callback the callback containing the button that was modified
  12984. */
  12985. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12986. /**
  12987. * X and Y axis corrisponding to the controllers joystick
  12988. */
  12989. pad: StickValues;
  12990. /**
  12991. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12992. */
  12993. hand: string;
  12994. /**
  12995. * The default controller model for the controller
  12996. */
  12997. readonly defaultModel: AbstractMesh;
  12998. /**
  12999. * Creates a new WebVRController from a gamepad
  13000. * @param vrGamepad the gamepad that the WebVRController should be created from
  13001. */
  13002. constructor(vrGamepad: any);
  13003. /**
  13004. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13005. */
  13006. update(): void;
  13007. /**
  13008. * Function to be called when a button is modified
  13009. */
  13010. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13011. /**
  13012. * Loads a mesh and attaches it to the controller
  13013. * @param scene the scene the mesh should be added to
  13014. * @param meshLoaded callback for when the mesh has been loaded
  13015. */
  13016. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13017. private _setButtonValue;
  13018. private _changes;
  13019. private _checkChanges;
  13020. /**
  13021. * Disposes of th webVRCOntroller
  13022. */
  13023. dispose(): void;
  13024. }
  13025. }
  13026. declare module BABYLON {
  13027. /**
  13028. * The HemisphericLight simulates the ambient environment light,
  13029. * so the passed direction is the light reflection direction, not the incoming direction.
  13030. */
  13031. export class HemisphericLight extends Light {
  13032. /**
  13033. * The groundColor is the light in the opposite direction to the one specified during creation.
  13034. * 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.
  13035. */
  13036. groundColor: Color3;
  13037. /**
  13038. * The light reflection direction, not the incoming direction.
  13039. */
  13040. direction: Vector3;
  13041. /**
  13042. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13043. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13044. * The HemisphericLight can't cast shadows.
  13045. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13046. * @param name The friendly name of the light
  13047. * @param direction The direction of the light reflection
  13048. * @param scene The scene the light belongs to
  13049. */
  13050. constructor(name: string, direction: Vector3, scene: Scene);
  13051. protected _buildUniformLayout(): void;
  13052. /**
  13053. * Returns the string "HemisphericLight".
  13054. * @return The class name
  13055. */
  13056. getClassName(): string;
  13057. /**
  13058. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13059. * Returns the updated direction.
  13060. * @param target The target the direction should point to
  13061. * @return The computed direction
  13062. */
  13063. setDirectionToTarget(target: Vector3): Vector3;
  13064. /**
  13065. * Returns the shadow generator associated to the light.
  13066. * @returns Always null for hemispheric lights because it does not support shadows.
  13067. */
  13068. getShadowGenerator(): Nullable<IShadowGenerator>;
  13069. /**
  13070. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13071. * @param effect The effect to update
  13072. * @param lightIndex The index of the light in the effect to update
  13073. * @returns The hemispheric light
  13074. */
  13075. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13076. /**
  13077. * Computes the world matrix of the node
  13078. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13079. * @param useWasUpdatedFlag defines a reserved property
  13080. * @returns the world matrix
  13081. */
  13082. computeWorldMatrix(): Matrix;
  13083. /**
  13084. * Returns the integer 3.
  13085. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13086. */
  13087. getTypeID(): number;
  13088. /**
  13089. * Prepares the list of defines specific to the light type.
  13090. * @param defines the list of defines
  13091. * @param lightIndex defines the index of the light for the effect
  13092. */
  13093. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13094. }
  13095. }
  13096. declare module BABYLON {
  13097. /** @hidden */
  13098. export var vrMultiviewToSingleviewPixelShader: {
  13099. name: string;
  13100. shader: string;
  13101. };
  13102. }
  13103. declare module BABYLON {
  13104. /**
  13105. * Renders to multiple views with a single draw call
  13106. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13107. */
  13108. export class MultiviewRenderTarget extends RenderTargetTexture {
  13109. /**
  13110. * Creates a multiview render target
  13111. * @param scene scene used with the render target
  13112. * @param size the size of the render target (used for each view)
  13113. */
  13114. constructor(scene: Scene, size?: number | {
  13115. width: number;
  13116. height: number;
  13117. } | {
  13118. ratio: number;
  13119. });
  13120. /**
  13121. * @hidden
  13122. * @param faceIndex the face index, if its a cube texture
  13123. */
  13124. _bindFrameBuffer(faceIndex?: number): void;
  13125. /**
  13126. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13127. * @returns the view count
  13128. */
  13129. getViewCount(): number;
  13130. }
  13131. }
  13132. declare module BABYLON {
  13133. interface Engine {
  13134. /**
  13135. * Creates a new multiview render target
  13136. * @param width defines the width of the texture
  13137. * @param height defines the height of the texture
  13138. * @returns the created multiview texture
  13139. */
  13140. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13141. /**
  13142. * Binds a multiview framebuffer to be drawn to
  13143. * @param multiviewTexture texture to bind
  13144. */
  13145. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13146. }
  13147. interface Camera {
  13148. /**
  13149. * @hidden
  13150. * 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)
  13151. */
  13152. _useMultiviewToSingleView: boolean;
  13153. /**
  13154. * @hidden
  13155. * 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)
  13156. */
  13157. _multiviewTexture: Nullable<RenderTargetTexture>;
  13158. /**
  13159. * @hidden
  13160. * ensures the multiview texture of the camera exists and has the specified width/height
  13161. * @param width height to set on the multiview texture
  13162. * @param height width to set on the multiview texture
  13163. */
  13164. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13165. }
  13166. interface Scene {
  13167. /** @hidden */
  13168. _transformMatrixR: Matrix;
  13169. /** @hidden */
  13170. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13171. /** @hidden */
  13172. _createMultiviewUbo(): void;
  13173. /** @hidden */
  13174. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13175. /** @hidden */
  13176. _renderMultiviewToSingleView(camera: Camera): void;
  13177. }
  13178. }
  13179. declare module BABYLON {
  13180. /**
  13181. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13182. * This will not be used for webXR as it supports displaying texture arrays directly
  13183. */
  13184. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13185. /**
  13186. * Initializes a VRMultiviewToSingleview
  13187. * @param name name of the post process
  13188. * @param camera camera to be applied to
  13189. * @param scaleFactor scaling factor to the size of the output texture
  13190. */
  13191. constructor(name: string, camera: Camera, scaleFactor: number);
  13192. }
  13193. }
  13194. declare module BABYLON {
  13195. /**
  13196. * Defines the interface used by display changed events
  13197. */
  13198. interface IDisplayChangedEventArgs {
  13199. /** Gets the vrDisplay object (if any) */
  13200. vrDisplay: Nullable<any>;
  13201. /** Gets a boolean indicating if webVR is supported */
  13202. vrSupported: boolean;
  13203. }
  13204. interface Engine {
  13205. /** @hidden */
  13206. _vrDisplay: any;
  13207. /** @hidden */
  13208. _vrSupported: boolean;
  13209. /** @hidden */
  13210. _oldSize: Size;
  13211. /** @hidden */
  13212. _oldHardwareScaleFactor: number;
  13213. /** @hidden */
  13214. _vrExclusivePointerMode: boolean;
  13215. /** @hidden */
  13216. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13217. /** @hidden */
  13218. _onVRDisplayPointerRestricted: () => void;
  13219. /** @hidden */
  13220. _onVRDisplayPointerUnrestricted: () => void;
  13221. /** @hidden */
  13222. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13223. /** @hidden */
  13224. _onVrDisplayDisconnect: Nullable<() => void>;
  13225. /** @hidden */
  13226. _onVrDisplayPresentChange: Nullable<() => void>;
  13227. /**
  13228. * Observable signaled when VR display mode changes
  13229. */
  13230. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13231. /**
  13232. * Observable signaled when VR request present is complete
  13233. */
  13234. onVRRequestPresentComplete: Observable<boolean>;
  13235. /**
  13236. * Observable signaled when VR request present starts
  13237. */
  13238. onVRRequestPresentStart: Observable<Engine>;
  13239. /**
  13240. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13241. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13242. */
  13243. isInVRExclusivePointerMode: boolean;
  13244. /**
  13245. * Gets a boolean indicating if a webVR device was detected
  13246. * @returns true if a webVR device was detected
  13247. */
  13248. isVRDevicePresent(): boolean;
  13249. /**
  13250. * Gets the current webVR device
  13251. * @returns the current webVR device (or null)
  13252. */
  13253. getVRDevice(): any;
  13254. /**
  13255. * Initializes a webVR display and starts listening to display change events
  13256. * The onVRDisplayChangedObservable will be notified upon these changes
  13257. * @returns A promise containing a VRDisplay and if vr is supported
  13258. */
  13259. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13260. /** @hidden */
  13261. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13262. /**
  13263. * Call this function to switch to webVR mode
  13264. * Will do nothing if webVR is not supported or if there is no webVR device
  13265. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13266. */
  13267. enableVR(): void;
  13268. /** @hidden */
  13269. _onVRFullScreenTriggered(): void;
  13270. }
  13271. }
  13272. declare module BABYLON {
  13273. /**
  13274. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13275. * IMPORTANT!! The data is right-hand data.
  13276. * @export
  13277. * @interface DevicePose
  13278. */
  13279. export interface DevicePose {
  13280. /**
  13281. * The position of the device, values in array are [x,y,z].
  13282. */
  13283. readonly position: Nullable<Float32Array>;
  13284. /**
  13285. * The linearVelocity of the device, values in array are [x,y,z].
  13286. */
  13287. readonly linearVelocity: Nullable<Float32Array>;
  13288. /**
  13289. * The linearAcceleration of the device, values in array are [x,y,z].
  13290. */
  13291. readonly linearAcceleration: Nullable<Float32Array>;
  13292. /**
  13293. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13294. */
  13295. readonly orientation: Nullable<Float32Array>;
  13296. /**
  13297. * The angularVelocity of the device, values in array are [x,y,z].
  13298. */
  13299. readonly angularVelocity: Nullable<Float32Array>;
  13300. /**
  13301. * The angularAcceleration of the device, values in array are [x,y,z].
  13302. */
  13303. readonly angularAcceleration: Nullable<Float32Array>;
  13304. }
  13305. /**
  13306. * Interface representing a pose controlled object in Babylon.
  13307. * A pose controlled object has both regular pose values as well as pose values
  13308. * from an external device such as a VR head mounted display
  13309. */
  13310. export interface PoseControlled {
  13311. /**
  13312. * The position of the object in babylon space.
  13313. */
  13314. position: Vector3;
  13315. /**
  13316. * The rotation quaternion of the object in babylon space.
  13317. */
  13318. rotationQuaternion: Quaternion;
  13319. /**
  13320. * The position of the device in babylon space.
  13321. */
  13322. devicePosition?: Vector3;
  13323. /**
  13324. * The rotation quaternion of the device in babylon space.
  13325. */
  13326. deviceRotationQuaternion: Quaternion;
  13327. /**
  13328. * The raw pose coming from the device.
  13329. */
  13330. rawPose: Nullable<DevicePose>;
  13331. /**
  13332. * The scale of the device to be used when translating from device space to babylon space.
  13333. */
  13334. deviceScaleFactor: number;
  13335. /**
  13336. * Updates the poseControlled values based on the input device pose.
  13337. * @param poseData the pose data to update the object with
  13338. */
  13339. updateFromDevice(poseData: DevicePose): void;
  13340. }
  13341. /**
  13342. * Set of options to customize the webVRCamera
  13343. */
  13344. export interface WebVROptions {
  13345. /**
  13346. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13347. */
  13348. trackPosition?: boolean;
  13349. /**
  13350. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13351. */
  13352. positionScale?: number;
  13353. /**
  13354. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13355. */
  13356. displayName?: string;
  13357. /**
  13358. * Should the native controller meshes be initialized. (default: true)
  13359. */
  13360. controllerMeshes?: boolean;
  13361. /**
  13362. * Creating a default HemiLight only on controllers. (default: true)
  13363. */
  13364. defaultLightingOnControllers?: boolean;
  13365. /**
  13366. * If you don't want to use the default VR button of the helper. (default: false)
  13367. */
  13368. useCustomVRButton?: boolean;
  13369. /**
  13370. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13371. */
  13372. customVRButton?: HTMLButtonElement;
  13373. /**
  13374. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13375. */
  13376. rayLength?: number;
  13377. /**
  13378. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13379. */
  13380. defaultHeight?: number;
  13381. /**
  13382. * If multiview should be used if availible (default: false)
  13383. */
  13384. useMultiview?: boolean;
  13385. }
  13386. /**
  13387. * This represents a WebVR camera.
  13388. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13389. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13390. */
  13391. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13392. private webVROptions;
  13393. /**
  13394. * @hidden
  13395. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13396. */
  13397. _vrDevice: any;
  13398. /**
  13399. * The rawPose of the vrDevice.
  13400. */
  13401. rawPose: Nullable<DevicePose>;
  13402. private _onVREnabled;
  13403. private _specsVersion;
  13404. private _attached;
  13405. private _frameData;
  13406. protected _descendants: Array<Node>;
  13407. private _deviceRoomPosition;
  13408. /** @hidden */
  13409. _deviceRoomRotationQuaternion: Quaternion;
  13410. private _standingMatrix;
  13411. /**
  13412. * Represents device position in babylon space.
  13413. */
  13414. devicePosition: Vector3;
  13415. /**
  13416. * Represents device rotation in babylon space.
  13417. */
  13418. deviceRotationQuaternion: Quaternion;
  13419. /**
  13420. * The scale of the device to be used when translating from device space to babylon space.
  13421. */
  13422. deviceScaleFactor: number;
  13423. private _deviceToWorld;
  13424. private _worldToDevice;
  13425. /**
  13426. * References to the webVR controllers for the vrDevice.
  13427. */
  13428. controllers: Array<WebVRController>;
  13429. /**
  13430. * Emits an event when a controller is attached.
  13431. */
  13432. onControllersAttachedObservable: Observable<WebVRController[]>;
  13433. /**
  13434. * Emits an event when a controller's mesh has been loaded;
  13435. */
  13436. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13437. /**
  13438. * Emits an event when the HMD's pose has been updated.
  13439. */
  13440. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13441. private _poseSet;
  13442. /**
  13443. * If the rig cameras be used as parent instead of this camera.
  13444. */
  13445. rigParenting: boolean;
  13446. private _lightOnControllers;
  13447. private _defaultHeight?;
  13448. /**
  13449. * Instantiates a WebVRFreeCamera.
  13450. * @param name The name of the WebVRFreeCamera
  13451. * @param position The starting anchor position for the camera
  13452. * @param scene The scene the camera belongs to
  13453. * @param webVROptions a set of customizable options for the webVRCamera
  13454. */
  13455. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13456. /**
  13457. * Gets the device distance from the ground in meters.
  13458. * @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.
  13459. */
  13460. deviceDistanceToRoomGround(): number;
  13461. /**
  13462. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13463. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13464. */
  13465. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13466. /**
  13467. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13468. * @returns A promise with a boolean set to if the standing matrix is supported.
  13469. */
  13470. useStandingMatrixAsync(): Promise<boolean>;
  13471. /**
  13472. * Disposes the camera
  13473. */
  13474. dispose(): void;
  13475. /**
  13476. * Gets a vrController by name.
  13477. * @param name The name of the controller to retreive
  13478. * @returns the controller matching the name specified or null if not found
  13479. */
  13480. getControllerByName(name: string): Nullable<WebVRController>;
  13481. private _leftController;
  13482. /**
  13483. * The controller corrisponding to the users left hand.
  13484. */
  13485. readonly leftController: Nullable<WebVRController>;
  13486. private _rightController;
  13487. /**
  13488. * The controller corrisponding to the users right hand.
  13489. */
  13490. readonly rightController: Nullable<WebVRController>;
  13491. /**
  13492. * Casts a ray forward from the vrCamera's gaze.
  13493. * @param length Length of the ray (default: 100)
  13494. * @returns the ray corrisponding to the gaze
  13495. */
  13496. getForwardRay(length?: number): Ray;
  13497. /**
  13498. * @hidden
  13499. * Updates the camera based on device's frame data
  13500. */
  13501. _checkInputs(): void;
  13502. /**
  13503. * Updates the poseControlled values based on the input device pose.
  13504. * @param poseData Pose coming from the device
  13505. */
  13506. updateFromDevice(poseData: DevicePose): void;
  13507. private _htmlElementAttached;
  13508. private _detachIfAttached;
  13509. /**
  13510. * WebVR's attach control will start broadcasting frames to the device.
  13511. * Note that in certain browsers (chrome for example) this function must be called
  13512. * within a user-interaction callback. Example:
  13513. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13514. *
  13515. * @param element html element to attach the vrDevice to
  13516. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13517. */
  13518. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13519. /**
  13520. * Detaches the camera from the html element and disables VR
  13521. *
  13522. * @param element html element to detach from
  13523. */
  13524. detachControl(element: HTMLElement): void;
  13525. /**
  13526. * @returns the name of this class
  13527. */
  13528. getClassName(): string;
  13529. /**
  13530. * Calls resetPose on the vrDisplay
  13531. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13532. */
  13533. resetToCurrentRotation(): void;
  13534. /**
  13535. * @hidden
  13536. * Updates the rig cameras (left and right eye)
  13537. */
  13538. _updateRigCameras(): void;
  13539. private _workingVector;
  13540. private _oneVector;
  13541. private _workingMatrix;
  13542. private updateCacheCalled;
  13543. private _correctPositionIfNotTrackPosition;
  13544. /**
  13545. * @hidden
  13546. * Updates the cached values of the camera
  13547. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13548. */
  13549. _updateCache(ignoreParentClass?: boolean): void;
  13550. /**
  13551. * @hidden
  13552. * Get current device position in babylon world
  13553. */
  13554. _computeDevicePosition(): void;
  13555. /**
  13556. * Updates the current device position and rotation in the babylon world
  13557. */
  13558. update(): void;
  13559. /**
  13560. * @hidden
  13561. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13562. * @returns an identity matrix
  13563. */
  13564. _getViewMatrix(): Matrix;
  13565. private _tmpMatrix;
  13566. /**
  13567. * This function is called by the two RIG cameras.
  13568. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13569. * @hidden
  13570. */
  13571. _getWebVRViewMatrix(): Matrix;
  13572. /** @hidden */
  13573. _getWebVRProjectionMatrix(): Matrix;
  13574. private _onGamepadConnectedObserver;
  13575. private _onGamepadDisconnectedObserver;
  13576. private _updateCacheWhenTrackingDisabledObserver;
  13577. /**
  13578. * Initializes the controllers and their meshes
  13579. */
  13580. initControllers(): void;
  13581. }
  13582. }
  13583. declare module BABYLON {
  13584. /**
  13585. * Size options for a post process
  13586. */
  13587. export type PostProcessOptions = {
  13588. width: number;
  13589. height: number;
  13590. };
  13591. /**
  13592. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13593. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13594. */
  13595. export class PostProcess {
  13596. /** Name of the PostProcess. */
  13597. name: string;
  13598. /**
  13599. * Gets or sets the unique id of the post process
  13600. */
  13601. uniqueId: number;
  13602. /**
  13603. * Width of the texture to apply the post process on
  13604. */
  13605. width: number;
  13606. /**
  13607. * Height of the texture to apply the post process on
  13608. */
  13609. height: number;
  13610. /**
  13611. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13612. * @hidden
  13613. */
  13614. _outputTexture: Nullable<InternalTexture>;
  13615. /**
  13616. * Sampling mode used by the shader
  13617. * See https://doc.babylonjs.com/classes/3.1/texture
  13618. */
  13619. renderTargetSamplingMode: number;
  13620. /**
  13621. * Clear color to use when screen clearing
  13622. */
  13623. clearColor: Color4;
  13624. /**
  13625. * If the buffer needs to be cleared before applying the post process. (default: true)
  13626. * Should be set to false if shader will overwrite all previous pixels.
  13627. */
  13628. autoClear: boolean;
  13629. /**
  13630. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13631. */
  13632. alphaMode: number;
  13633. /**
  13634. * Sets the setAlphaBlendConstants of the babylon engine
  13635. */
  13636. alphaConstants: Color4;
  13637. /**
  13638. * Animations to be used for the post processing
  13639. */
  13640. animations: Animation[];
  13641. /**
  13642. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13643. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13644. */
  13645. enablePixelPerfectMode: boolean;
  13646. /**
  13647. * Force the postprocess to be applied without taking in account viewport
  13648. */
  13649. forceFullscreenViewport: boolean;
  13650. /**
  13651. * List of inspectable custom properties (used by the Inspector)
  13652. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13653. */
  13654. inspectableCustomProperties: IInspectable[];
  13655. /**
  13656. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13657. *
  13658. * | Value | Type | Description |
  13659. * | ----- | ----------------------------------- | ----------- |
  13660. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13661. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13662. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13663. *
  13664. */
  13665. scaleMode: number;
  13666. /**
  13667. * Force textures to be a power of two (default: false)
  13668. */
  13669. alwaysForcePOT: boolean;
  13670. private _samples;
  13671. /**
  13672. * Number of sample textures (default: 1)
  13673. */
  13674. samples: number;
  13675. /**
  13676. * Modify the scale of the post process to be the same as the viewport (default: false)
  13677. */
  13678. adaptScaleToCurrentViewport: boolean;
  13679. private _camera;
  13680. private _scene;
  13681. private _engine;
  13682. private _options;
  13683. private _reusable;
  13684. private _textureType;
  13685. /**
  13686. * Smart array of input and output textures for the post process.
  13687. * @hidden
  13688. */
  13689. _textures: SmartArray<InternalTexture>;
  13690. /**
  13691. * The index in _textures that corresponds to the output texture.
  13692. * @hidden
  13693. */
  13694. _currentRenderTextureInd: number;
  13695. private _effect;
  13696. private _samplers;
  13697. private _fragmentUrl;
  13698. private _vertexUrl;
  13699. private _parameters;
  13700. private _scaleRatio;
  13701. protected _indexParameters: any;
  13702. private _shareOutputWithPostProcess;
  13703. private _texelSize;
  13704. private _forcedOutputTexture;
  13705. /**
  13706. * Returns the fragment url or shader name used in the post process.
  13707. * @returns the fragment url or name in the shader store.
  13708. */
  13709. getEffectName(): string;
  13710. /**
  13711. * An event triggered when the postprocess is activated.
  13712. */
  13713. onActivateObservable: Observable<Camera>;
  13714. private _onActivateObserver;
  13715. /**
  13716. * A function that is added to the onActivateObservable
  13717. */
  13718. onActivate: Nullable<(camera: Camera) => void>;
  13719. /**
  13720. * An event triggered when the postprocess changes its size.
  13721. */
  13722. onSizeChangedObservable: Observable<PostProcess>;
  13723. private _onSizeChangedObserver;
  13724. /**
  13725. * A function that is added to the onSizeChangedObservable
  13726. */
  13727. onSizeChanged: (postProcess: PostProcess) => void;
  13728. /**
  13729. * An event triggered when the postprocess applies its effect.
  13730. */
  13731. onApplyObservable: Observable<Effect>;
  13732. private _onApplyObserver;
  13733. /**
  13734. * A function that is added to the onApplyObservable
  13735. */
  13736. onApply: (effect: Effect) => void;
  13737. /**
  13738. * An event triggered before rendering the postprocess
  13739. */
  13740. onBeforeRenderObservable: Observable<Effect>;
  13741. private _onBeforeRenderObserver;
  13742. /**
  13743. * A function that is added to the onBeforeRenderObservable
  13744. */
  13745. onBeforeRender: (effect: Effect) => void;
  13746. /**
  13747. * An event triggered after rendering the postprocess
  13748. */
  13749. onAfterRenderObservable: Observable<Effect>;
  13750. private _onAfterRenderObserver;
  13751. /**
  13752. * A function that is added to the onAfterRenderObservable
  13753. */
  13754. onAfterRender: (efect: Effect) => void;
  13755. /**
  13756. * 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
  13757. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13758. */
  13759. inputTexture: InternalTexture;
  13760. /**
  13761. * Gets the camera which post process is applied to.
  13762. * @returns The camera the post process is applied to.
  13763. */
  13764. getCamera(): Camera;
  13765. /**
  13766. * Gets the texel size of the postprocess.
  13767. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13768. */
  13769. readonly texelSize: Vector2;
  13770. /**
  13771. * Creates a new instance PostProcess
  13772. * @param name The name of the PostProcess.
  13773. * @param fragmentUrl The url of the fragment shader to be used.
  13774. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13775. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13776. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13777. * @param camera The camera to apply the render pass to.
  13778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13779. * @param engine The engine which the post process will be applied. (default: current engine)
  13780. * @param reusable If the post process can be reused on the same frame. (default: false)
  13781. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13782. * @param textureType Type of textures used when performing the post process. (default: 0)
  13783. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13784. * @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
  13785. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13786. */
  13787. constructor(
  13788. /** Name of the PostProcess. */
  13789. 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);
  13790. /**
  13791. * Gets a string idenfifying the name of the class
  13792. * @returns "PostProcess" string
  13793. */
  13794. getClassName(): string;
  13795. /**
  13796. * Gets the engine which this post process belongs to.
  13797. * @returns The engine the post process was enabled with.
  13798. */
  13799. getEngine(): Engine;
  13800. /**
  13801. * The effect that is created when initializing the post process.
  13802. * @returns The created effect corrisponding the the postprocess.
  13803. */
  13804. getEffect(): Effect;
  13805. /**
  13806. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13807. * @param postProcess The post process to share the output with.
  13808. * @returns This post process.
  13809. */
  13810. shareOutputWith(postProcess: PostProcess): PostProcess;
  13811. /**
  13812. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13813. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13814. */
  13815. useOwnOutput(): void;
  13816. /**
  13817. * Updates the effect with the current post process compile time values and recompiles the shader.
  13818. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13819. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13820. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13821. * @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
  13822. * @param onCompiled Called when the shader has been compiled.
  13823. * @param onError Called if there is an error when compiling a shader.
  13824. */
  13825. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13826. /**
  13827. * The post process is reusable if it can be used multiple times within one frame.
  13828. * @returns If the post process is reusable
  13829. */
  13830. isReusable(): boolean;
  13831. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13832. markTextureDirty(): void;
  13833. /**
  13834. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13835. * 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.
  13836. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13837. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13838. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13839. * @returns The target texture that was bound to be written to.
  13840. */
  13841. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13842. /**
  13843. * If the post process is supported.
  13844. */
  13845. readonly isSupported: boolean;
  13846. /**
  13847. * The aspect ratio of the output texture.
  13848. */
  13849. readonly aspectRatio: number;
  13850. /**
  13851. * Get a value indicating if the post-process is ready to be used
  13852. * @returns true if the post-process is ready (shader is compiled)
  13853. */
  13854. isReady(): boolean;
  13855. /**
  13856. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13857. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13858. */
  13859. apply(): Nullable<Effect>;
  13860. private _disposeTextures;
  13861. /**
  13862. * Disposes the post process.
  13863. * @param camera The camera to dispose the post process on.
  13864. */
  13865. dispose(camera?: Camera): void;
  13866. }
  13867. }
  13868. declare module BABYLON {
  13869. /**
  13870. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13871. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13872. */
  13873. export class PostProcessManager {
  13874. private _scene;
  13875. private _indexBuffer;
  13876. private _vertexBuffers;
  13877. /**
  13878. * Creates a new instance PostProcess
  13879. * @param scene The scene that the post process is associated with.
  13880. */
  13881. constructor(scene: Scene);
  13882. private _prepareBuffers;
  13883. private _buildIndexBuffer;
  13884. /**
  13885. * Rebuilds the vertex buffers of the manager.
  13886. * @hidden
  13887. */
  13888. _rebuild(): void;
  13889. /**
  13890. * Prepares a frame to be run through a post process.
  13891. * @param sourceTexture The input texture to the post procesess. (default: null)
  13892. * @param postProcesses An array of post processes to be run. (default: null)
  13893. * @returns True if the post processes were able to be run.
  13894. * @hidden
  13895. */
  13896. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13897. /**
  13898. * Manually render a set of post processes to a texture.
  13899. * @param postProcesses An array of post processes to be run.
  13900. * @param targetTexture The target texture to render to.
  13901. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13902. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13903. * @param lodLevel defines which lod of the texture to render to
  13904. */
  13905. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13906. /**
  13907. * Finalize the result of the output of the postprocesses.
  13908. * @param doNotPresent If true the result will not be displayed to the screen.
  13909. * @param targetTexture The target texture to render to.
  13910. * @param faceIndex The index of the face to bind the target texture to.
  13911. * @param postProcesses The array of post processes to render.
  13912. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13913. * @hidden
  13914. */
  13915. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13916. /**
  13917. * Disposes of the post process manager.
  13918. */
  13919. dispose(): void;
  13920. }
  13921. }
  13922. declare module BABYLON {
  13923. interface AbstractScene {
  13924. /**
  13925. * The list of layers (background and foreground) of the scene
  13926. */
  13927. layers: Array<Layer>;
  13928. }
  13929. /**
  13930. * Defines the layer scene component responsible to manage any layers
  13931. * in a given scene.
  13932. */
  13933. export class LayerSceneComponent implements ISceneComponent {
  13934. /**
  13935. * The component name helpfull to identify the component in the list of scene components.
  13936. */
  13937. readonly name: string;
  13938. /**
  13939. * The scene the component belongs to.
  13940. */
  13941. scene: Scene;
  13942. private _engine;
  13943. /**
  13944. * Creates a new instance of the component for the given scene
  13945. * @param scene Defines the scene to register the component in
  13946. */
  13947. constructor(scene: Scene);
  13948. /**
  13949. * Registers the component in a given scene
  13950. */
  13951. register(): void;
  13952. /**
  13953. * Rebuilds the elements related to this component in case of
  13954. * context lost for instance.
  13955. */
  13956. rebuild(): void;
  13957. /**
  13958. * Disposes the component and the associated ressources.
  13959. */
  13960. dispose(): void;
  13961. private _draw;
  13962. private _drawCameraPredicate;
  13963. private _drawCameraBackground;
  13964. private _drawCameraForeground;
  13965. private _drawRenderTargetPredicate;
  13966. private _drawRenderTargetBackground;
  13967. private _drawRenderTargetForeground;
  13968. }
  13969. }
  13970. declare module BABYLON {
  13971. /** @hidden */
  13972. export var layerPixelShader: {
  13973. name: string;
  13974. shader: string;
  13975. };
  13976. }
  13977. declare module BABYLON {
  13978. /** @hidden */
  13979. export var layerVertexShader: {
  13980. name: string;
  13981. shader: string;
  13982. };
  13983. }
  13984. declare module BABYLON {
  13985. /**
  13986. * This represents a full screen 2d layer.
  13987. * This can be useful to display a picture in the background of your scene for instance.
  13988. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13989. */
  13990. export class Layer {
  13991. /**
  13992. * Define the name of the layer.
  13993. */
  13994. name: string;
  13995. /**
  13996. * Define the texture the layer should display.
  13997. */
  13998. texture: Nullable<Texture>;
  13999. /**
  14000. * Is the layer in background or foreground.
  14001. */
  14002. isBackground: boolean;
  14003. /**
  14004. * Define the color of the layer (instead of texture).
  14005. */
  14006. color: Color4;
  14007. /**
  14008. * Define the scale of the layer in order to zoom in out of the texture.
  14009. */
  14010. scale: Vector2;
  14011. /**
  14012. * Define an offset for the layer in order to shift the texture.
  14013. */
  14014. offset: Vector2;
  14015. /**
  14016. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14017. */
  14018. alphaBlendingMode: number;
  14019. /**
  14020. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14021. * Alpha test will not mix with the background color in case of transparency.
  14022. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14023. */
  14024. alphaTest: boolean;
  14025. /**
  14026. * Define a mask to restrict the layer to only some of the scene cameras.
  14027. */
  14028. layerMask: number;
  14029. /**
  14030. * Define the list of render target the layer is visible into.
  14031. */
  14032. renderTargetTextures: RenderTargetTexture[];
  14033. /**
  14034. * Define if the layer is only used in renderTarget or if it also
  14035. * renders in the main frame buffer of the canvas.
  14036. */
  14037. renderOnlyInRenderTargetTextures: boolean;
  14038. private _scene;
  14039. private _vertexBuffers;
  14040. private _indexBuffer;
  14041. private _effect;
  14042. private _alphaTestEffect;
  14043. /**
  14044. * An event triggered when the layer is disposed.
  14045. */
  14046. onDisposeObservable: Observable<Layer>;
  14047. private _onDisposeObserver;
  14048. /**
  14049. * Back compatibility with callback before the onDisposeObservable existed.
  14050. * The set callback will be triggered when the layer has been disposed.
  14051. */
  14052. onDispose: () => void;
  14053. /**
  14054. * An event triggered before rendering the scene
  14055. */
  14056. onBeforeRenderObservable: Observable<Layer>;
  14057. private _onBeforeRenderObserver;
  14058. /**
  14059. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14060. * The set callback will be triggered just before rendering the layer.
  14061. */
  14062. onBeforeRender: () => void;
  14063. /**
  14064. * An event triggered after rendering the scene
  14065. */
  14066. onAfterRenderObservable: Observable<Layer>;
  14067. private _onAfterRenderObserver;
  14068. /**
  14069. * Back compatibility with callback before the onAfterRenderObservable existed.
  14070. * The set callback will be triggered just after rendering the layer.
  14071. */
  14072. onAfterRender: () => void;
  14073. /**
  14074. * Instantiates a new layer.
  14075. * This represents a full screen 2d layer.
  14076. * This can be useful to display a picture in the background of your scene for instance.
  14077. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14078. * @param name Define the name of the layer in the scene
  14079. * @param imgUrl Define the url of the texture to display in the layer
  14080. * @param scene Define the scene the layer belongs to
  14081. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14082. * @param color Defines a color for the layer
  14083. */
  14084. constructor(
  14085. /**
  14086. * Define the name of the layer.
  14087. */
  14088. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14089. private _createIndexBuffer;
  14090. /** @hidden */
  14091. _rebuild(): void;
  14092. /**
  14093. * Renders the layer in the scene.
  14094. */
  14095. render(): void;
  14096. /**
  14097. * Disposes and releases the associated ressources.
  14098. */
  14099. dispose(): void;
  14100. }
  14101. }
  14102. declare module BABYLON {
  14103. interface AbstractScene {
  14104. /**
  14105. * The list of procedural textures added to the scene
  14106. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14107. */
  14108. proceduralTextures: Array<ProceduralTexture>;
  14109. }
  14110. /**
  14111. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14112. * in a given scene.
  14113. */
  14114. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14115. /**
  14116. * The component name helpfull to identify the component in the list of scene components.
  14117. */
  14118. readonly name: string;
  14119. /**
  14120. * The scene the component belongs to.
  14121. */
  14122. scene: Scene;
  14123. /**
  14124. * Creates a new instance of the component for the given scene
  14125. * @param scene Defines the scene to register the component in
  14126. */
  14127. constructor(scene: Scene);
  14128. /**
  14129. * Registers the component in a given scene
  14130. */
  14131. register(): void;
  14132. /**
  14133. * Rebuilds the elements related to this component in case of
  14134. * context lost for instance.
  14135. */
  14136. rebuild(): void;
  14137. /**
  14138. * Disposes the component and the associated ressources.
  14139. */
  14140. dispose(): void;
  14141. private _beforeClear;
  14142. }
  14143. }
  14144. declare module BABYLON {
  14145. interface Engine {
  14146. /**
  14147. * Creates a new render target cube texture
  14148. * @param size defines the size of the texture
  14149. * @param options defines the options used to create the texture
  14150. * @returns a new render target cube texture stored in an InternalTexture
  14151. */
  14152. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14153. }
  14154. }
  14155. declare module BABYLON {
  14156. /** @hidden */
  14157. export var proceduralVertexShader: {
  14158. name: string;
  14159. shader: string;
  14160. };
  14161. }
  14162. declare module BABYLON {
  14163. /**
  14164. * 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.
  14165. * This is the base class of any Procedural texture and contains most of the shareable code.
  14166. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14167. */
  14168. export class ProceduralTexture extends Texture {
  14169. isCube: boolean;
  14170. /**
  14171. * Define if the texture is enabled or not (disabled texture will not render)
  14172. */
  14173. isEnabled: boolean;
  14174. /**
  14175. * Define if the texture must be cleared before rendering (default is true)
  14176. */
  14177. autoClear: boolean;
  14178. /**
  14179. * Callback called when the texture is generated
  14180. */
  14181. onGenerated: () => void;
  14182. /**
  14183. * Event raised when the texture is generated
  14184. */
  14185. onGeneratedObservable: Observable<ProceduralTexture>;
  14186. /** @hidden */
  14187. _generateMipMaps: boolean;
  14188. /** @hidden **/
  14189. _effect: Effect;
  14190. /** @hidden */
  14191. _textures: {
  14192. [key: string]: Texture;
  14193. };
  14194. private _size;
  14195. private _currentRefreshId;
  14196. private _refreshRate;
  14197. private _vertexBuffers;
  14198. private _indexBuffer;
  14199. private _uniforms;
  14200. private _samplers;
  14201. private _fragment;
  14202. private _floats;
  14203. private _ints;
  14204. private _floatsArrays;
  14205. private _colors3;
  14206. private _colors4;
  14207. private _vectors2;
  14208. private _vectors3;
  14209. private _matrices;
  14210. private _fallbackTexture;
  14211. private _fallbackTextureUsed;
  14212. private _engine;
  14213. private _cachedDefines;
  14214. private _contentUpdateId;
  14215. private _contentData;
  14216. /**
  14217. * Instantiates a new procedural texture.
  14218. * 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.
  14219. * This is the base class of any Procedural texture and contains most of the shareable code.
  14220. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14221. * @param name Define the name of the texture
  14222. * @param size Define the size of the texture to create
  14223. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14224. * @param scene Define the scene the texture belongs to
  14225. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14226. * @param generateMipMaps Define if the texture should creates mip maps or not
  14227. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14228. */
  14229. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14230. /**
  14231. * The effect that is created when initializing the post process.
  14232. * @returns The created effect corrisponding the the postprocess.
  14233. */
  14234. getEffect(): Effect;
  14235. /**
  14236. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14237. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14238. */
  14239. getContent(): Nullable<ArrayBufferView>;
  14240. private _createIndexBuffer;
  14241. /** @hidden */
  14242. _rebuild(): void;
  14243. /**
  14244. * Resets the texture in order to recreate its associated resources.
  14245. * This can be called in case of context loss
  14246. */
  14247. reset(): void;
  14248. protected _getDefines(): string;
  14249. /**
  14250. * Is the texture ready to be used ? (rendered at least once)
  14251. * @returns true if ready, otherwise, false.
  14252. */
  14253. isReady(): boolean;
  14254. /**
  14255. * Resets the refresh counter of the texture and start bak from scratch.
  14256. * Could be useful to regenerate the texture if it is setup to render only once.
  14257. */
  14258. resetRefreshCounter(): void;
  14259. /**
  14260. * Set the fragment shader to use in order to render the texture.
  14261. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14262. */
  14263. setFragment(fragment: any): void;
  14264. /**
  14265. * Define the refresh rate of the texture or the rendering frequency.
  14266. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14267. */
  14268. refreshRate: number;
  14269. /** @hidden */
  14270. _shouldRender(): boolean;
  14271. /**
  14272. * Get the size the texture is rendering at.
  14273. * @returns the size (texture is always squared)
  14274. */
  14275. getRenderSize(): number;
  14276. /**
  14277. * Resize the texture to new value.
  14278. * @param size Define the new size the texture should have
  14279. * @param generateMipMaps Define whether the new texture should create mip maps
  14280. */
  14281. resize(size: number, generateMipMaps: boolean): void;
  14282. private _checkUniform;
  14283. /**
  14284. * Set a texture in the shader program used to render.
  14285. * @param name Define the name of the uniform samplers as defined in the shader
  14286. * @param texture Define the texture to bind to this sampler
  14287. * @return the texture itself allowing "fluent" like uniform updates
  14288. */
  14289. setTexture(name: string, texture: Texture): ProceduralTexture;
  14290. /**
  14291. * Set a float in the shader.
  14292. * @param name Define the name of the uniform as defined in the shader
  14293. * @param value Define the value to give to the uniform
  14294. * @return the texture itself allowing "fluent" like uniform updates
  14295. */
  14296. setFloat(name: string, value: number): ProceduralTexture;
  14297. /**
  14298. * Set a int in the shader.
  14299. * @param name Define the name of the uniform as defined in the shader
  14300. * @param value Define the value to give to the uniform
  14301. * @return the texture itself allowing "fluent" like uniform updates
  14302. */
  14303. setInt(name: string, value: number): ProceduralTexture;
  14304. /**
  14305. * Set an array of floats in the shader.
  14306. * @param name Define the name of the uniform as defined in the shader
  14307. * @param value Define the value to give to the uniform
  14308. * @return the texture itself allowing "fluent" like uniform updates
  14309. */
  14310. setFloats(name: string, value: number[]): ProceduralTexture;
  14311. /**
  14312. * Set a vec3 in the shader from a Color3.
  14313. * @param name Define the name of the uniform as defined in the shader
  14314. * @param value Define the value to give to the uniform
  14315. * @return the texture itself allowing "fluent" like uniform updates
  14316. */
  14317. setColor3(name: string, value: Color3): ProceduralTexture;
  14318. /**
  14319. * Set a vec4 in the shader from a Color4.
  14320. * @param name Define the name of the uniform as defined in the shader
  14321. * @param value Define the value to give to the uniform
  14322. * @return the texture itself allowing "fluent" like uniform updates
  14323. */
  14324. setColor4(name: string, value: Color4): ProceduralTexture;
  14325. /**
  14326. * Set a vec2 in the shader from a Vector2.
  14327. * @param name Define the name of the uniform as defined in the shader
  14328. * @param value Define the value to give to the uniform
  14329. * @return the texture itself allowing "fluent" like uniform updates
  14330. */
  14331. setVector2(name: string, value: Vector2): ProceduralTexture;
  14332. /**
  14333. * Set a vec3 in the shader from a Vector3.
  14334. * @param name Define the name of the uniform as defined in the shader
  14335. * @param value Define the value to give to the uniform
  14336. * @return the texture itself allowing "fluent" like uniform updates
  14337. */
  14338. setVector3(name: string, value: Vector3): ProceduralTexture;
  14339. /**
  14340. * Set a mat4 in the shader from a MAtrix.
  14341. * @param name Define the name of the uniform as defined in the shader
  14342. * @param value Define the value to give to the uniform
  14343. * @return the texture itself allowing "fluent" like uniform updates
  14344. */
  14345. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14346. /**
  14347. * Render the texture to its associated render target.
  14348. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14349. */
  14350. render(useCameraPostProcess?: boolean): void;
  14351. /**
  14352. * Clone the texture.
  14353. * @returns the cloned texture
  14354. */
  14355. clone(): ProceduralTexture;
  14356. /**
  14357. * Dispose the texture and release its asoociated resources.
  14358. */
  14359. dispose(): void;
  14360. }
  14361. }
  14362. declare module BABYLON {
  14363. /**
  14364. * This represents the base class for particle system in Babylon.
  14365. * 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.
  14366. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14367. * @example https://doc.babylonjs.com/babylon101/particles
  14368. */
  14369. export class BaseParticleSystem {
  14370. /**
  14371. * Source color is added to the destination color without alpha affecting the result
  14372. */
  14373. static BLENDMODE_ONEONE: number;
  14374. /**
  14375. * Blend current color and particle color using particle’s alpha
  14376. */
  14377. static BLENDMODE_STANDARD: number;
  14378. /**
  14379. * Add current color and particle color multiplied by particle’s alpha
  14380. */
  14381. static BLENDMODE_ADD: number;
  14382. /**
  14383. * Multiply current color with particle color
  14384. */
  14385. static BLENDMODE_MULTIPLY: number;
  14386. /**
  14387. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14388. */
  14389. static BLENDMODE_MULTIPLYADD: number;
  14390. /**
  14391. * List of animations used by the particle system.
  14392. */
  14393. animations: Animation[];
  14394. /**
  14395. * The id of the Particle system.
  14396. */
  14397. id: string;
  14398. /**
  14399. * The friendly name of the Particle system.
  14400. */
  14401. name: string;
  14402. /**
  14403. * The rendering group used by the Particle system to chose when to render.
  14404. */
  14405. renderingGroupId: number;
  14406. /**
  14407. * The emitter represents the Mesh or position we are attaching the particle system to.
  14408. */
  14409. emitter: Nullable<AbstractMesh | Vector3>;
  14410. /**
  14411. * The maximum number of particles to emit per frame
  14412. */
  14413. emitRate: number;
  14414. /**
  14415. * If you want to launch only a few particles at once, that can be done, as well.
  14416. */
  14417. manualEmitCount: number;
  14418. /**
  14419. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14420. */
  14421. updateSpeed: number;
  14422. /**
  14423. * The amount of time the particle system is running (depends of the overall update speed).
  14424. */
  14425. targetStopDuration: number;
  14426. /**
  14427. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14428. */
  14429. disposeOnStop: boolean;
  14430. /**
  14431. * Minimum power of emitting particles.
  14432. */
  14433. minEmitPower: number;
  14434. /**
  14435. * Maximum power of emitting particles.
  14436. */
  14437. maxEmitPower: number;
  14438. /**
  14439. * Minimum life time of emitting particles.
  14440. */
  14441. minLifeTime: number;
  14442. /**
  14443. * Maximum life time of emitting particles.
  14444. */
  14445. maxLifeTime: number;
  14446. /**
  14447. * Minimum Size of emitting particles.
  14448. */
  14449. minSize: number;
  14450. /**
  14451. * Maximum Size of emitting particles.
  14452. */
  14453. maxSize: number;
  14454. /**
  14455. * Minimum scale of emitting particles on X axis.
  14456. */
  14457. minScaleX: number;
  14458. /**
  14459. * Maximum scale of emitting particles on X axis.
  14460. */
  14461. maxScaleX: number;
  14462. /**
  14463. * Minimum scale of emitting particles on Y axis.
  14464. */
  14465. minScaleY: number;
  14466. /**
  14467. * Maximum scale of emitting particles on Y axis.
  14468. */
  14469. maxScaleY: number;
  14470. /**
  14471. * Gets or sets the minimal initial rotation in radians.
  14472. */
  14473. minInitialRotation: number;
  14474. /**
  14475. * Gets or sets the maximal initial rotation in radians.
  14476. */
  14477. maxInitialRotation: number;
  14478. /**
  14479. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14480. */
  14481. minAngularSpeed: number;
  14482. /**
  14483. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14484. */
  14485. maxAngularSpeed: number;
  14486. /**
  14487. * The texture used to render each particle. (this can be a spritesheet)
  14488. */
  14489. particleTexture: Nullable<Texture>;
  14490. /**
  14491. * The layer mask we are rendering the particles through.
  14492. */
  14493. layerMask: number;
  14494. /**
  14495. * This can help using your own shader to render the particle system.
  14496. * The according effect will be created
  14497. */
  14498. customShader: any;
  14499. /**
  14500. * By default particle system starts as soon as they are created. This prevents the
  14501. * automatic start to happen and let you decide when to start emitting particles.
  14502. */
  14503. preventAutoStart: boolean;
  14504. private _noiseTexture;
  14505. /**
  14506. * Gets or sets a texture used to add random noise to particle positions
  14507. */
  14508. noiseTexture: Nullable<ProceduralTexture>;
  14509. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14510. noiseStrength: Vector3;
  14511. /**
  14512. * Callback triggered when the particle animation is ending.
  14513. */
  14514. onAnimationEnd: Nullable<() => void>;
  14515. /**
  14516. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14517. */
  14518. blendMode: number;
  14519. /**
  14520. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14521. * to override the particles.
  14522. */
  14523. forceDepthWrite: boolean;
  14524. /** 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 */
  14525. preWarmCycles: number;
  14526. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14527. preWarmStepOffset: number;
  14528. /**
  14529. * 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)
  14530. */
  14531. spriteCellChangeSpeed: number;
  14532. /**
  14533. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14534. */
  14535. startSpriteCellID: number;
  14536. /**
  14537. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14538. */
  14539. endSpriteCellID: number;
  14540. /**
  14541. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14542. */
  14543. spriteCellWidth: number;
  14544. /**
  14545. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14546. */
  14547. spriteCellHeight: number;
  14548. /**
  14549. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14550. */
  14551. spriteRandomStartCell: boolean;
  14552. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14553. translationPivot: Vector2;
  14554. /** @hidden */
  14555. protected _isAnimationSheetEnabled: boolean;
  14556. /**
  14557. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14558. */
  14559. beginAnimationOnStart: boolean;
  14560. /**
  14561. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14562. */
  14563. beginAnimationFrom: number;
  14564. /**
  14565. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14566. */
  14567. beginAnimationTo: number;
  14568. /**
  14569. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14570. */
  14571. beginAnimationLoop: boolean;
  14572. /**
  14573. * Gets or sets a world offset applied to all particles
  14574. */
  14575. worldOffset: Vector3;
  14576. /**
  14577. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14578. */
  14579. isAnimationSheetEnabled: boolean;
  14580. /**
  14581. * Get hosting scene
  14582. * @returns the scene
  14583. */
  14584. getScene(): Scene;
  14585. /**
  14586. * You can use gravity if you want to give an orientation to your particles.
  14587. */
  14588. gravity: Vector3;
  14589. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14590. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14591. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14592. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14593. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14594. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14595. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14596. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14597. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14598. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14599. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14600. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14601. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14602. /**
  14603. * Defines the delay in milliseconds before starting the system (0 by default)
  14604. */
  14605. startDelay: number;
  14606. /**
  14607. * Gets the current list of drag gradients.
  14608. * You must use addDragGradient and removeDragGradient to udpate this list
  14609. * @returns the list of drag gradients
  14610. */
  14611. getDragGradients(): Nullable<Array<FactorGradient>>;
  14612. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14613. limitVelocityDamping: number;
  14614. /**
  14615. * Gets the current list of limit velocity gradients.
  14616. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14617. * @returns the list of limit velocity gradients
  14618. */
  14619. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14620. /**
  14621. * Gets the current list of color gradients.
  14622. * You must use addColorGradient and removeColorGradient to udpate this list
  14623. * @returns the list of color gradients
  14624. */
  14625. getColorGradients(): Nullable<Array<ColorGradient>>;
  14626. /**
  14627. * Gets the current list of size gradients.
  14628. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14629. * @returns the list of size gradients
  14630. */
  14631. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14632. /**
  14633. * Gets the current list of color remap gradients.
  14634. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14635. * @returns the list of color remap gradients
  14636. */
  14637. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14638. /**
  14639. * Gets the current list of alpha remap gradients.
  14640. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14641. * @returns the list of alpha remap gradients
  14642. */
  14643. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14644. /**
  14645. * Gets the current list of life time gradients.
  14646. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14647. * @returns the list of life time gradients
  14648. */
  14649. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14650. /**
  14651. * Gets the current list of angular speed gradients.
  14652. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14653. * @returns the list of angular speed gradients
  14654. */
  14655. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14656. /**
  14657. * Gets the current list of velocity gradients.
  14658. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14659. * @returns the list of velocity gradients
  14660. */
  14661. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14662. /**
  14663. * Gets the current list of start size gradients.
  14664. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14665. * @returns the list of start size gradients
  14666. */
  14667. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14668. /**
  14669. * Gets the current list of emit rate gradients.
  14670. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14671. * @returns the list of emit rate gradients
  14672. */
  14673. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14674. /**
  14675. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14676. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14677. */
  14678. direction1: Vector3;
  14679. /**
  14680. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14681. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14682. */
  14683. direction2: Vector3;
  14684. /**
  14685. * 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.
  14686. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14687. */
  14688. minEmitBox: Vector3;
  14689. /**
  14690. * 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.
  14691. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14692. */
  14693. maxEmitBox: Vector3;
  14694. /**
  14695. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14696. */
  14697. color1: Color4;
  14698. /**
  14699. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14700. */
  14701. color2: Color4;
  14702. /**
  14703. * Color the particle will have at the end of its lifetime
  14704. */
  14705. colorDead: Color4;
  14706. /**
  14707. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14708. */
  14709. textureMask: Color4;
  14710. /**
  14711. * The particle emitter type defines the emitter used by the particle system.
  14712. * It can be for example box, sphere, or cone...
  14713. */
  14714. particleEmitterType: IParticleEmitterType;
  14715. /** @hidden */
  14716. _isSubEmitter: boolean;
  14717. /**
  14718. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14719. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14720. */
  14721. billboardMode: number;
  14722. protected _isBillboardBased: boolean;
  14723. /**
  14724. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14725. */
  14726. isBillboardBased: boolean;
  14727. /**
  14728. * The scene the particle system belongs to.
  14729. */
  14730. protected _scene: Scene;
  14731. /**
  14732. * Local cache of defines for image processing.
  14733. */
  14734. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14735. /**
  14736. * Default configuration related to image processing available in the standard Material.
  14737. */
  14738. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14739. /**
  14740. * Gets the image processing configuration used either in this material.
  14741. */
  14742. /**
  14743. * Sets the Default image processing configuration used either in the this material.
  14744. *
  14745. * If sets to null, the scene one is in use.
  14746. */
  14747. imageProcessingConfiguration: ImageProcessingConfiguration;
  14748. /**
  14749. * Attaches a new image processing configuration to the Standard Material.
  14750. * @param configuration
  14751. */
  14752. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14753. /** @hidden */
  14754. protected _reset(): void;
  14755. /** @hidden */
  14756. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14757. /**
  14758. * Instantiates a particle system.
  14759. * 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.
  14760. * @param name The name of the particle system
  14761. */
  14762. constructor(name: string);
  14763. /**
  14764. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14765. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14766. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14767. * @returns the emitter
  14768. */
  14769. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14770. /**
  14771. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14772. * @param radius The radius of the hemisphere to emit from
  14773. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14774. * @returns the emitter
  14775. */
  14776. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14777. /**
  14778. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14779. * @param radius The radius of the sphere to emit from
  14780. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14781. * @returns the emitter
  14782. */
  14783. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14784. /**
  14785. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14786. * @param radius The radius of the sphere to emit from
  14787. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14788. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14789. * @returns the emitter
  14790. */
  14791. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14792. /**
  14793. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14794. * @param radius The radius of the emission cylinder
  14795. * @param height The height of the emission cylinder
  14796. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14797. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14798. * @returns the emitter
  14799. */
  14800. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14801. /**
  14802. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14803. * @param radius The radius of the cylinder to emit from
  14804. * @param height The height of the emission cylinder
  14805. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14806. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14807. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14808. * @returns the emitter
  14809. */
  14810. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14811. /**
  14812. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14813. * @param radius The radius of the cone to emit from
  14814. * @param angle The base angle of the cone
  14815. * @returns the emitter
  14816. */
  14817. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14818. /**
  14819. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14820. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14821. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14822. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14823. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14824. * @returns the emitter
  14825. */
  14826. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14827. }
  14828. }
  14829. declare module BABYLON {
  14830. /**
  14831. * Type of sub emitter
  14832. */
  14833. export enum SubEmitterType {
  14834. /**
  14835. * Attached to the particle over it's lifetime
  14836. */
  14837. ATTACHED = 0,
  14838. /**
  14839. * Created when the particle dies
  14840. */
  14841. END = 1
  14842. }
  14843. /**
  14844. * Sub emitter class used to emit particles from an existing particle
  14845. */
  14846. export class SubEmitter {
  14847. /**
  14848. * the particle system to be used by the sub emitter
  14849. */
  14850. particleSystem: ParticleSystem;
  14851. /**
  14852. * Type of the submitter (Default: END)
  14853. */
  14854. type: SubEmitterType;
  14855. /**
  14856. * 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)
  14857. * Note: This only is supported when using an emitter of type Mesh
  14858. */
  14859. inheritDirection: boolean;
  14860. /**
  14861. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14862. */
  14863. inheritedVelocityAmount: number;
  14864. /**
  14865. * Creates a sub emitter
  14866. * @param particleSystem the particle system to be used by the sub emitter
  14867. */
  14868. constructor(
  14869. /**
  14870. * the particle system to be used by the sub emitter
  14871. */
  14872. particleSystem: ParticleSystem);
  14873. /**
  14874. * Clones the sub emitter
  14875. * @returns the cloned sub emitter
  14876. */
  14877. clone(): SubEmitter;
  14878. /**
  14879. * Serialize current object to a JSON object
  14880. * @returns the serialized object
  14881. */
  14882. serialize(): any;
  14883. /** @hidden */
  14884. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14885. /**
  14886. * Creates a new SubEmitter from a serialized JSON version
  14887. * @param serializationObject defines the JSON object to read from
  14888. * @param scene defines the hosting scene
  14889. * @param rootUrl defines the rootUrl for data loading
  14890. * @returns a new SubEmitter
  14891. */
  14892. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14893. /** Release associated resources */
  14894. dispose(): void;
  14895. }
  14896. }
  14897. declare module BABYLON {
  14898. /** @hidden */
  14899. export var clipPlaneFragmentDeclaration: {
  14900. name: string;
  14901. shader: string;
  14902. };
  14903. }
  14904. declare module BABYLON {
  14905. /** @hidden */
  14906. export var imageProcessingDeclaration: {
  14907. name: string;
  14908. shader: string;
  14909. };
  14910. }
  14911. declare module BABYLON {
  14912. /** @hidden */
  14913. export var imageProcessingFunctions: {
  14914. name: string;
  14915. shader: string;
  14916. };
  14917. }
  14918. declare module BABYLON {
  14919. /** @hidden */
  14920. export var clipPlaneFragment: {
  14921. name: string;
  14922. shader: string;
  14923. };
  14924. }
  14925. declare module BABYLON {
  14926. /** @hidden */
  14927. export var particlesPixelShader: {
  14928. name: string;
  14929. shader: string;
  14930. };
  14931. }
  14932. declare module BABYLON {
  14933. /** @hidden */
  14934. export var clipPlaneVertexDeclaration: {
  14935. name: string;
  14936. shader: string;
  14937. };
  14938. }
  14939. declare module BABYLON {
  14940. /** @hidden */
  14941. export var clipPlaneVertex: {
  14942. name: string;
  14943. shader: string;
  14944. };
  14945. }
  14946. declare module BABYLON {
  14947. /** @hidden */
  14948. export var particlesVertexShader: {
  14949. name: string;
  14950. shader: string;
  14951. };
  14952. }
  14953. declare module BABYLON {
  14954. /**
  14955. * This represents a particle system in Babylon.
  14956. * 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.
  14957. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14958. * @example https://doc.babylonjs.com/babylon101/particles
  14959. */
  14960. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14961. /**
  14962. * Billboard mode will only apply to Y axis
  14963. */
  14964. static readonly BILLBOARDMODE_Y: number;
  14965. /**
  14966. * Billboard mode will apply to all axes
  14967. */
  14968. static readonly BILLBOARDMODE_ALL: number;
  14969. /**
  14970. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14971. */
  14972. static readonly BILLBOARDMODE_STRETCHED: number;
  14973. /**
  14974. * This function can be defined to provide custom update for active particles.
  14975. * This function will be called instead of regular update (age, position, color, etc.).
  14976. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14977. */
  14978. updateFunction: (particles: Particle[]) => void;
  14979. private _emitterWorldMatrix;
  14980. /**
  14981. * This function can be defined to specify initial direction for every new particle.
  14982. * It by default use the emitterType defined function
  14983. */
  14984. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14985. /**
  14986. * This function can be defined to specify initial position for every new particle.
  14987. * It by default use the emitterType defined function
  14988. */
  14989. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14990. /**
  14991. * @hidden
  14992. */
  14993. _inheritedVelocityOffset: Vector3;
  14994. /**
  14995. * An event triggered when the system is disposed
  14996. */
  14997. onDisposeObservable: Observable<ParticleSystem>;
  14998. private _onDisposeObserver;
  14999. /**
  15000. * Sets a callback that will be triggered when the system is disposed
  15001. */
  15002. onDispose: () => void;
  15003. private _particles;
  15004. private _epsilon;
  15005. private _capacity;
  15006. private _stockParticles;
  15007. private _newPartsExcess;
  15008. private _vertexData;
  15009. private _vertexBuffer;
  15010. private _vertexBuffers;
  15011. private _spriteBuffer;
  15012. private _indexBuffer;
  15013. private _effect;
  15014. private _customEffect;
  15015. private _cachedDefines;
  15016. private _scaledColorStep;
  15017. private _colorDiff;
  15018. private _scaledDirection;
  15019. private _scaledGravity;
  15020. private _currentRenderId;
  15021. private _alive;
  15022. private _useInstancing;
  15023. private _started;
  15024. private _stopped;
  15025. private _actualFrame;
  15026. private _scaledUpdateSpeed;
  15027. private _vertexBufferSize;
  15028. /** @hidden */
  15029. _currentEmitRateGradient: Nullable<FactorGradient>;
  15030. /** @hidden */
  15031. _currentEmitRate1: number;
  15032. /** @hidden */
  15033. _currentEmitRate2: number;
  15034. /** @hidden */
  15035. _currentStartSizeGradient: Nullable<FactorGradient>;
  15036. /** @hidden */
  15037. _currentStartSize1: number;
  15038. /** @hidden */
  15039. _currentStartSize2: number;
  15040. private readonly _rawTextureWidth;
  15041. private _rampGradientsTexture;
  15042. private _useRampGradients;
  15043. /** Gets or sets a boolean indicating that ramp gradients must be used
  15044. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15045. */
  15046. useRampGradients: boolean;
  15047. /**
  15048. * 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.
  15049. * 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: [])
  15050. */
  15051. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15052. private _subEmitters;
  15053. /**
  15054. * @hidden
  15055. * If the particle systems emitter should be disposed when the particle system is disposed
  15056. */
  15057. _disposeEmitterOnDispose: boolean;
  15058. /**
  15059. * The current active Sub-systems, this property is used by the root particle system only.
  15060. */
  15061. activeSubSystems: Array<ParticleSystem>;
  15062. private _rootParticleSystem;
  15063. /**
  15064. * Gets the current list of active particles
  15065. */
  15066. readonly particles: Particle[];
  15067. /**
  15068. * Returns the string "ParticleSystem"
  15069. * @returns a string containing the class name
  15070. */
  15071. getClassName(): string;
  15072. /**
  15073. * Instantiates a particle system.
  15074. * 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.
  15075. * @param name The name of the particle system
  15076. * @param capacity The max number of particles alive at the same time
  15077. * @param scene The scene the particle system belongs to
  15078. * @param customEffect a custom effect used to change the way particles are rendered by default
  15079. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15080. * @param epsilon Offset used to render the particles
  15081. */
  15082. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15083. private _addFactorGradient;
  15084. private _removeFactorGradient;
  15085. /**
  15086. * Adds a new life time gradient
  15087. * @param gradient defines the gradient to use (between 0 and 1)
  15088. * @param factor defines the life time factor to affect to the specified gradient
  15089. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15090. * @returns the current particle system
  15091. */
  15092. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15093. /**
  15094. * Remove a specific life time gradient
  15095. * @param gradient defines the gradient to remove
  15096. * @returns the current particle system
  15097. */
  15098. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15099. /**
  15100. * Adds a new size gradient
  15101. * @param gradient defines the gradient to use (between 0 and 1)
  15102. * @param factor defines the size factor to affect to the specified gradient
  15103. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15104. * @returns the current particle system
  15105. */
  15106. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15107. /**
  15108. * Remove a specific size gradient
  15109. * @param gradient defines the gradient to remove
  15110. * @returns the current particle system
  15111. */
  15112. removeSizeGradient(gradient: number): IParticleSystem;
  15113. /**
  15114. * Adds a new color remap gradient
  15115. * @param gradient defines the gradient to use (between 0 and 1)
  15116. * @param min defines the color remap minimal range
  15117. * @param max defines the color remap maximal range
  15118. * @returns the current particle system
  15119. */
  15120. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15121. /**
  15122. * Remove a specific color remap gradient
  15123. * @param gradient defines the gradient to remove
  15124. * @returns the current particle system
  15125. */
  15126. removeColorRemapGradient(gradient: number): IParticleSystem;
  15127. /**
  15128. * Adds a new alpha remap gradient
  15129. * @param gradient defines the gradient to use (between 0 and 1)
  15130. * @param min defines the alpha remap minimal range
  15131. * @param max defines the alpha remap maximal range
  15132. * @returns the current particle system
  15133. */
  15134. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15135. /**
  15136. * Remove a specific alpha remap gradient
  15137. * @param gradient defines the gradient to remove
  15138. * @returns the current particle system
  15139. */
  15140. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15141. /**
  15142. * Adds a new angular speed gradient
  15143. * @param gradient defines the gradient to use (between 0 and 1)
  15144. * @param factor defines the angular speed to affect to the specified gradient
  15145. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15146. * @returns the current particle system
  15147. */
  15148. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15149. /**
  15150. * Remove a specific angular speed gradient
  15151. * @param gradient defines the gradient to remove
  15152. * @returns the current particle system
  15153. */
  15154. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15155. /**
  15156. * Adds a new velocity gradient
  15157. * @param gradient defines the gradient to use (between 0 and 1)
  15158. * @param factor defines the velocity to affect to the specified gradient
  15159. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15160. * @returns the current particle system
  15161. */
  15162. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15163. /**
  15164. * Remove a specific velocity gradient
  15165. * @param gradient defines the gradient to remove
  15166. * @returns the current particle system
  15167. */
  15168. removeVelocityGradient(gradient: number): IParticleSystem;
  15169. /**
  15170. * Adds a new limit velocity gradient
  15171. * @param gradient defines the gradient to use (between 0 and 1)
  15172. * @param factor defines the limit velocity value to affect to the specified gradient
  15173. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15174. * @returns the current particle system
  15175. */
  15176. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15177. /**
  15178. * Remove a specific limit velocity gradient
  15179. * @param gradient defines the gradient to remove
  15180. * @returns the current particle system
  15181. */
  15182. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15183. /**
  15184. * Adds a new drag gradient
  15185. * @param gradient defines the gradient to use (between 0 and 1)
  15186. * @param factor defines the drag value to affect to the specified gradient
  15187. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15188. * @returns the current particle system
  15189. */
  15190. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15191. /**
  15192. * Remove a specific drag gradient
  15193. * @param gradient defines the gradient to remove
  15194. * @returns the current particle system
  15195. */
  15196. removeDragGradient(gradient: number): IParticleSystem;
  15197. /**
  15198. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15199. * @param gradient defines the gradient to use (between 0 and 1)
  15200. * @param factor defines the emit rate value to affect to the specified gradient
  15201. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15202. * @returns the current particle system
  15203. */
  15204. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15205. /**
  15206. * Remove a specific emit rate gradient
  15207. * @param gradient defines the gradient to remove
  15208. * @returns the current particle system
  15209. */
  15210. removeEmitRateGradient(gradient: number): IParticleSystem;
  15211. /**
  15212. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15213. * @param gradient defines the gradient to use (between 0 and 1)
  15214. * @param factor defines the start size value to affect to the specified gradient
  15215. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15216. * @returns the current particle system
  15217. */
  15218. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15219. /**
  15220. * Remove a specific start size gradient
  15221. * @param gradient defines the gradient to remove
  15222. * @returns the current particle system
  15223. */
  15224. removeStartSizeGradient(gradient: number): IParticleSystem;
  15225. private _createRampGradientTexture;
  15226. /**
  15227. * Gets the current list of ramp gradients.
  15228. * You must use addRampGradient and removeRampGradient to udpate this list
  15229. * @returns the list of ramp gradients
  15230. */
  15231. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15232. /**
  15233. * Adds a new ramp gradient used to remap particle colors
  15234. * @param gradient defines the gradient to use (between 0 and 1)
  15235. * @param color defines the color to affect to the specified gradient
  15236. * @returns the current particle system
  15237. */
  15238. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15239. /**
  15240. * Remove a specific ramp gradient
  15241. * @param gradient defines the gradient to remove
  15242. * @returns the current particle system
  15243. */
  15244. removeRampGradient(gradient: number): ParticleSystem;
  15245. /**
  15246. * Adds a new color gradient
  15247. * @param gradient defines the gradient to use (between 0 and 1)
  15248. * @param color1 defines the color to affect to the specified gradient
  15249. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15250. * @returns this particle system
  15251. */
  15252. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15253. /**
  15254. * Remove a specific color gradient
  15255. * @param gradient defines the gradient to remove
  15256. * @returns this particle system
  15257. */
  15258. removeColorGradient(gradient: number): IParticleSystem;
  15259. private _fetchR;
  15260. protected _reset(): void;
  15261. private _resetEffect;
  15262. private _createVertexBuffers;
  15263. private _createIndexBuffer;
  15264. /**
  15265. * Gets the maximum number of particles active at the same time.
  15266. * @returns The max number of active particles.
  15267. */
  15268. getCapacity(): number;
  15269. /**
  15270. * Gets whether there are still active particles in the system.
  15271. * @returns True if it is alive, otherwise false.
  15272. */
  15273. isAlive(): boolean;
  15274. /**
  15275. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15276. * @returns True if it has been started, otherwise false.
  15277. */
  15278. isStarted(): boolean;
  15279. private _prepareSubEmitterInternalArray;
  15280. /**
  15281. * Starts the particle system and begins to emit
  15282. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15283. */
  15284. start(delay?: number): void;
  15285. /**
  15286. * Stops the particle system.
  15287. * @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.
  15288. */
  15289. stop(stopSubEmitters?: boolean): void;
  15290. /**
  15291. * Remove all active particles
  15292. */
  15293. reset(): void;
  15294. /**
  15295. * @hidden (for internal use only)
  15296. */
  15297. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15298. /**
  15299. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15300. * Its lifetime will start back at 0.
  15301. */
  15302. recycleParticle: (particle: Particle) => void;
  15303. private _stopSubEmitters;
  15304. private _createParticle;
  15305. private _removeFromRoot;
  15306. private _emitFromParticle;
  15307. private _update;
  15308. /** @hidden */
  15309. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15310. /** @hidden */
  15311. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15312. /** @hidden */
  15313. private _getEffect;
  15314. /**
  15315. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15316. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15317. */
  15318. animate(preWarmOnly?: boolean): void;
  15319. private _appendParticleVertices;
  15320. /**
  15321. * Rebuilds the particle system.
  15322. */
  15323. rebuild(): void;
  15324. /**
  15325. * Is this system ready to be used/rendered
  15326. * @return true if the system is ready
  15327. */
  15328. isReady(): boolean;
  15329. private _render;
  15330. /**
  15331. * Renders the particle system in its current state.
  15332. * @returns the current number of particles
  15333. */
  15334. render(): number;
  15335. /**
  15336. * Disposes the particle system and free the associated resources
  15337. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15338. */
  15339. dispose(disposeTexture?: boolean): void;
  15340. /**
  15341. * Clones the particle system.
  15342. * @param name The name of the cloned object
  15343. * @param newEmitter The new emitter to use
  15344. * @returns the cloned particle system
  15345. */
  15346. clone(name: string, newEmitter: any): ParticleSystem;
  15347. /**
  15348. * Serializes the particle system to a JSON object.
  15349. * @returns the JSON object
  15350. */
  15351. serialize(): any;
  15352. /** @hidden */
  15353. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15354. /** @hidden */
  15355. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15356. /**
  15357. * Parses a JSON object to create a particle system.
  15358. * @param parsedParticleSystem The JSON object to parse
  15359. * @param scene The scene to create the particle system in
  15360. * @param rootUrl The root url to use to load external dependencies like texture
  15361. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15362. * @returns the Parsed particle system
  15363. */
  15364. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15365. }
  15366. }
  15367. declare module BABYLON {
  15368. /**
  15369. * A particle represents one of the element emitted by a particle system.
  15370. * This is mainly define by its coordinates, direction, velocity and age.
  15371. */
  15372. export class Particle {
  15373. /**
  15374. * The particle system the particle belongs to.
  15375. */
  15376. particleSystem: ParticleSystem;
  15377. private static _Count;
  15378. /**
  15379. * Unique ID of the particle
  15380. */
  15381. id: number;
  15382. /**
  15383. * The world position of the particle in the scene.
  15384. */
  15385. position: Vector3;
  15386. /**
  15387. * The world direction of the particle in the scene.
  15388. */
  15389. direction: Vector3;
  15390. /**
  15391. * The color of the particle.
  15392. */
  15393. color: Color4;
  15394. /**
  15395. * The color change of the particle per step.
  15396. */
  15397. colorStep: Color4;
  15398. /**
  15399. * Defines how long will the life of the particle be.
  15400. */
  15401. lifeTime: number;
  15402. /**
  15403. * The current age of the particle.
  15404. */
  15405. age: number;
  15406. /**
  15407. * The current size of the particle.
  15408. */
  15409. size: number;
  15410. /**
  15411. * The current scale of the particle.
  15412. */
  15413. scale: Vector2;
  15414. /**
  15415. * The current angle of the particle.
  15416. */
  15417. angle: number;
  15418. /**
  15419. * Defines how fast is the angle changing.
  15420. */
  15421. angularSpeed: number;
  15422. /**
  15423. * Defines the cell index used by the particle to be rendered from a sprite.
  15424. */
  15425. cellIndex: number;
  15426. /**
  15427. * The information required to support color remapping
  15428. */
  15429. remapData: Vector4;
  15430. /** @hidden */
  15431. _randomCellOffset?: number;
  15432. /** @hidden */
  15433. _initialDirection: Nullable<Vector3>;
  15434. /** @hidden */
  15435. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15436. /** @hidden */
  15437. _initialStartSpriteCellID: number;
  15438. /** @hidden */
  15439. _initialEndSpriteCellID: number;
  15440. /** @hidden */
  15441. _currentColorGradient: Nullable<ColorGradient>;
  15442. /** @hidden */
  15443. _currentColor1: Color4;
  15444. /** @hidden */
  15445. _currentColor2: Color4;
  15446. /** @hidden */
  15447. _currentSizeGradient: Nullable<FactorGradient>;
  15448. /** @hidden */
  15449. _currentSize1: number;
  15450. /** @hidden */
  15451. _currentSize2: number;
  15452. /** @hidden */
  15453. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15454. /** @hidden */
  15455. _currentAngularSpeed1: number;
  15456. /** @hidden */
  15457. _currentAngularSpeed2: number;
  15458. /** @hidden */
  15459. _currentVelocityGradient: Nullable<FactorGradient>;
  15460. /** @hidden */
  15461. _currentVelocity1: number;
  15462. /** @hidden */
  15463. _currentVelocity2: number;
  15464. /** @hidden */
  15465. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15466. /** @hidden */
  15467. _currentLimitVelocity1: number;
  15468. /** @hidden */
  15469. _currentLimitVelocity2: number;
  15470. /** @hidden */
  15471. _currentDragGradient: Nullable<FactorGradient>;
  15472. /** @hidden */
  15473. _currentDrag1: number;
  15474. /** @hidden */
  15475. _currentDrag2: number;
  15476. /** @hidden */
  15477. _randomNoiseCoordinates1: Vector3;
  15478. /** @hidden */
  15479. _randomNoiseCoordinates2: Vector3;
  15480. /**
  15481. * Creates a new instance Particle
  15482. * @param particleSystem the particle system the particle belongs to
  15483. */
  15484. constructor(
  15485. /**
  15486. * The particle system the particle belongs to.
  15487. */
  15488. particleSystem: ParticleSystem);
  15489. private updateCellInfoFromSystem;
  15490. /**
  15491. * Defines how the sprite cell index is updated for the particle
  15492. */
  15493. updateCellIndex(): void;
  15494. /** @hidden */
  15495. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15496. /** @hidden */
  15497. _inheritParticleInfoToSubEmitters(): void;
  15498. /** @hidden */
  15499. _reset(): void;
  15500. /**
  15501. * Copy the properties of particle to another one.
  15502. * @param other the particle to copy the information to.
  15503. */
  15504. copyTo(other: Particle): void;
  15505. }
  15506. }
  15507. declare module BABYLON {
  15508. /**
  15509. * Particle emitter represents a volume emitting particles.
  15510. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15511. */
  15512. export interface IParticleEmitterType {
  15513. /**
  15514. * Called by the particle System when the direction is computed for the created particle.
  15515. * @param worldMatrix is the world matrix of the particle system
  15516. * @param directionToUpdate is the direction vector to update with the result
  15517. * @param particle is the particle we are computed the direction for
  15518. */
  15519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15520. /**
  15521. * Called by the particle System when the position is computed for the created particle.
  15522. * @param worldMatrix is the world matrix of the particle system
  15523. * @param positionToUpdate is the position vector to update with the result
  15524. * @param particle is the particle we are computed the position for
  15525. */
  15526. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15527. /**
  15528. * Clones the current emitter and returns a copy of it
  15529. * @returns the new emitter
  15530. */
  15531. clone(): IParticleEmitterType;
  15532. /**
  15533. * Called by the GPUParticleSystem to setup the update shader
  15534. * @param effect defines the update shader
  15535. */
  15536. applyToShader(effect: Effect): void;
  15537. /**
  15538. * Returns a string to use to update the GPU particles update shader
  15539. * @returns the effect defines string
  15540. */
  15541. getEffectDefines(): string;
  15542. /**
  15543. * Returns a string representing the class name
  15544. * @returns a string containing the class name
  15545. */
  15546. getClassName(): string;
  15547. /**
  15548. * Serializes the particle system to a JSON object.
  15549. * @returns the JSON object
  15550. */
  15551. serialize(): any;
  15552. /**
  15553. * Parse properties from a JSON object
  15554. * @param serializationObject defines the JSON object
  15555. */
  15556. parse(serializationObject: any): void;
  15557. }
  15558. }
  15559. declare module BABYLON {
  15560. /**
  15561. * Particle emitter emitting particles from the inside of a box.
  15562. * It emits the particles randomly between 2 given directions.
  15563. */
  15564. export class BoxParticleEmitter implements IParticleEmitterType {
  15565. /**
  15566. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15567. */
  15568. direction1: Vector3;
  15569. /**
  15570. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15571. */
  15572. direction2: Vector3;
  15573. /**
  15574. * 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.
  15575. */
  15576. minEmitBox: Vector3;
  15577. /**
  15578. * 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.
  15579. */
  15580. maxEmitBox: Vector3;
  15581. /**
  15582. * Creates a new instance BoxParticleEmitter
  15583. */
  15584. constructor();
  15585. /**
  15586. * Called by the particle System when the direction is computed for the created particle.
  15587. * @param worldMatrix is the world matrix of the particle system
  15588. * @param directionToUpdate is the direction vector to update with the result
  15589. * @param particle is the particle we are computed the direction for
  15590. */
  15591. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15592. /**
  15593. * Called by the particle System when the position is computed for the created particle.
  15594. * @param worldMatrix is the world matrix of the particle system
  15595. * @param positionToUpdate is the position vector to update with the result
  15596. * @param particle is the particle we are computed the position for
  15597. */
  15598. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15599. /**
  15600. * Clones the current emitter and returns a copy of it
  15601. * @returns the new emitter
  15602. */
  15603. clone(): BoxParticleEmitter;
  15604. /**
  15605. * Called by the GPUParticleSystem to setup the update shader
  15606. * @param effect defines the update shader
  15607. */
  15608. applyToShader(effect: Effect): void;
  15609. /**
  15610. * Returns a string to use to update the GPU particles update shader
  15611. * @returns a string containng the defines string
  15612. */
  15613. getEffectDefines(): string;
  15614. /**
  15615. * Returns the string "BoxParticleEmitter"
  15616. * @returns a string containing the class name
  15617. */
  15618. getClassName(): string;
  15619. /**
  15620. * Serializes the particle system to a JSON object.
  15621. * @returns the JSON object
  15622. */
  15623. serialize(): any;
  15624. /**
  15625. * Parse properties from a JSON object
  15626. * @param serializationObject defines the JSON object
  15627. */
  15628. parse(serializationObject: any): void;
  15629. }
  15630. }
  15631. declare module BABYLON {
  15632. /**
  15633. * Particle emitter emitting particles from the inside of a cone.
  15634. * It emits the particles alongside the cone volume from the base to the particle.
  15635. * The emission direction might be randomized.
  15636. */
  15637. export class ConeParticleEmitter implements IParticleEmitterType {
  15638. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15639. directionRandomizer: number;
  15640. private _radius;
  15641. private _angle;
  15642. private _height;
  15643. /**
  15644. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15645. */
  15646. radiusRange: number;
  15647. /**
  15648. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15649. */
  15650. heightRange: number;
  15651. /**
  15652. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15653. */
  15654. emitFromSpawnPointOnly: boolean;
  15655. /**
  15656. * Gets or sets the radius of the emission cone
  15657. */
  15658. radius: number;
  15659. /**
  15660. * Gets or sets the angle of the emission cone
  15661. */
  15662. angle: number;
  15663. private _buildHeight;
  15664. /**
  15665. * Creates a new instance ConeParticleEmitter
  15666. * @param radius the radius of the emission cone (1 by default)
  15667. * @param angle the cone base angle (PI by default)
  15668. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15669. */
  15670. constructor(radius?: number, angle?: number,
  15671. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15672. directionRandomizer?: number);
  15673. /**
  15674. * Called by the particle System when the direction is computed for the created particle.
  15675. * @param worldMatrix is the world matrix of the particle system
  15676. * @param directionToUpdate is the direction vector to update with the result
  15677. * @param particle is the particle we are computed the direction for
  15678. */
  15679. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15680. /**
  15681. * Called by the particle System when the position is computed for the created particle.
  15682. * @param worldMatrix is the world matrix of the particle system
  15683. * @param positionToUpdate is the position vector to update with the result
  15684. * @param particle is the particle we are computed the position for
  15685. */
  15686. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15687. /**
  15688. * Clones the current emitter and returns a copy of it
  15689. * @returns the new emitter
  15690. */
  15691. clone(): ConeParticleEmitter;
  15692. /**
  15693. * Called by the GPUParticleSystem to setup the update shader
  15694. * @param effect defines the update shader
  15695. */
  15696. applyToShader(effect: Effect): void;
  15697. /**
  15698. * Returns a string to use to update the GPU particles update shader
  15699. * @returns a string containng the defines string
  15700. */
  15701. getEffectDefines(): string;
  15702. /**
  15703. * Returns the string "ConeParticleEmitter"
  15704. * @returns a string containing the class name
  15705. */
  15706. getClassName(): string;
  15707. /**
  15708. * Serializes the particle system to a JSON object.
  15709. * @returns the JSON object
  15710. */
  15711. serialize(): any;
  15712. /**
  15713. * Parse properties from a JSON object
  15714. * @param serializationObject defines the JSON object
  15715. */
  15716. parse(serializationObject: any): void;
  15717. }
  15718. }
  15719. declare module BABYLON {
  15720. /**
  15721. * Particle emitter emitting particles from the inside of a cylinder.
  15722. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15723. */
  15724. export class CylinderParticleEmitter implements IParticleEmitterType {
  15725. /**
  15726. * The radius of the emission cylinder.
  15727. */
  15728. radius: number;
  15729. /**
  15730. * The height of the emission cylinder.
  15731. */
  15732. height: number;
  15733. /**
  15734. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15735. */
  15736. radiusRange: number;
  15737. /**
  15738. * How much to randomize the particle direction [0-1].
  15739. */
  15740. directionRandomizer: number;
  15741. /**
  15742. * Creates a new instance CylinderParticleEmitter
  15743. * @param radius the radius of the emission cylinder (1 by default)
  15744. * @param height the height of the emission cylinder (1 by default)
  15745. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15746. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15747. */
  15748. constructor(
  15749. /**
  15750. * The radius of the emission cylinder.
  15751. */
  15752. radius?: number,
  15753. /**
  15754. * The height of the emission cylinder.
  15755. */
  15756. height?: number,
  15757. /**
  15758. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15759. */
  15760. radiusRange?: number,
  15761. /**
  15762. * How much to randomize the particle direction [0-1].
  15763. */
  15764. directionRandomizer?: number);
  15765. /**
  15766. * Called by the particle System when the direction is computed for the created particle.
  15767. * @param worldMatrix is the world matrix of the particle system
  15768. * @param directionToUpdate is the direction vector to update with the result
  15769. * @param particle is the particle we are computed the direction for
  15770. */
  15771. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15772. /**
  15773. * Called by the particle System when the position is computed for the created particle.
  15774. * @param worldMatrix is the world matrix of the particle system
  15775. * @param positionToUpdate is the position vector to update with the result
  15776. * @param particle is the particle we are computed the position for
  15777. */
  15778. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15779. /**
  15780. * Clones the current emitter and returns a copy of it
  15781. * @returns the new emitter
  15782. */
  15783. clone(): CylinderParticleEmitter;
  15784. /**
  15785. * Called by the GPUParticleSystem to setup the update shader
  15786. * @param effect defines the update shader
  15787. */
  15788. applyToShader(effect: Effect): void;
  15789. /**
  15790. * Returns a string to use to update the GPU particles update shader
  15791. * @returns a string containng the defines string
  15792. */
  15793. getEffectDefines(): string;
  15794. /**
  15795. * Returns the string "CylinderParticleEmitter"
  15796. * @returns a string containing the class name
  15797. */
  15798. getClassName(): string;
  15799. /**
  15800. * Serializes the particle system to a JSON object.
  15801. * @returns the JSON object
  15802. */
  15803. serialize(): any;
  15804. /**
  15805. * Parse properties from a JSON object
  15806. * @param serializationObject defines the JSON object
  15807. */
  15808. parse(serializationObject: any): void;
  15809. }
  15810. /**
  15811. * Particle emitter emitting particles from the inside of a cylinder.
  15812. * It emits the particles randomly between two vectors.
  15813. */
  15814. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15815. /**
  15816. * The min limit of the emission direction.
  15817. */
  15818. direction1: Vector3;
  15819. /**
  15820. * The max limit of the emission direction.
  15821. */
  15822. direction2: Vector3;
  15823. /**
  15824. * Creates a new instance CylinderDirectedParticleEmitter
  15825. * @param radius the radius of the emission cylinder (1 by default)
  15826. * @param height the height of the emission cylinder (1 by default)
  15827. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15828. * @param direction1 the min limit of the emission direction (up vector by default)
  15829. * @param direction2 the max limit of the emission direction (up vector by default)
  15830. */
  15831. constructor(radius?: number, height?: number, radiusRange?: number,
  15832. /**
  15833. * The min limit of the emission direction.
  15834. */
  15835. direction1?: Vector3,
  15836. /**
  15837. * The max limit of the emission direction.
  15838. */
  15839. direction2?: Vector3);
  15840. /**
  15841. * Called by the particle System when the direction is computed for the created particle.
  15842. * @param worldMatrix is the world matrix of the particle system
  15843. * @param directionToUpdate is the direction vector to update with the result
  15844. * @param particle is the particle we are computed the direction for
  15845. */
  15846. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15847. /**
  15848. * Clones the current emitter and returns a copy of it
  15849. * @returns the new emitter
  15850. */
  15851. clone(): CylinderDirectedParticleEmitter;
  15852. /**
  15853. * Called by the GPUParticleSystem to setup the update shader
  15854. * @param effect defines the update shader
  15855. */
  15856. applyToShader(effect: Effect): void;
  15857. /**
  15858. * Returns a string to use to update the GPU particles update shader
  15859. * @returns a string containng the defines string
  15860. */
  15861. getEffectDefines(): string;
  15862. /**
  15863. * Returns the string "CylinderDirectedParticleEmitter"
  15864. * @returns a string containing the class name
  15865. */
  15866. getClassName(): string;
  15867. /**
  15868. * Serializes the particle system to a JSON object.
  15869. * @returns the JSON object
  15870. */
  15871. serialize(): any;
  15872. /**
  15873. * Parse properties from a JSON object
  15874. * @param serializationObject defines the JSON object
  15875. */
  15876. parse(serializationObject: any): void;
  15877. }
  15878. }
  15879. declare module BABYLON {
  15880. /**
  15881. * Particle emitter emitting particles from the inside of a hemisphere.
  15882. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15883. */
  15884. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15885. /**
  15886. * The radius of the emission hemisphere.
  15887. */
  15888. radius: number;
  15889. /**
  15890. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15891. */
  15892. radiusRange: number;
  15893. /**
  15894. * How much to randomize the particle direction [0-1].
  15895. */
  15896. directionRandomizer: number;
  15897. /**
  15898. * Creates a new instance HemisphericParticleEmitter
  15899. * @param radius the radius of the emission hemisphere (1 by default)
  15900. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15901. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15902. */
  15903. constructor(
  15904. /**
  15905. * The radius of the emission hemisphere.
  15906. */
  15907. radius?: number,
  15908. /**
  15909. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15910. */
  15911. radiusRange?: number,
  15912. /**
  15913. * How much to randomize the particle direction [0-1].
  15914. */
  15915. directionRandomizer?: number);
  15916. /**
  15917. * Called by the particle System when the direction is computed for the created particle.
  15918. * @param worldMatrix is the world matrix of the particle system
  15919. * @param directionToUpdate is the direction vector to update with the result
  15920. * @param particle is the particle we are computed the direction for
  15921. */
  15922. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15923. /**
  15924. * Called by the particle System when the position is computed for the created particle.
  15925. * @param worldMatrix is the world matrix of the particle system
  15926. * @param positionToUpdate is the position vector to update with the result
  15927. * @param particle is the particle we are computed the position for
  15928. */
  15929. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15930. /**
  15931. * Clones the current emitter and returns a copy of it
  15932. * @returns the new emitter
  15933. */
  15934. clone(): HemisphericParticleEmitter;
  15935. /**
  15936. * Called by the GPUParticleSystem to setup the update shader
  15937. * @param effect defines the update shader
  15938. */
  15939. applyToShader(effect: Effect): void;
  15940. /**
  15941. * Returns a string to use to update the GPU particles update shader
  15942. * @returns a string containng the defines string
  15943. */
  15944. getEffectDefines(): string;
  15945. /**
  15946. * Returns the string "HemisphericParticleEmitter"
  15947. * @returns a string containing the class name
  15948. */
  15949. getClassName(): string;
  15950. /**
  15951. * Serializes the particle system to a JSON object.
  15952. * @returns the JSON object
  15953. */
  15954. serialize(): any;
  15955. /**
  15956. * Parse properties from a JSON object
  15957. * @param serializationObject defines the JSON object
  15958. */
  15959. parse(serializationObject: any): void;
  15960. }
  15961. }
  15962. declare module BABYLON {
  15963. /**
  15964. * Particle emitter emitting particles from a point.
  15965. * It emits the particles randomly between 2 given directions.
  15966. */
  15967. export class PointParticleEmitter implements IParticleEmitterType {
  15968. /**
  15969. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15970. */
  15971. direction1: Vector3;
  15972. /**
  15973. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15974. */
  15975. direction2: Vector3;
  15976. /**
  15977. * Creates a new instance PointParticleEmitter
  15978. */
  15979. constructor();
  15980. /**
  15981. * Called by the particle System when the direction is computed for the created particle.
  15982. * @param worldMatrix is the world matrix of the particle system
  15983. * @param directionToUpdate is the direction vector to update with the result
  15984. * @param particle is the particle we are computed the direction for
  15985. */
  15986. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15987. /**
  15988. * Called by the particle System when the position is computed for the created particle.
  15989. * @param worldMatrix is the world matrix of the particle system
  15990. * @param positionToUpdate is the position vector to update with the result
  15991. * @param particle is the particle we are computed the position for
  15992. */
  15993. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15994. /**
  15995. * Clones the current emitter and returns a copy of it
  15996. * @returns the new emitter
  15997. */
  15998. clone(): PointParticleEmitter;
  15999. /**
  16000. * Called by the GPUParticleSystem to setup the update shader
  16001. * @param effect defines the update shader
  16002. */
  16003. applyToShader(effect: Effect): void;
  16004. /**
  16005. * Returns a string to use to update the GPU particles update shader
  16006. * @returns a string containng the defines string
  16007. */
  16008. getEffectDefines(): string;
  16009. /**
  16010. * Returns the string "PointParticleEmitter"
  16011. * @returns a string containing the class name
  16012. */
  16013. getClassName(): string;
  16014. /**
  16015. * Serializes the particle system to a JSON object.
  16016. * @returns the JSON object
  16017. */
  16018. serialize(): any;
  16019. /**
  16020. * Parse properties from a JSON object
  16021. * @param serializationObject defines the JSON object
  16022. */
  16023. parse(serializationObject: any): void;
  16024. }
  16025. }
  16026. declare module BABYLON {
  16027. /**
  16028. * Particle emitter emitting particles from the inside of a sphere.
  16029. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16030. */
  16031. export class SphereParticleEmitter implements IParticleEmitterType {
  16032. /**
  16033. * The radius of the emission sphere.
  16034. */
  16035. radius: number;
  16036. /**
  16037. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16038. */
  16039. radiusRange: number;
  16040. /**
  16041. * How much to randomize the particle direction [0-1].
  16042. */
  16043. directionRandomizer: number;
  16044. /**
  16045. * Creates a new instance SphereParticleEmitter
  16046. * @param radius the radius of the emission sphere (1 by default)
  16047. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16048. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16049. */
  16050. constructor(
  16051. /**
  16052. * The radius of the emission sphere.
  16053. */
  16054. radius?: number,
  16055. /**
  16056. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16057. */
  16058. radiusRange?: number,
  16059. /**
  16060. * How much to randomize the particle direction [0-1].
  16061. */
  16062. directionRandomizer?: number);
  16063. /**
  16064. * Called by the particle System when the direction is computed for the created particle.
  16065. * @param worldMatrix is the world matrix of the particle system
  16066. * @param directionToUpdate is the direction vector to update with the result
  16067. * @param particle is the particle we are computed the direction for
  16068. */
  16069. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16070. /**
  16071. * Called by the particle System when the position is computed for the created particle.
  16072. * @param worldMatrix is the world matrix of the particle system
  16073. * @param positionToUpdate is the position vector to update with the result
  16074. * @param particle is the particle we are computed the position for
  16075. */
  16076. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16077. /**
  16078. * Clones the current emitter and returns a copy of it
  16079. * @returns the new emitter
  16080. */
  16081. clone(): SphereParticleEmitter;
  16082. /**
  16083. * Called by the GPUParticleSystem to setup the update shader
  16084. * @param effect defines the update shader
  16085. */
  16086. applyToShader(effect: Effect): void;
  16087. /**
  16088. * Returns a string to use to update the GPU particles update shader
  16089. * @returns a string containng the defines string
  16090. */
  16091. getEffectDefines(): string;
  16092. /**
  16093. * Returns the string "SphereParticleEmitter"
  16094. * @returns a string containing the class name
  16095. */
  16096. getClassName(): string;
  16097. /**
  16098. * Serializes the particle system to a JSON object.
  16099. * @returns the JSON object
  16100. */
  16101. serialize(): any;
  16102. /**
  16103. * Parse properties from a JSON object
  16104. * @param serializationObject defines the JSON object
  16105. */
  16106. parse(serializationObject: any): void;
  16107. }
  16108. /**
  16109. * Particle emitter emitting particles from the inside of a sphere.
  16110. * It emits the particles randomly between two vectors.
  16111. */
  16112. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16113. /**
  16114. * The min limit of the emission direction.
  16115. */
  16116. direction1: Vector3;
  16117. /**
  16118. * The max limit of the emission direction.
  16119. */
  16120. direction2: Vector3;
  16121. /**
  16122. * Creates a new instance SphereDirectedParticleEmitter
  16123. * @param radius the radius of the emission sphere (1 by default)
  16124. * @param direction1 the min limit of the emission direction (up vector by default)
  16125. * @param direction2 the max limit of the emission direction (up vector by default)
  16126. */
  16127. constructor(radius?: number,
  16128. /**
  16129. * The min limit of the emission direction.
  16130. */
  16131. direction1?: Vector3,
  16132. /**
  16133. * The max limit of the emission direction.
  16134. */
  16135. direction2?: Vector3);
  16136. /**
  16137. * Called by the particle System when the direction is computed for the created particle.
  16138. * @param worldMatrix is the world matrix of the particle system
  16139. * @param directionToUpdate is the direction vector to update with the result
  16140. * @param particle is the particle we are computed the direction for
  16141. */
  16142. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16143. /**
  16144. * Clones the current emitter and returns a copy of it
  16145. * @returns the new emitter
  16146. */
  16147. clone(): SphereDirectedParticleEmitter;
  16148. /**
  16149. * Called by the GPUParticleSystem to setup the update shader
  16150. * @param effect defines the update shader
  16151. */
  16152. applyToShader(effect: Effect): void;
  16153. /**
  16154. * Returns a string to use to update the GPU particles update shader
  16155. * @returns a string containng the defines string
  16156. */
  16157. getEffectDefines(): string;
  16158. /**
  16159. * Returns the string "SphereDirectedParticleEmitter"
  16160. * @returns a string containing the class name
  16161. */
  16162. getClassName(): string;
  16163. /**
  16164. * Serializes the particle system to a JSON object.
  16165. * @returns the JSON object
  16166. */
  16167. serialize(): any;
  16168. /**
  16169. * Parse properties from a JSON object
  16170. * @param serializationObject defines the JSON object
  16171. */
  16172. parse(serializationObject: any): void;
  16173. }
  16174. }
  16175. declare module BABYLON {
  16176. /**
  16177. * Interface representing a particle system in Babylon.js.
  16178. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16179. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16180. */
  16181. export interface IParticleSystem {
  16182. /**
  16183. * List of animations used by the particle system.
  16184. */
  16185. animations: Animation[];
  16186. /**
  16187. * The id of the Particle system.
  16188. */
  16189. id: string;
  16190. /**
  16191. * The name of the Particle system.
  16192. */
  16193. name: string;
  16194. /**
  16195. * The emitter represents the Mesh or position we are attaching the particle system to.
  16196. */
  16197. emitter: Nullable<AbstractMesh | Vector3>;
  16198. /**
  16199. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16200. */
  16201. isBillboardBased: boolean;
  16202. /**
  16203. * The rendering group used by the Particle system to chose when to render.
  16204. */
  16205. renderingGroupId: number;
  16206. /**
  16207. * The layer mask we are rendering the particles through.
  16208. */
  16209. layerMask: number;
  16210. /**
  16211. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16212. */
  16213. updateSpeed: number;
  16214. /**
  16215. * The amount of time the particle system is running (depends of the overall update speed).
  16216. */
  16217. targetStopDuration: number;
  16218. /**
  16219. * The texture used to render each particle. (this can be a spritesheet)
  16220. */
  16221. particleTexture: Nullable<Texture>;
  16222. /**
  16223. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16224. */
  16225. blendMode: number;
  16226. /**
  16227. * Minimum life time of emitting particles.
  16228. */
  16229. minLifeTime: number;
  16230. /**
  16231. * Maximum life time of emitting particles.
  16232. */
  16233. maxLifeTime: number;
  16234. /**
  16235. * Minimum Size of emitting particles.
  16236. */
  16237. minSize: number;
  16238. /**
  16239. * Maximum Size of emitting particles.
  16240. */
  16241. maxSize: number;
  16242. /**
  16243. * Minimum scale of emitting particles on X axis.
  16244. */
  16245. minScaleX: number;
  16246. /**
  16247. * Maximum scale of emitting particles on X axis.
  16248. */
  16249. maxScaleX: number;
  16250. /**
  16251. * Minimum scale of emitting particles on Y axis.
  16252. */
  16253. minScaleY: number;
  16254. /**
  16255. * Maximum scale of emitting particles on Y axis.
  16256. */
  16257. maxScaleY: number;
  16258. /**
  16259. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16260. */
  16261. color1: Color4;
  16262. /**
  16263. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16264. */
  16265. color2: Color4;
  16266. /**
  16267. * Color the particle will have at the end of its lifetime.
  16268. */
  16269. colorDead: Color4;
  16270. /**
  16271. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16272. */
  16273. emitRate: number;
  16274. /**
  16275. * You can use gravity if you want to give an orientation to your particles.
  16276. */
  16277. gravity: Vector3;
  16278. /**
  16279. * Minimum power of emitting particles.
  16280. */
  16281. minEmitPower: number;
  16282. /**
  16283. * Maximum power of emitting particles.
  16284. */
  16285. maxEmitPower: number;
  16286. /**
  16287. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16288. */
  16289. minAngularSpeed: number;
  16290. /**
  16291. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16292. */
  16293. maxAngularSpeed: number;
  16294. /**
  16295. * Gets or sets the minimal initial rotation in radians.
  16296. */
  16297. minInitialRotation: number;
  16298. /**
  16299. * Gets or sets the maximal initial rotation in radians.
  16300. */
  16301. maxInitialRotation: number;
  16302. /**
  16303. * The particle emitter type defines the emitter used by the particle system.
  16304. * It can be for example box, sphere, or cone...
  16305. */
  16306. particleEmitterType: Nullable<IParticleEmitterType>;
  16307. /**
  16308. * Defines the delay in milliseconds before starting the system (0 by default)
  16309. */
  16310. startDelay: number;
  16311. /**
  16312. * 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
  16313. */
  16314. preWarmCycles: number;
  16315. /**
  16316. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16317. */
  16318. preWarmStepOffset: number;
  16319. /**
  16320. * 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)
  16321. */
  16322. spriteCellChangeSpeed: number;
  16323. /**
  16324. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16325. */
  16326. startSpriteCellID: number;
  16327. /**
  16328. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16329. */
  16330. endSpriteCellID: number;
  16331. /**
  16332. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16333. */
  16334. spriteCellWidth: number;
  16335. /**
  16336. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16337. */
  16338. spriteCellHeight: number;
  16339. /**
  16340. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16341. */
  16342. spriteRandomStartCell: boolean;
  16343. /**
  16344. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16345. */
  16346. isAnimationSheetEnabled: boolean;
  16347. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16348. translationPivot: Vector2;
  16349. /**
  16350. * Gets or sets a texture used to add random noise to particle positions
  16351. */
  16352. noiseTexture: Nullable<BaseTexture>;
  16353. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16354. noiseStrength: Vector3;
  16355. /**
  16356. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16357. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16358. */
  16359. billboardMode: number;
  16360. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16361. limitVelocityDamping: number;
  16362. /**
  16363. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16364. */
  16365. beginAnimationOnStart: boolean;
  16366. /**
  16367. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16368. */
  16369. beginAnimationFrom: number;
  16370. /**
  16371. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16372. */
  16373. beginAnimationTo: number;
  16374. /**
  16375. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16376. */
  16377. beginAnimationLoop: boolean;
  16378. /**
  16379. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16380. */
  16381. disposeOnStop: boolean;
  16382. /**
  16383. * Gets the maximum number of particles active at the same time.
  16384. * @returns The max number of active particles.
  16385. */
  16386. getCapacity(): number;
  16387. /**
  16388. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16389. * @returns True if it has been started, otherwise false.
  16390. */
  16391. isStarted(): boolean;
  16392. /**
  16393. * Animates the particle system for this frame.
  16394. */
  16395. animate(): void;
  16396. /**
  16397. * Renders the particle system in its current state.
  16398. * @returns the current number of particles
  16399. */
  16400. render(): number;
  16401. /**
  16402. * Dispose the particle system and frees its associated resources.
  16403. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16404. */
  16405. dispose(disposeTexture?: boolean): void;
  16406. /**
  16407. * Clones the particle system.
  16408. * @param name The name of the cloned object
  16409. * @param newEmitter The new emitter to use
  16410. * @returns the cloned particle system
  16411. */
  16412. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16413. /**
  16414. * Serializes the particle system to a JSON object.
  16415. * @returns the JSON object
  16416. */
  16417. serialize(): any;
  16418. /**
  16419. * Rebuild the particle system
  16420. */
  16421. rebuild(): void;
  16422. /**
  16423. * Starts the particle system and begins to emit
  16424. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16425. */
  16426. start(delay?: number): void;
  16427. /**
  16428. * Stops the particle system.
  16429. */
  16430. stop(): void;
  16431. /**
  16432. * Remove all active particles
  16433. */
  16434. reset(): void;
  16435. /**
  16436. * Is this system ready to be used/rendered
  16437. * @return true if the system is ready
  16438. */
  16439. isReady(): boolean;
  16440. /**
  16441. * Adds a new color gradient
  16442. * @param gradient defines the gradient to use (between 0 and 1)
  16443. * @param color1 defines the color to affect to the specified gradient
  16444. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16445. * @returns the current particle system
  16446. */
  16447. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16448. /**
  16449. * Remove a specific color gradient
  16450. * @param gradient defines the gradient to remove
  16451. * @returns the current particle system
  16452. */
  16453. removeColorGradient(gradient: number): IParticleSystem;
  16454. /**
  16455. * Adds a new size gradient
  16456. * @param gradient defines the gradient to use (between 0 and 1)
  16457. * @param factor defines the size factor to affect to the specified gradient
  16458. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16459. * @returns the current particle system
  16460. */
  16461. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16462. /**
  16463. * Remove a specific size gradient
  16464. * @param gradient defines the gradient to remove
  16465. * @returns the current particle system
  16466. */
  16467. removeSizeGradient(gradient: number): IParticleSystem;
  16468. /**
  16469. * Gets the current list of color gradients.
  16470. * You must use addColorGradient and removeColorGradient to udpate this list
  16471. * @returns the list of color gradients
  16472. */
  16473. getColorGradients(): Nullable<Array<ColorGradient>>;
  16474. /**
  16475. * Gets the current list of size gradients.
  16476. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16477. * @returns the list of size gradients
  16478. */
  16479. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16480. /**
  16481. * Gets the current list of angular speed gradients.
  16482. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16483. * @returns the list of angular speed gradients
  16484. */
  16485. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16486. /**
  16487. * Adds a new angular speed gradient
  16488. * @param gradient defines the gradient to use (between 0 and 1)
  16489. * @param factor defines the angular speed to affect to the specified gradient
  16490. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16491. * @returns the current particle system
  16492. */
  16493. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16494. /**
  16495. * Remove a specific angular speed gradient
  16496. * @param gradient defines the gradient to remove
  16497. * @returns the current particle system
  16498. */
  16499. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16500. /**
  16501. * Gets the current list of velocity gradients.
  16502. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16503. * @returns the list of velocity gradients
  16504. */
  16505. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16506. /**
  16507. * Adds a new velocity gradient
  16508. * @param gradient defines the gradient to use (between 0 and 1)
  16509. * @param factor defines the velocity to affect to the specified gradient
  16510. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16511. * @returns the current particle system
  16512. */
  16513. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16514. /**
  16515. * Remove a specific velocity gradient
  16516. * @param gradient defines the gradient to remove
  16517. * @returns the current particle system
  16518. */
  16519. removeVelocityGradient(gradient: number): IParticleSystem;
  16520. /**
  16521. * Gets the current list of limit velocity gradients.
  16522. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16523. * @returns the list of limit velocity gradients
  16524. */
  16525. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16526. /**
  16527. * Adds a new limit velocity gradient
  16528. * @param gradient defines the gradient to use (between 0 and 1)
  16529. * @param factor defines the limit velocity to affect to the specified gradient
  16530. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16531. * @returns the current particle system
  16532. */
  16533. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16534. /**
  16535. * Remove a specific limit velocity gradient
  16536. * @param gradient defines the gradient to remove
  16537. * @returns the current particle system
  16538. */
  16539. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16540. /**
  16541. * Adds a new drag gradient
  16542. * @param gradient defines the gradient to use (between 0 and 1)
  16543. * @param factor defines the drag to affect to the specified gradient
  16544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16545. * @returns the current particle system
  16546. */
  16547. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16548. /**
  16549. * Remove a specific drag gradient
  16550. * @param gradient defines the gradient to remove
  16551. * @returns the current particle system
  16552. */
  16553. removeDragGradient(gradient: number): IParticleSystem;
  16554. /**
  16555. * Gets the current list of drag gradients.
  16556. * You must use addDragGradient and removeDragGradient to udpate this list
  16557. * @returns the list of drag gradients
  16558. */
  16559. getDragGradients(): Nullable<Array<FactorGradient>>;
  16560. /**
  16561. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16562. * @param gradient defines the gradient to use (between 0 and 1)
  16563. * @param factor defines the emit rate to affect to the specified gradient
  16564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16565. * @returns the current particle system
  16566. */
  16567. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16568. /**
  16569. * Remove a specific emit rate gradient
  16570. * @param gradient defines the gradient to remove
  16571. * @returns the current particle system
  16572. */
  16573. removeEmitRateGradient(gradient: number): IParticleSystem;
  16574. /**
  16575. * Gets the current list of emit rate gradients.
  16576. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16577. * @returns the list of emit rate gradients
  16578. */
  16579. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16580. /**
  16581. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16582. * @param gradient defines the gradient to use (between 0 and 1)
  16583. * @param factor defines the start size to affect to the specified gradient
  16584. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16585. * @returns the current particle system
  16586. */
  16587. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16588. /**
  16589. * Remove a specific start size gradient
  16590. * @param gradient defines the gradient to remove
  16591. * @returns the current particle system
  16592. */
  16593. removeStartSizeGradient(gradient: number): IParticleSystem;
  16594. /**
  16595. * Gets the current list of start size gradients.
  16596. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16597. * @returns the list of start size gradients
  16598. */
  16599. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16600. /**
  16601. * Adds a new life time gradient
  16602. * @param gradient defines the gradient to use (between 0 and 1)
  16603. * @param factor defines the life time factor to affect to the specified gradient
  16604. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16605. * @returns the current particle system
  16606. */
  16607. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16608. /**
  16609. * Remove a specific life time gradient
  16610. * @param gradient defines the gradient to remove
  16611. * @returns the current particle system
  16612. */
  16613. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16614. /**
  16615. * Gets the current list of life time gradients.
  16616. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16617. * @returns the list of life time gradients
  16618. */
  16619. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16620. /**
  16621. * Gets the current list of color gradients.
  16622. * You must use addColorGradient and removeColorGradient to udpate this list
  16623. * @returns the list of color gradients
  16624. */
  16625. getColorGradients(): Nullable<Array<ColorGradient>>;
  16626. /**
  16627. * Adds a new ramp gradient used to remap particle colors
  16628. * @param gradient defines the gradient to use (between 0 and 1)
  16629. * @param color defines the color to affect to the specified gradient
  16630. * @returns the current particle system
  16631. */
  16632. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16633. /**
  16634. * Gets the current list of ramp gradients.
  16635. * You must use addRampGradient and removeRampGradient to udpate this list
  16636. * @returns the list of ramp gradients
  16637. */
  16638. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16639. /** Gets or sets a boolean indicating that ramp gradients must be used
  16640. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16641. */
  16642. useRampGradients: boolean;
  16643. /**
  16644. * Adds a new color remap gradient
  16645. * @param gradient defines the gradient to use (between 0 and 1)
  16646. * @param min defines the color remap minimal range
  16647. * @param max defines the color remap maximal range
  16648. * @returns the current particle system
  16649. */
  16650. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16651. /**
  16652. * Gets the current list of color remap gradients.
  16653. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16654. * @returns the list of color remap gradients
  16655. */
  16656. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16657. /**
  16658. * Adds a new alpha remap gradient
  16659. * @param gradient defines the gradient to use (between 0 and 1)
  16660. * @param min defines the alpha remap minimal range
  16661. * @param max defines the alpha remap maximal range
  16662. * @returns the current particle system
  16663. */
  16664. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16665. /**
  16666. * Gets the current list of alpha remap gradients.
  16667. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16668. * @returns the list of alpha remap gradients
  16669. */
  16670. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16671. /**
  16672. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16673. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16674. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16675. * @returns the emitter
  16676. */
  16677. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16678. /**
  16679. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16680. * @param radius The radius of the hemisphere to emit from
  16681. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16682. * @returns the emitter
  16683. */
  16684. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16685. /**
  16686. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16687. * @param radius The radius of the sphere to emit from
  16688. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16689. * @returns the emitter
  16690. */
  16691. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16692. /**
  16693. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16694. * @param radius The radius of the sphere to emit from
  16695. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16696. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16697. * @returns the emitter
  16698. */
  16699. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16700. /**
  16701. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16702. * @param radius The radius of the emission cylinder
  16703. * @param height The height of the emission cylinder
  16704. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16705. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16706. * @returns the emitter
  16707. */
  16708. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16709. /**
  16710. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16711. * @param radius The radius of the cylinder to emit from
  16712. * @param height The height of the emission cylinder
  16713. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16714. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16715. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16716. * @returns the emitter
  16717. */
  16718. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16719. /**
  16720. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16721. * @param radius The radius of the cone to emit from
  16722. * @param angle The base angle of the cone
  16723. * @returns the emitter
  16724. */
  16725. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16726. /**
  16727. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16728. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16729. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16730. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16731. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16732. * @returns the emitter
  16733. */
  16734. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16735. /**
  16736. * Get hosting scene
  16737. * @returns the scene
  16738. */
  16739. getScene(): Scene;
  16740. }
  16741. }
  16742. declare module BABYLON {
  16743. /**
  16744. * Creates an instance based on a source mesh.
  16745. */
  16746. export class InstancedMesh extends AbstractMesh {
  16747. private _sourceMesh;
  16748. private _currentLOD;
  16749. /** @hidden */
  16750. _indexInSourceMeshInstanceArray: number;
  16751. constructor(name: string, source: Mesh);
  16752. /**
  16753. * Returns the string "InstancedMesh".
  16754. */
  16755. getClassName(): string;
  16756. /** Gets the list of lights affecting that mesh */
  16757. readonly lightSources: Light[];
  16758. _resyncLightSources(): void;
  16759. _resyncLighSource(light: Light): void;
  16760. _removeLightSource(light: Light): void;
  16761. /**
  16762. * If the source mesh receives shadows
  16763. */
  16764. readonly receiveShadows: boolean;
  16765. /**
  16766. * The material of the source mesh
  16767. */
  16768. readonly material: Nullable<Material>;
  16769. /**
  16770. * Visibility of the source mesh
  16771. */
  16772. readonly visibility: number;
  16773. /**
  16774. * Skeleton of the source mesh
  16775. */
  16776. readonly skeleton: Nullable<Skeleton>;
  16777. /**
  16778. * Rendering ground id of the source mesh
  16779. */
  16780. renderingGroupId: number;
  16781. /**
  16782. * Returns the total number of vertices (integer).
  16783. */
  16784. getTotalVertices(): number;
  16785. /**
  16786. * Returns a positive integer : the total number of indices in this mesh geometry.
  16787. * @returns the numner of indices or zero if the mesh has no geometry.
  16788. */
  16789. getTotalIndices(): number;
  16790. /**
  16791. * The source mesh of the instance
  16792. */
  16793. readonly sourceMesh: Mesh;
  16794. /**
  16795. * Is this node ready to be used/rendered
  16796. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16797. * @return {boolean} is it ready
  16798. */
  16799. isReady(completeCheck?: boolean): boolean;
  16800. /**
  16801. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16802. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16803. * @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.
  16804. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16805. */
  16806. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16807. /**
  16808. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16809. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16810. * The `data` are either a numeric array either a Float32Array.
  16811. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16812. * 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).
  16813. * Note that a new underlying VertexBuffer object is created each call.
  16814. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16815. *
  16816. * Possible `kind` values :
  16817. * - VertexBuffer.PositionKind
  16818. * - VertexBuffer.UVKind
  16819. * - VertexBuffer.UV2Kind
  16820. * - VertexBuffer.UV3Kind
  16821. * - VertexBuffer.UV4Kind
  16822. * - VertexBuffer.UV5Kind
  16823. * - VertexBuffer.UV6Kind
  16824. * - VertexBuffer.ColorKind
  16825. * - VertexBuffer.MatricesIndicesKind
  16826. * - VertexBuffer.MatricesIndicesExtraKind
  16827. * - VertexBuffer.MatricesWeightsKind
  16828. * - VertexBuffer.MatricesWeightsExtraKind
  16829. *
  16830. * Returns the Mesh.
  16831. */
  16832. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16833. /**
  16834. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16835. * If the mesh has no geometry, it is simply returned as it is.
  16836. * The `data` are either a numeric array either a Float32Array.
  16837. * No new underlying VertexBuffer object is created.
  16838. * 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.
  16839. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16840. *
  16841. * Possible `kind` values :
  16842. * - VertexBuffer.PositionKind
  16843. * - VertexBuffer.UVKind
  16844. * - VertexBuffer.UV2Kind
  16845. * - VertexBuffer.UV3Kind
  16846. * - VertexBuffer.UV4Kind
  16847. * - VertexBuffer.UV5Kind
  16848. * - VertexBuffer.UV6Kind
  16849. * - VertexBuffer.ColorKind
  16850. * - VertexBuffer.MatricesIndicesKind
  16851. * - VertexBuffer.MatricesIndicesExtraKind
  16852. * - VertexBuffer.MatricesWeightsKind
  16853. * - VertexBuffer.MatricesWeightsExtraKind
  16854. *
  16855. * Returns the Mesh.
  16856. */
  16857. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16858. /**
  16859. * Sets the mesh indices.
  16860. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16861. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16862. * This method creates a new index buffer each call.
  16863. * Returns the Mesh.
  16864. */
  16865. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16866. /**
  16867. * Boolean : True if the mesh owns the requested kind of data.
  16868. */
  16869. isVerticesDataPresent(kind: string): boolean;
  16870. /**
  16871. * Returns an array of indices (IndicesArray).
  16872. */
  16873. getIndices(): Nullable<IndicesArray>;
  16874. readonly _positions: Nullable<Vector3[]>;
  16875. /**
  16876. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16877. * This means the mesh underlying bounding box and sphere are recomputed.
  16878. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16879. * @returns the current mesh
  16880. */
  16881. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16882. /** @hidden */
  16883. _preActivate(): InstancedMesh;
  16884. /** @hidden */
  16885. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16886. /** @hidden */
  16887. _postActivate(): void;
  16888. getWorldMatrix(): Matrix;
  16889. readonly isAnInstance: boolean;
  16890. /**
  16891. * Returns the current associated LOD AbstractMesh.
  16892. */
  16893. getLOD(camera: Camera): AbstractMesh;
  16894. /** @hidden */
  16895. _syncSubMeshes(): InstancedMesh;
  16896. /** @hidden */
  16897. _generatePointsArray(): boolean;
  16898. /**
  16899. * Creates a new InstancedMesh from the current mesh.
  16900. * - name (string) : the cloned mesh name
  16901. * - newParent (optional Node) : the optional Node to parent the clone to.
  16902. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16903. *
  16904. * Returns the clone.
  16905. */
  16906. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16907. /**
  16908. * Disposes the InstancedMesh.
  16909. * Returns nothing.
  16910. */
  16911. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16912. }
  16913. }
  16914. declare module BABYLON {
  16915. /**
  16916. * Defines the options associated with the creation of a shader material.
  16917. */
  16918. export interface IShaderMaterialOptions {
  16919. /**
  16920. * Does the material work in alpha blend mode
  16921. */
  16922. needAlphaBlending: boolean;
  16923. /**
  16924. * Does the material work in alpha test mode
  16925. */
  16926. needAlphaTesting: boolean;
  16927. /**
  16928. * The list of attribute names used in the shader
  16929. */
  16930. attributes: string[];
  16931. /**
  16932. * The list of unifrom names used in the shader
  16933. */
  16934. uniforms: string[];
  16935. /**
  16936. * The list of UBO names used in the shader
  16937. */
  16938. uniformBuffers: string[];
  16939. /**
  16940. * The list of sampler names used in the shader
  16941. */
  16942. samplers: string[];
  16943. /**
  16944. * The list of defines used in the shader
  16945. */
  16946. defines: string[];
  16947. }
  16948. /**
  16949. * 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.
  16950. *
  16951. * This returned material effects how the mesh will look based on the code in the shaders.
  16952. *
  16953. * @see http://doc.babylonjs.com/how_to/shader_material
  16954. */
  16955. export class ShaderMaterial extends Material {
  16956. private _shaderPath;
  16957. private _options;
  16958. private _textures;
  16959. private _textureArrays;
  16960. private _floats;
  16961. private _ints;
  16962. private _floatsArrays;
  16963. private _colors3;
  16964. private _colors3Arrays;
  16965. private _colors4;
  16966. private _vectors2;
  16967. private _vectors3;
  16968. private _vectors4;
  16969. private _matrices;
  16970. private _matrices3x3;
  16971. private _matrices2x2;
  16972. private _vectors2Arrays;
  16973. private _vectors3Arrays;
  16974. private _cachedWorldViewMatrix;
  16975. private _renderId;
  16976. /**
  16977. * Instantiate a new shader material.
  16978. * 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.
  16979. * This returned material effects how the mesh will look based on the code in the shaders.
  16980. * @see http://doc.babylonjs.com/how_to/shader_material
  16981. * @param name Define the name of the material in the scene
  16982. * @param scene Define the scene the material belongs to
  16983. * @param shaderPath Defines the route to the shader code in one of three ways:
  16984. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16985. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16986. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16987. * @param options Define the options used to create the shader
  16988. */
  16989. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16990. /**
  16991. * Gets the options used to compile the shader.
  16992. * They can be modified to trigger a new compilation
  16993. */
  16994. readonly options: IShaderMaterialOptions;
  16995. /**
  16996. * Gets the current class name of the material e.g. "ShaderMaterial"
  16997. * Mainly use in serialization.
  16998. * @returns the class name
  16999. */
  17000. getClassName(): string;
  17001. /**
  17002. * Specifies if the material will require alpha blending
  17003. * @returns a boolean specifying if alpha blending is needed
  17004. */
  17005. needAlphaBlending(): boolean;
  17006. /**
  17007. * Specifies if this material should be rendered in alpha test mode
  17008. * @returns a boolean specifying if an alpha test is needed.
  17009. */
  17010. needAlphaTesting(): boolean;
  17011. private _checkUniform;
  17012. /**
  17013. * Set a texture in the shader.
  17014. * @param name Define the name of the uniform samplers as defined in the shader
  17015. * @param texture Define the texture to bind to this sampler
  17016. * @return the material itself allowing "fluent" like uniform updates
  17017. */
  17018. setTexture(name: string, texture: Texture): ShaderMaterial;
  17019. /**
  17020. * Set a texture array in the shader.
  17021. * @param name Define the name of the uniform sampler array as defined in the shader
  17022. * @param textures Define the list of textures to bind to this sampler
  17023. * @return the material itself allowing "fluent" like uniform updates
  17024. */
  17025. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17026. /**
  17027. * Set a float in the shader.
  17028. * @param name Define the name of the uniform as defined in the shader
  17029. * @param value Define the value to give to the uniform
  17030. * @return the material itself allowing "fluent" like uniform updates
  17031. */
  17032. setFloat(name: string, value: number): ShaderMaterial;
  17033. /**
  17034. * Set a int in the shader.
  17035. * @param name Define the name of the uniform as defined in the shader
  17036. * @param value Define the value to give to the uniform
  17037. * @return the material itself allowing "fluent" like uniform updates
  17038. */
  17039. setInt(name: string, value: number): ShaderMaterial;
  17040. /**
  17041. * Set an array of floats in the shader.
  17042. * @param name Define the name of the uniform as defined in the shader
  17043. * @param value Define the value to give to the uniform
  17044. * @return the material itself allowing "fluent" like uniform updates
  17045. */
  17046. setFloats(name: string, value: number[]): ShaderMaterial;
  17047. /**
  17048. * Set a vec3 in the shader from a Color3.
  17049. * @param name Define the name of the uniform as defined in the shader
  17050. * @param value Define the value to give to the uniform
  17051. * @return the material itself allowing "fluent" like uniform updates
  17052. */
  17053. setColor3(name: string, value: Color3): ShaderMaterial;
  17054. /**
  17055. * Set a vec3 array in the shader from a Color3 array.
  17056. * @param name Define the name of the uniform as defined in the shader
  17057. * @param value Define the value to give to the uniform
  17058. * @return the material itself allowing "fluent" like uniform updates
  17059. */
  17060. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17061. /**
  17062. * Set a vec4 in the shader from a Color4.
  17063. * @param name Define the name of the uniform as defined in the shader
  17064. * @param value Define the value to give to the uniform
  17065. * @return the material itself allowing "fluent" like uniform updates
  17066. */
  17067. setColor4(name: string, value: Color4): ShaderMaterial;
  17068. /**
  17069. * Set a vec2 in the shader from a Vector2.
  17070. * @param name Define the name of the uniform as defined in the shader
  17071. * @param value Define the value to give to the uniform
  17072. * @return the material itself allowing "fluent" like uniform updates
  17073. */
  17074. setVector2(name: string, value: Vector2): ShaderMaterial;
  17075. /**
  17076. * Set a vec3 in the shader from a Vector3.
  17077. * @param name Define the name of the uniform as defined in the shader
  17078. * @param value Define the value to give to the uniform
  17079. * @return the material itself allowing "fluent" like uniform updates
  17080. */
  17081. setVector3(name: string, value: Vector3): ShaderMaterial;
  17082. /**
  17083. * Set a vec4 in the shader from a Vector4.
  17084. * @param name Define the name of the uniform as defined in the shader
  17085. * @param value Define the value to give to the uniform
  17086. * @return the material itself allowing "fluent" like uniform updates
  17087. */
  17088. setVector4(name: string, value: Vector4): ShaderMaterial;
  17089. /**
  17090. * Set a mat4 in the shader from a Matrix.
  17091. * @param name Define the name of the uniform as defined in the shader
  17092. * @param value Define the value to give to the uniform
  17093. * @return the material itself allowing "fluent" like uniform updates
  17094. */
  17095. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17096. /**
  17097. * Set a mat3 in the shader from a Float32Array.
  17098. * @param name Define the name of the uniform as defined in the shader
  17099. * @param value Define the value to give to the uniform
  17100. * @return the material itself allowing "fluent" like uniform updates
  17101. */
  17102. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17103. /**
  17104. * Set a mat2 in the shader from a Float32Array.
  17105. * @param name Define the name of the uniform as defined in the shader
  17106. * @param value Define the value to give to the uniform
  17107. * @return the material itself allowing "fluent" like uniform updates
  17108. */
  17109. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17110. /**
  17111. * Set a vec2 array in the shader from a number array.
  17112. * @param name Define the name of the uniform as defined in the shader
  17113. * @param value Define the value to give to the uniform
  17114. * @return the material itself allowing "fluent" like uniform updates
  17115. */
  17116. setArray2(name: string, value: number[]): ShaderMaterial;
  17117. /**
  17118. * Set a vec3 array in the shader from a number array.
  17119. * @param name Define the name of the uniform as defined in the shader
  17120. * @param value Define the value to give to the uniform
  17121. * @return the material itself allowing "fluent" like uniform updates
  17122. */
  17123. setArray3(name: string, value: number[]): ShaderMaterial;
  17124. private _checkCache;
  17125. /**
  17126. * Specifies that the submesh is ready to be used
  17127. * @param mesh defines the mesh to check
  17128. * @param subMesh defines which submesh to check
  17129. * @param useInstances specifies that instances should be used
  17130. * @returns a boolean indicating that the submesh is ready or not
  17131. */
  17132. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17133. /**
  17134. * Checks if the material is ready to render the requested mesh
  17135. * @param mesh Define the mesh to render
  17136. * @param useInstances Define whether or not the material is used with instances
  17137. * @returns true if ready, otherwise false
  17138. */
  17139. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17140. /**
  17141. * Binds the world matrix to the material
  17142. * @param world defines the world transformation matrix
  17143. */
  17144. bindOnlyWorldMatrix(world: Matrix): void;
  17145. /**
  17146. * Binds the material to the mesh
  17147. * @param world defines the world transformation matrix
  17148. * @param mesh defines the mesh to bind the material to
  17149. */
  17150. bind(world: Matrix, mesh?: Mesh): void;
  17151. /**
  17152. * Gets the active textures from the material
  17153. * @returns an array of textures
  17154. */
  17155. getActiveTextures(): BaseTexture[];
  17156. /**
  17157. * Specifies if the material uses a texture
  17158. * @param texture defines the texture to check against the material
  17159. * @returns a boolean specifying if the material uses the texture
  17160. */
  17161. hasTexture(texture: BaseTexture): boolean;
  17162. /**
  17163. * Makes a duplicate of the material, and gives it a new name
  17164. * @param name defines the new name for the duplicated material
  17165. * @returns the cloned material
  17166. */
  17167. clone(name: string): ShaderMaterial;
  17168. /**
  17169. * Disposes the material
  17170. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17171. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17172. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17173. */
  17174. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17175. /**
  17176. * Serializes this material in a JSON representation
  17177. * @returns the serialized material object
  17178. */
  17179. serialize(): any;
  17180. /**
  17181. * Creates a shader material from parsed shader material data
  17182. * @param source defines the JSON represnetation of the material
  17183. * @param scene defines the hosting scene
  17184. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17185. * @returns a new material
  17186. */
  17187. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17188. }
  17189. }
  17190. declare module BABYLON {
  17191. /** @hidden */
  17192. export var colorPixelShader: {
  17193. name: string;
  17194. shader: string;
  17195. };
  17196. }
  17197. declare module BABYLON {
  17198. /** @hidden */
  17199. export var colorVertexShader: {
  17200. name: string;
  17201. shader: string;
  17202. };
  17203. }
  17204. declare module BABYLON {
  17205. /**
  17206. * Line mesh
  17207. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17208. */
  17209. export class LinesMesh extends Mesh {
  17210. /**
  17211. * If vertex color should be applied to the mesh
  17212. */
  17213. useVertexColor?: boolean | undefined;
  17214. /**
  17215. * If vertex alpha should be applied to the mesh
  17216. */
  17217. useVertexAlpha?: boolean | undefined;
  17218. /**
  17219. * Color of the line (Default: White)
  17220. */
  17221. color: Color3;
  17222. /**
  17223. * Alpha of the line (Default: 1)
  17224. */
  17225. alpha: number;
  17226. /**
  17227. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17228. * This margin is expressed in world space coordinates, so its value may vary.
  17229. * Default value is 0.1
  17230. */
  17231. intersectionThreshold: number;
  17232. private _colorShader;
  17233. /**
  17234. * Creates a new LinesMesh
  17235. * @param name defines the name
  17236. * @param scene defines the hosting scene
  17237. * @param parent defines the parent mesh if any
  17238. * @param source defines the optional source LinesMesh used to clone data from
  17239. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17240. * When false, achieved by calling a clone(), also passing False.
  17241. * This will make creation of children, recursive.
  17242. * @param useVertexColor defines if this LinesMesh supports vertex color
  17243. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17244. */
  17245. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17246. /**
  17247. * If vertex color should be applied to the mesh
  17248. */
  17249. useVertexColor?: boolean | undefined,
  17250. /**
  17251. * If vertex alpha should be applied to the mesh
  17252. */
  17253. useVertexAlpha?: boolean | undefined);
  17254. private _addClipPlaneDefine;
  17255. private _removeClipPlaneDefine;
  17256. isReady(): boolean;
  17257. /**
  17258. * Returns the string "LineMesh"
  17259. */
  17260. getClassName(): string;
  17261. /**
  17262. * @hidden
  17263. */
  17264. /**
  17265. * @hidden
  17266. */
  17267. material: Material;
  17268. /**
  17269. * @hidden
  17270. */
  17271. readonly checkCollisions: boolean;
  17272. /** @hidden */
  17273. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17274. /** @hidden */
  17275. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17276. /**
  17277. * Disposes of the line mesh
  17278. * @param doNotRecurse If children should be disposed
  17279. */
  17280. dispose(doNotRecurse?: boolean): void;
  17281. /**
  17282. * Returns a new LineMesh object cloned from the current one.
  17283. */
  17284. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17285. /**
  17286. * Creates a new InstancedLinesMesh object from the mesh model.
  17287. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17288. * @param name defines the name of the new instance
  17289. * @returns a new InstancedLinesMesh
  17290. */
  17291. createInstance(name: string): InstancedLinesMesh;
  17292. }
  17293. /**
  17294. * Creates an instance based on a source LinesMesh
  17295. */
  17296. export class InstancedLinesMesh extends InstancedMesh {
  17297. /**
  17298. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17299. * This margin is expressed in world space coordinates, so its value may vary.
  17300. * Initilized with the intersectionThreshold value of the source LinesMesh
  17301. */
  17302. intersectionThreshold: number;
  17303. constructor(name: string, source: LinesMesh);
  17304. /**
  17305. * Returns the string "InstancedLinesMesh".
  17306. */
  17307. getClassName(): string;
  17308. }
  17309. }
  17310. declare module BABYLON {
  17311. /** @hidden */
  17312. export var linePixelShader: {
  17313. name: string;
  17314. shader: string;
  17315. };
  17316. }
  17317. declare module BABYLON {
  17318. /** @hidden */
  17319. export var lineVertexShader: {
  17320. name: string;
  17321. shader: string;
  17322. };
  17323. }
  17324. declare module BABYLON {
  17325. interface AbstractMesh {
  17326. /**
  17327. * Gets the edgesRenderer associated with the mesh
  17328. */
  17329. edgesRenderer: Nullable<EdgesRenderer>;
  17330. }
  17331. interface LinesMesh {
  17332. /**
  17333. * Enables the edge rendering mode on the mesh.
  17334. * This mode makes the mesh edges visible
  17335. * @param epsilon defines the maximal distance between two angles to detect a face
  17336. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17337. * @returns the currentAbstractMesh
  17338. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17339. */
  17340. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17341. }
  17342. interface InstancedLinesMesh {
  17343. /**
  17344. * Enables the edge rendering mode on the mesh.
  17345. * This mode makes the mesh edges visible
  17346. * @param epsilon defines the maximal distance between two angles to detect a face
  17347. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17348. * @returns the current InstancedLinesMesh
  17349. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17350. */
  17351. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17352. }
  17353. /**
  17354. * Defines the minimum contract an Edges renderer should follow.
  17355. */
  17356. export interface IEdgesRenderer extends IDisposable {
  17357. /**
  17358. * Gets or sets a boolean indicating if the edgesRenderer is active
  17359. */
  17360. isEnabled: boolean;
  17361. /**
  17362. * Renders the edges of the attached mesh,
  17363. */
  17364. render(): void;
  17365. /**
  17366. * Checks wether or not the edges renderer is ready to render.
  17367. * @return true if ready, otherwise false.
  17368. */
  17369. isReady(): boolean;
  17370. }
  17371. /**
  17372. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17373. */
  17374. export class EdgesRenderer implements IEdgesRenderer {
  17375. /**
  17376. * Define the size of the edges with an orthographic camera
  17377. */
  17378. edgesWidthScalerForOrthographic: number;
  17379. /**
  17380. * Define the size of the edges with a perspective camera
  17381. */
  17382. edgesWidthScalerForPerspective: number;
  17383. protected _source: AbstractMesh;
  17384. protected _linesPositions: number[];
  17385. protected _linesNormals: number[];
  17386. protected _linesIndices: number[];
  17387. protected _epsilon: number;
  17388. protected _indicesCount: number;
  17389. protected _lineShader: ShaderMaterial;
  17390. protected _ib: DataBuffer;
  17391. protected _buffers: {
  17392. [key: string]: Nullable<VertexBuffer>;
  17393. };
  17394. protected _checkVerticesInsteadOfIndices: boolean;
  17395. private _meshRebuildObserver;
  17396. private _meshDisposeObserver;
  17397. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17398. isEnabled: boolean;
  17399. /**
  17400. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17401. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17402. * @param source Mesh used to create edges
  17403. * @param epsilon sum of angles in adjacency to check for edge
  17404. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17405. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17406. */
  17407. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17408. protected _prepareRessources(): void;
  17409. /** @hidden */
  17410. _rebuild(): void;
  17411. /**
  17412. * Releases the required resources for the edges renderer
  17413. */
  17414. dispose(): void;
  17415. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17416. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17417. /**
  17418. * Checks if the pair of p0 and p1 is en edge
  17419. * @param faceIndex
  17420. * @param edge
  17421. * @param faceNormals
  17422. * @param p0
  17423. * @param p1
  17424. * @private
  17425. */
  17426. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17427. /**
  17428. * push line into the position, normal and index buffer
  17429. * @protected
  17430. */
  17431. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17432. /**
  17433. * Generates lines edges from adjacencjes
  17434. * @private
  17435. */
  17436. _generateEdgesLines(): void;
  17437. /**
  17438. * Checks wether or not the edges renderer is ready to render.
  17439. * @return true if ready, otherwise false.
  17440. */
  17441. isReady(): boolean;
  17442. /**
  17443. * Renders the edges of the attached mesh,
  17444. */
  17445. render(): void;
  17446. }
  17447. /**
  17448. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17449. */
  17450. export class LineEdgesRenderer extends EdgesRenderer {
  17451. /**
  17452. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17453. * @param source LineMesh used to generate edges
  17454. * @param epsilon not important (specified angle for edge detection)
  17455. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17456. */
  17457. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17458. /**
  17459. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17460. */
  17461. _generateEdgesLines(): void;
  17462. }
  17463. }
  17464. declare module BABYLON {
  17465. /**
  17466. * This represents the object necessary to create a rendering group.
  17467. * This is exclusively used and created by the rendering manager.
  17468. * To modify the behavior, you use the available helpers in your scene or meshes.
  17469. * @hidden
  17470. */
  17471. export class RenderingGroup {
  17472. index: number;
  17473. private _scene;
  17474. private _opaqueSubMeshes;
  17475. private _transparentSubMeshes;
  17476. private _alphaTestSubMeshes;
  17477. private _depthOnlySubMeshes;
  17478. private _particleSystems;
  17479. private _spriteManagers;
  17480. private _opaqueSortCompareFn;
  17481. private _alphaTestSortCompareFn;
  17482. private _transparentSortCompareFn;
  17483. private _renderOpaque;
  17484. private _renderAlphaTest;
  17485. private _renderTransparent;
  17486. /** @hidden */
  17487. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17488. onBeforeTransparentRendering: () => void;
  17489. /**
  17490. * Set the opaque sort comparison function.
  17491. * If null the sub meshes will be render in the order they were created
  17492. */
  17493. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17494. /**
  17495. * Set the alpha test sort comparison function.
  17496. * If null the sub meshes will be render in the order they were created
  17497. */
  17498. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17499. /**
  17500. * Set the transparent sort comparison function.
  17501. * If null the sub meshes will be render in the order they were created
  17502. */
  17503. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17504. /**
  17505. * Creates a new rendering group.
  17506. * @param index The rendering group index
  17507. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17508. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17509. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17510. */
  17511. 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>);
  17512. /**
  17513. * Render all the sub meshes contained in the group.
  17514. * @param customRenderFunction Used to override the default render behaviour of the group.
  17515. * @returns true if rendered some submeshes.
  17516. */
  17517. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17518. /**
  17519. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17520. * @param subMeshes The submeshes to render
  17521. */
  17522. private renderOpaqueSorted;
  17523. /**
  17524. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17525. * @param subMeshes The submeshes to render
  17526. */
  17527. private renderAlphaTestSorted;
  17528. /**
  17529. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17530. * @param subMeshes The submeshes to render
  17531. */
  17532. private renderTransparentSorted;
  17533. /**
  17534. * Renders the submeshes in a specified order.
  17535. * @param subMeshes The submeshes to sort before render
  17536. * @param sortCompareFn The comparison function use to sort
  17537. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17538. * @param transparent Specifies to activate blending if true
  17539. */
  17540. private static renderSorted;
  17541. /**
  17542. * Renders the submeshes in the order they were dispatched (no sort applied).
  17543. * @param subMeshes The submeshes to render
  17544. */
  17545. private static renderUnsorted;
  17546. /**
  17547. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17548. * are rendered back to front if in the same alpha index.
  17549. *
  17550. * @param a The first submesh
  17551. * @param b The second submesh
  17552. * @returns The result of the comparison
  17553. */
  17554. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17555. /**
  17556. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17557. * are rendered back to front.
  17558. *
  17559. * @param a The first submesh
  17560. * @param b The second submesh
  17561. * @returns The result of the comparison
  17562. */
  17563. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17564. /**
  17565. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17566. * are rendered front to back (prevent overdraw).
  17567. *
  17568. * @param a The first submesh
  17569. * @param b The second submesh
  17570. * @returns The result of the comparison
  17571. */
  17572. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17573. /**
  17574. * Resets the different lists of submeshes to prepare a new frame.
  17575. */
  17576. prepare(): void;
  17577. dispose(): void;
  17578. /**
  17579. * Inserts the submesh in its correct queue depending on its material.
  17580. * @param subMesh The submesh to dispatch
  17581. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17582. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17583. */
  17584. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17585. dispatchSprites(spriteManager: ISpriteManager): void;
  17586. dispatchParticles(particleSystem: IParticleSystem): void;
  17587. private _renderParticles;
  17588. private _renderSprites;
  17589. }
  17590. }
  17591. declare module BABYLON {
  17592. /**
  17593. * Interface describing the different options available in the rendering manager
  17594. * regarding Auto Clear between groups.
  17595. */
  17596. export interface IRenderingManagerAutoClearSetup {
  17597. /**
  17598. * Defines whether or not autoclear is enable.
  17599. */
  17600. autoClear: boolean;
  17601. /**
  17602. * Defines whether or not to autoclear the depth buffer.
  17603. */
  17604. depth: boolean;
  17605. /**
  17606. * Defines whether or not to autoclear the stencil buffer.
  17607. */
  17608. stencil: boolean;
  17609. }
  17610. /**
  17611. * This class is used by the onRenderingGroupObservable
  17612. */
  17613. export class RenderingGroupInfo {
  17614. /**
  17615. * The Scene that being rendered
  17616. */
  17617. scene: Scene;
  17618. /**
  17619. * The camera currently used for the rendering pass
  17620. */
  17621. camera: Nullable<Camera>;
  17622. /**
  17623. * The ID of the renderingGroup being processed
  17624. */
  17625. renderingGroupId: number;
  17626. }
  17627. /**
  17628. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17629. * It is enable to manage the different groups as well as the different necessary sort functions.
  17630. * This should not be used directly aside of the few static configurations
  17631. */
  17632. export class RenderingManager {
  17633. /**
  17634. * The max id used for rendering groups (not included)
  17635. */
  17636. static MAX_RENDERINGGROUPS: number;
  17637. /**
  17638. * The min id used for rendering groups (included)
  17639. */
  17640. static MIN_RENDERINGGROUPS: number;
  17641. /**
  17642. * Used to globally prevent autoclearing scenes.
  17643. */
  17644. static AUTOCLEAR: boolean;
  17645. /**
  17646. * @hidden
  17647. */
  17648. _useSceneAutoClearSetup: boolean;
  17649. private _scene;
  17650. private _renderingGroups;
  17651. private _depthStencilBufferAlreadyCleaned;
  17652. private _autoClearDepthStencil;
  17653. private _customOpaqueSortCompareFn;
  17654. private _customAlphaTestSortCompareFn;
  17655. private _customTransparentSortCompareFn;
  17656. private _renderingGroupInfo;
  17657. /**
  17658. * Instantiates a new rendering group for a particular scene
  17659. * @param scene Defines the scene the groups belongs to
  17660. */
  17661. constructor(scene: Scene);
  17662. private _clearDepthStencilBuffer;
  17663. /**
  17664. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17665. * @hidden
  17666. */
  17667. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17668. /**
  17669. * Resets the different information of the group to prepare a new frame
  17670. * @hidden
  17671. */
  17672. reset(): void;
  17673. /**
  17674. * Dispose and release the group and its associated resources.
  17675. * @hidden
  17676. */
  17677. dispose(): void;
  17678. /**
  17679. * Clear the info related to rendering groups preventing retention points during dispose.
  17680. */
  17681. freeRenderingGroups(): void;
  17682. private _prepareRenderingGroup;
  17683. /**
  17684. * Add a sprite manager to the rendering manager in order to render it this frame.
  17685. * @param spriteManager Define the sprite manager to render
  17686. */
  17687. dispatchSprites(spriteManager: ISpriteManager): void;
  17688. /**
  17689. * Add a particle system to the rendering manager in order to render it this frame.
  17690. * @param particleSystem Define the particle system to render
  17691. */
  17692. dispatchParticles(particleSystem: IParticleSystem): void;
  17693. /**
  17694. * Add a submesh to the manager in order to render it this frame
  17695. * @param subMesh The submesh to dispatch
  17696. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17697. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17698. */
  17699. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17700. /**
  17701. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17702. * This allowed control for front to back rendering or reversly depending of the special needs.
  17703. *
  17704. * @param renderingGroupId The rendering group id corresponding to its index
  17705. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17706. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17707. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17708. */
  17709. 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;
  17710. /**
  17711. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17712. *
  17713. * @param renderingGroupId The rendering group id corresponding to its index
  17714. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17715. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17716. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17717. */
  17718. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17719. /**
  17720. * Gets the current auto clear configuration for one rendering group of the rendering
  17721. * manager.
  17722. * @param index the rendering group index to get the information for
  17723. * @returns The auto clear setup for the requested rendering group
  17724. */
  17725. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17726. }
  17727. }
  17728. declare module BABYLON {
  17729. /**
  17730. * This Helps creating a texture that will be created from a camera in your scene.
  17731. * It is basically a dynamic texture that could be used to create special effects for instance.
  17732. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17733. */
  17734. export class RenderTargetTexture extends Texture {
  17735. isCube: boolean;
  17736. /**
  17737. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17738. */
  17739. static readonly REFRESHRATE_RENDER_ONCE: number;
  17740. /**
  17741. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17742. */
  17743. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17744. /**
  17745. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17746. * the central point of your effect and can save a lot of performances.
  17747. */
  17748. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17749. /**
  17750. * Use this predicate to dynamically define the list of mesh you want to render.
  17751. * If set, the renderList property will be overwritten.
  17752. */
  17753. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17754. private _renderList;
  17755. /**
  17756. * Use this list to define the list of mesh you want to render.
  17757. */
  17758. renderList: Nullable<Array<AbstractMesh>>;
  17759. private _hookArray;
  17760. /**
  17761. * Define if particles should be rendered in your texture.
  17762. */
  17763. renderParticles: boolean;
  17764. /**
  17765. * Define if sprites should be rendered in your texture.
  17766. */
  17767. renderSprites: boolean;
  17768. /**
  17769. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17770. */
  17771. coordinatesMode: number;
  17772. /**
  17773. * Define the camera used to render the texture.
  17774. */
  17775. activeCamera: Nullable<Camera>;
  17776. /**
  17777. * Override the render function of the texture with your own one.
  17778. */
  17779. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17780. /**
  17781. * Define if camera post processes should be use while rendering the texture.
  17782. */
  17783. useCameraPostProcesses: boolean;
  17784. /**
  17785. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17786. */
  17787. ignoreCameraViewport: boolean;
  17788. private _postProcessManager;
  17789. private _postProcesses;
  17790. private _resizeObserver;
  17791. /**
  17792. * An event triggered when the texture is unbind.
  17793. */
  17794. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17795. /**
  17796. * An event triggered when the texture is unbind.
  17797. */
  17798. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17799. private _onAfterUnbindObserver;
  17800. /**
  17801. * Set a after unbind callback in the texture.
  17802. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17803. */
  17804. onAfterUnbind: () => void;
  17805. /**
  17806. * An event triggered before rendering the texture
  17807. */
  17808. onBeforeRenderObservable: Observable<number>;
  17809. private _onBeforeRenderObserver;
  17810. /**
  17811. * Set a before render callback in the texture.
  17812. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17813. */
  17814. onBeforeRender: (faceIndex: number) => void;
  17815. /**
  17816. * An event triggered after rendering the texture
  17817. */
  17818. onAfterRenderObservable: Observable<number>;
  17819. private _onAfterRenderObserver;
  17820. /**
  17821. * Set a after render callback in the texture.
  17822. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17823. */
  17824. onAfterRender: (faceIndex: number) => void;
  17825. /**
  17826. * An event triggered after the texture clear
  17827. */
  17828. onClearObservable: Observable<Engine>;
  17829. private _onClearObserver;
  17830. /**
  17831. * Set a clear callback in the texture.
  17832. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17833. */
  17834. onClear: (Engine: Engine) => void;
  17835. /**
  17836. * Define the clear color of the Render Target if it should be different from the scene.
  17837. */
  17838. clearColor: Color4;
  17839. protected _size: number | {
  17840. width: number;
  17841. height: number;
  17842. };
  17843. protected _initialSizeParameter: number | {
  17844. width: number;
  17845. height: number;
  17846. } | {
  17847. ratio: number;
  17848. };
  17849. protected _sizeRatio: Nullable<number>;
  17850. /** @hidden */
  17851. _generateMipMaps: boolean;
  17852. protected _renderingManager: RenderingManager;
  17853. /** @hidden */
  17854. _waitingRenderList: string[];
  17855. protected _doNotChangeAspectRatio: boolean;
  17856. protected _currentRefreshId: number;
  17857. protected _refreshRate: number;
  17858. protected _textureMatrix: Matrix;
  17859. protected _samples: number;
  17860. protected _renderTargetOptions: RenderTargetCreationOptions;
  17861. /**
  17862. * Gets render target creation options that were used.
  17863. */
  17864. readonly renderTargetOptions: RenderTargetCreationOptions;
  17865. protected _engine: Engine;
  17866. protected _onRatioRescale(): void;
  17867. /**
  17868. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17869. * It must define where the camera used to render the texture is set
  17870. */
  17871. boundingBoxPosition: Vector3;
  17872. private _boundingBoxSize;
  17873. /**
  17874. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17875. * When defined, the cubemap will switch to local mode
  17876. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17877. * @example https://www.babylonjs-playground.com/#RNASML
  17878. */
  17879. boundingBoxSize: Vector3;
  17880. /**
  17881. * In case the RTT has been created with a depth texture, get the associated
  17882. * depth texture.
  17883. * Otherwise, return null.
  17884. */
  17885. depthStencilTexture: Nullable<InternalTexture>;
  17886. /**
  17887. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17888. * or used a shadow, depth texture...
  17889. * @param name The friendly name of the texture
  17890. * @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)
  17891. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17892. * @param generateMipMaps True if mip maps need to be generated after render.
  17893. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17894. * @param type The type of the buffer in the RTT (int, half float, float...)
  17895. * @param isCube True if a cube texture needs to be created
  17896. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17897. * @param generateDepthBuffer True to generate a depth buffer
  17898. * @param generateStencilBuffer True to generate a stencil buffer
  17899. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17900. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17901. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17902. */
  17903. constructor(name: string, size: number | {
  17904. width: number;
  17905. height: number;
  17906. } | {
  17907. ratio: number;
  17908. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17909. /**
  17910. * Creates a depth stencil texture.
  17911. * This is only available in WebGL 2 or with the depth texture extension available.
  17912. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17913. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17914. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17915. */
  17916. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17917. private _processSizeParameter;
  17918. /**
  17919. * Define the number of samples to use in case of MSAA.
  17920. * It defaults to one meaning no MSAA has been enabled.
  17921. */
  17922. samples: number;
  17923. /**
  17924. * Resets the refresh counter of the texture and start bak from scratch.
  17925. * Could be useful to regenerate the texture if it is setup to render only once.
  17926. */
  17927. resetRefreshCounter(): void;
  17928. /**
  17929. * Define the refresh rate of the texture or the rendering frequency.
  17930. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17931. */
  17932. refreshRate: number;
  17933. /**
  17934. * Adds a post process to the render target rendering passes.
  17935. * @param postProcess define the post process to add
  17936. */
  17937. addPostProcess(postProcess: PostProcess): void;
  17938. /**
  17939. * Clear all the post processes attached to the render target
  17940. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17941. */
  17942. clearPostProcesses(dispose?: boolean): void;
  17943. /**
  17944. * Remove one of the post process from the list of attached post processes to the texture
  17945. * @param postProcess define the post process to remove from the list
  17946. */
  17947. removePostProcess(postProcess: PostProcess): void;
  17948. /** @hidden */
  17949. _shouldRender(): boolean;
  17950. /**
  17951. * Gets the actual render size of the texture.
  17952. * @returns the width of the render size
  17953. */
  17954. getRenderSize(): number;
  17955. /**
  17956. * Gets the actual render width of the texture.
  17957. * @returns the width of the render size
  17958. */
  17959. getRenderWidth(): number;
  17960. /**
  17961. * Gets the actual render height of the texture.
  17962. * @returns the height of the render size
  17963. */
  17964. getRenderHeight(): number;
  17965. /**
  17966. * Get if the texture can be rescaled or not.
  17967. */
  17968. readonly canRescale: boolean;
  17969. /**
  17970. * Resize the texture using a ratio.
  17971. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17972. */
  17973. scale(ratio: number): void;
  17974. /**
  17975. * Get the texture reflection matrix used to rotate/transform the reflection.
  17976. * @returns the reflection matrix
  17977. */
  17978. getReflectionTextureMatrix(): Matrix;
  17979. /**
  17980. * Resize the texture to a new desired size.
  17981. * Be carrefull as it will recreate all the data in the new texture.
  17982. * @param size Define the new size. It can be:
  17983. * - a number for squared texture,
  17984. * - an object containing { width: number, height: number }
  17985. * - or an object containing a ratio { ratio: number }
  17986. */
  17987. resize(size: number | {
  17988. width: number;
  17989. height: number;
  17990. } | {
  17991. ratio: number;
  17992. }): void;
  17993. /**
  17994. * Renders all the objects from the render list into the texture.
  17995. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17996. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17997. */
  17998. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17999. private _bestReflectionRenderTargetDimension;
  18000. /**
  18001. * @hidden
  18002. * @param faceIndex face index to bind to if this is a cubetexture
  18003. */
  18004. _bindFrameBuffer(faceIndex?: number): void;
  18005. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18006. private renderToTarget;
  18007. /**
  18008. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18009. * This allowed control for front to back rendering or reversly depending of the special needs.
  18010. *
  18011. * @param renderingGroupId The rendering group id corresponding to its index
  18012. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18013. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18014. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18015. */
  18016. 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;
  18017. /**
  18018. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18019. *
  18020. * @param renderingGroupId The rendering group id corresponding to its index
  18021. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18022. */
  18023. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18024. /**
  18025. * Clones the texture.
  18026. * @returns the cloned texture
  18027. */
  18028. clone(): RenderTargetTexture;
  18029. /**
  18030. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18031. * @returns The JSON representation of the texture
  18032. */
  18033. serialize(): any;
  18034. /**
  18035. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18036. */
  18037. disposeFramebufferObjects(): void;
  18038. /**
  18039. * Dispose the texture and release its associated resources.
  18040. */
  18041. dispose(): void;
  18042. /** @hidden */
  18043. _rebuild(): void;
  18044. /**
  18045. * Clear the info related to rendering groups preventing retention point in material dispose.
  18046. */
  18047. freeRenderingGroups(): void;
  18048. /**
  18049. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18050. * @returns the view count
  18051. */
  18052. getViewCount(): number;
  18053. }
  18054. }
  18055. declare module BABYLON {
  18056. /**
  18057. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18058. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18059. * You can then easily use it as a reflectionTexture on a flat surface.
  18060. * In case the surface is not a plane, please consider relying on reflection probes.
  18061. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18062. */
  18063. export class MirrorTexture extends RenderTargetTexture {
  18064. private scene;
  18065. /**
  18066. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18067. * 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.
  18068. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18069. */
  18070. mirrorPlane: Plane;
  18071. /**
  18072. * Define the blur ratio used to blur the reflection if needed.
  18073. */
  18074. blurRatio: number;
  18075. /**
  18076. * Define the adaptive blur kernel used to blur the reflection if needed.
  18077. * This will autocompute the closest best match for the `blurKernel`
  18078. */
  18079. adaptiveBlurKernel: number;
  18080. /**
  18081. * Define the blur kernel used to blur the reflection if needed.
  18082. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18083. */
  18084. blurKernel: number;
  18085. /**
  18086. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18087. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18088. */
  18089. blurKernelX: number;
  18090. /**
  18091. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18092. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18093. */
  18094. blurKernelY: number;
  18095. private _autoComputeBlurKernel;
  18096. protected _onRatioRescale(): void;
  18097. private _updateGammaSpace;
  18098. private _imageProcessingConfigChangeObserver;
  18099. private _transformMatrix;
  18100. private _mirrorMatrix;
  18101. private _savedViewMatrix;
  18102. private _blurX;
  18103. private _blurY;
  18104. private _adaptiveBlurKernel;
  18105. private _blurKernelX;
  18106. private _blurKernelY;
  18107. private _blurRatio;
  18108. /**
  18109. * Instantiates a Mirror Texture.
  18110. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18111. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18112. * You can then easily use it as a reflectionTexture on a flat surface.
  18113. * In case the surface is not a plane, please consider relying on reflection probes.
  18114. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18115. * @param name
  18116. * @param size
  18117. * @param scene
  18118. * @param generateMipMaps
  18119. * @param type
  18120. * @param samplingMode
  18121. * @param generateDepthBuffer
  18122. */
  18123. constructor(name: string, size: number | {
  18124. width: number;
  18125. height: number;
  18126. } | {
  18127. ratio: number;
  18128. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18129. private _preparePostProcesses;
  18130. /**
  18131. * Clone the mirror texture.
  18132. * @returns the cloned texture
  18133. */
  18134. clone(): MirrorTexture;
  18135. /**
  18136. * Serialize the texture to a JSON representation you could use in Parse later on
  18137. * @returns the serialized JSON representation
  18138. */
  18139. serialize(): any;
  18140. /**
  18141. * Dispose the texture and release its associated resources.
  18142. */
  18143. dispose(): void;
  18144. }
  18145. }
  18146. declare module BABYLON {
  18147. /**
  18148. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18149. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18150. */
  18151. export class Texture extends BaseTexture {
  18152. /** @hidden */
  18153. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18154. /** @hidden */
  18155. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18156. /** @hidden */
  18157. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18158. /** nearest is mag = nearest and min = nearest and mip = linear */
  18159. static readonly NEAREST_SAMPLINGMODE: number;
  18160. /** nearest is mag = nearest and min = nearest and mip = linear */
  18161. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18162. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18163. static readonly BILINEAR_SAMPLINGMODE: number;
  18164. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18165. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18166. /** Trilinear is mag = linear and min = linear and mip = linear */
  18167. static readonly TRILINEAR_SAMPLINGMODE: number;
  18168. /** Trilinear is mag = linear and min = linear and mip = linear */
  18169. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18170. /** mag = nearest and min = nearest and mip = nearest */
  18171. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18172. /** mag = nearest and min = linear and mip = nearest */
  18173. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18174. /** mag = nearest and min = linear and mip = linear */
  18175. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18176. /** mag = nearest and min = linear and mip = none */
  18177. static readonly NEAREST_LINEAR: number;
  18178. /** mag = nearest and min = nearest and mip = none */
  18179. static readonly NEAREST_NEAREST: number;
  18180. /** mag = linear and min = nearest and mip = nearest */
  18181. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18182. /** mag = linear and min = nearest and mip = linear */
  18183. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18184. /** mag = linear and min = linear and mip = none */
  18185. static readonly LINEAR_LINEAR: number;
  18186. /** mag = linear and min = nearest and mip = none */
  18187. static readonly LINEAR_NEAREST: number;
  18188. /** Explicit coordinates mode */
  18189. static readonly EXPLICIT_MODE: number;
  18190. /** Spherical coordinates mode */
  18191. static readonly SPHERICAL_MODE: number;
  18192. /** Planar coordinates mode */
  18193. static readonly PLANAR_MODE: number;
  18194. /** Cubic coordinates mode */
  18195. static readonly CUBIC_MODE: number;
  18196. /** Projection coordinates mode */
  18197. static readonly PROJECTION_MODE: number;
  18198. /** Inverse Cubic coordinates mode */
  18199. static readonly SKYBOX_MODE: number;
  18200. /** Inverse Cubic coordinates mode */
  18201. static readonly INVCUBIC_MODE: number;
  18202. /** Equirectangular coordinates mode */
  18203. static readonly EQUIRECTANGULAR_MODE: number;
  18204. /** Equirectangular Fixed coordinates mode */
  18205. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18206. /** Equirectangular Fixed Mirrored coordinates mode */
  18207. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18208. /** Texture is not repeating outside of 0..1 UVs */
  18209. static readonly CLAMP_ADDRESSMODE: number;
  18210. /** Texture is repeating outside of 0..1 UVs */
  18211. static readonly WRAP_ADDRESSMODE: number;
  18212. /** Texture is repeating and mirrored */
  18213. static readonly MIRROR_ADDRESSMODE: number;
  18214. /**
  18215. * 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
  18216. */
  18217. static UseSerializedUrlIfAny: boolean;
  18218. /**
  18219. * Define the url of the texture.
  18220. */
  18221. url: Nullable<string>;
  18222. /**
  18223. * Define an offset on the texture to offset the u coordinates of the UVs
  18224. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18225. */
  18226. uOffset: number;
  18227. /**
  18228. * Define an offset on the texture to offset the v coordinates of the UVs
  18229. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18230. */
  18231. vOffset: number;
  18232. /**
  18233. * Define an offset on the texture to scale the u coordinates of the UVs
  18234. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18235. */
  18236. uScale: number;
  18237. /**
  18238. * Define an offset on the texture to scale the v coordinates of the UVs
  18239. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18240. */
  18241. vScale: number;
  18242. /**
  18243. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18244. * @see http://doc.babylonjs.com/how_to/more_materials
  18245. */
  18246. uAng: number;
  18247. /**
  18248. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18249. * @see http://doc.babylonjs.com/how_to/more_materials
  18250. */
  18251. vAng: number;
  18252. /**
  18253. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18254. * @see http://doc.babylonjs.com/how_to/more_materials
  18255. */
  18256. wAng: number;
  18257. /**
  18258. * Defines the center of rotation (U)
  18259. */
  18260. uRotationCenter: number;
  18261. /**
  18262. * Defines the center of rotation (V)
  18263. */
  18264. vRotationCenter: number;
  18265. /**
  18266. * Defines the center of rotation (W)
  18267. */
  18268. wRotationCenter: number;
  18269. /**
  18270. * Are mip maps generated for this texture or not.
  18271. */
  18272. readonly noMipmap: boolean;
  18273. /**
  18274. * List of inspectable custom properties (used by the Inspector)
  18275. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18276. */
  18277. inspectableCustomProperties: Nullable<IInspectable[]>;
  18278. private _noMipmap;
  18279. /** @hidden */
  18280. _invertY: boolean;
  18281. private _rowGenerationMatrix;
  18282. private _cachedTextureMatrix;
  18283. private _projectionModeMatrix;
  18284. private _t0;
  18285. private _t1;
  18286. private _t2;
  18287. private _cachedUOffset;
  18288. private _cachedVOffset;
  18289. private _cachedUScale;
  18290. private _cachedVScale;
  18291. private _cachedUAng;
  18292. private _cachedVAng;
  18293. private _cachedWAng;
  18294. private _cachedProjectionMatrixId;
  18295. private _cachedCoordinatesMode;
  18296. /** @hidden */
  18297. protected _initialSamplingMode: number;
  18298. /** @hidden */
  18299. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18300. private _deleteBuffer;
  18301. protected _format: Nullable<number>;
  18302. private _delayedOnLoad;
  18303. private _delayedOnError;
  18304. /**
  18305. * Observable triggered once the texture has been loaded.
  18306. */
  18307. onLoadObservable: Observable<Texture>;
  18308. protected _isBlocking: boolean;
  18309. /**
  18310. * Is the texture preventing material to render while loading.
  18311. * If false, a default texture will be used instead of the loading one during the preparation step.
  18312. */
  18313. isBlocking: boolean;
  18314. /**
  18315. * Get the current sampling mode associated with the texture.
  18316. */
  18317. readonly samplingMode: number;
  18318. /**
  18319. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18320. */
  18321. readonly invertY: boolean;
  18322. /**
  18323. * Instantiates a new texture.
  18324. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18325. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18326. * @param url define the url of the picture to load as a texture
  18327. * @param scene define the scene the texture will belong to
  18328. * @param noMipmap define if the texture will require mip maps or not
  18329. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18330. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18331. * @param onLoad define a callback triggered when the texture has been loaded
  18332. * @param onError define a callback triggered when an error occurred during the loading session
  18333. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18334. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18335. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18336. */
  18337. 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);
  18338. /**
  18339. * Update the url (and optional buffer) of this texture if url was null during construction.
  18340. * @param url the url of the texture
  18341. * @param buffer the buffer of the texture (defaults to null)
  18342. * @param onLoad callback called when the texture is loaded (defaults to null)
  18343. */
  18344. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18345. /**
  18346. * Finish the loading sequence of a texture flagged as delayed load.
  18347. * @hidden
  18348. */
  18349. delayLoad(): void;
  18350. private _prepareRowForTextureGeneration;
  18351. /**
  18352. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18353. * @returns the transform matrix of the texture.
  18354. */
  18355. getTextureMatrix(): Matrix;
  18356. /**
  18357. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18358. * @returns The reflection texture transform
  18359. */
  18360. getReflectionTextureMatrix(): Matrix;
  18361. /**
  18362. * Clones the texture.
  18363. * @returns the cloned texture
  18364. */
  18365. clone(): Texture;
  18366. /**
  18367. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18368. * @returns The JSON representation of the texture
  18369. */
  18370. serialize(): any;
  18371. /**
  18372. * Get the current class name of the texture useful for serialization or dynamic coding.
  18373. * @returns "Texture"
  18374. */
  18375. getClassName(): string;
  18376. /**
  18377. * Dispose the texture and release its associated resources.
  18378. */
  18379. dispose(): void;
  18380. /**
  18381. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18382. * @param parsedTexture Define the JSON representation of the texture
  18383. * @param scene Define the scene the parsed texture should be instantiated in
  18384. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18385. * @returns The parsed texture if successful
  18386. */
  18387. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18388. /**
  18389. * Creates a texture from its base 64 representation.
  18390. * @param data Define the base64 payload without the data: prefix
  18391. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18392. * @param scene Define the scene the texture should belong to
  18393. * @param noMipmap Forces the texture to not create mip map information if true
  18394. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18395. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18396. * @param onLoad define a callback triggered when the texture has been loaded
  18397. * @param onError define a callback triggered when an error occurred during the loading session
  18398. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18399. * @returns the created texture
  18400. */
  18401. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18402. /**
  18403. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18404. * @param data Define the base64 payload without the data: prefix
  18405. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18406. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18407. * @param scene Define the scene the texture should belong to
  18408. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18409. * @param noMipmap Forces the texture to not create mip map information if true
  18410. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18411. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18412. * @param onLoad define a callback triggered when the texture has been loaded
  18413. * @param onError define a callback triggered when an error occurred during the loading session
  18414. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18415. * @returns the created texture
  18416. */
  18417. 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;
  18418. }
  18419. }
  18420. declare module BABYLON {
  18421. interface Engine {
  18422. /**
  18423. * Creates a raw texture
  18424. * @param data defines the data to store in the texture
  18425. * @param width defines the width of the texture
  18426. * @param height defines the height of the texture
  18427. * @param format defines the format of the data
  18428. * @param generateMipMaps defines if the engine should generate the mip levels
  18429. * @param invertY defines if data must be stored with Y axis inverted
  18430. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18431. * @param compression defines the compression used (null by default)
  18432. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18433. * @returns the raw texture inside an InternalTexture
  18434. */
  18435. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18436. /**
  18437. * Update a raw texture
  18438. * @param texture defines the texture to update
  18439. * @param data defines the data to store in the texture
  18440. * @param format defines the format of the data
  18441. * @param invertY defines if data must be stored with Y axis inverted
  18442. */
  18443. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18444. /**
  18445. * Update a raw texture
  18446. * @param texture defines the texture to update
  18447. * @param data defines the data to store in the texture
  18448. * @param format defines the format of the data
  18449. * @param invertY defines if data must be stored with Y axis inverted
  18450. * @param compression defines the compression used (null by default)
  18451. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18452. */
  18453. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18454. /**
  18455. * Creates a new raw cube texture
  18456. * @param data defines the array of data to use to create each face
  18457. * @param size defines the size of the textures
  18458. * @param format defines the format of the data
  18459. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18460. * @param generateMipMaps defines if the engine should generate the mip levels
  18461. * @param invertY defines if data must be stored with Y axis inverted
  18462. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18463. * @param compression defines the compression used (null by default)
  18464. * @returns the cube texture as an InternalTexture
  18465. */
  18466. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18467. /**
  18468. * Update a raw cube texture
  18469. * @param texture defines the texture to udpdate
  18470. * @param data defines the data to store
  18471. * @param format defines the data format
  18472. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18473. * @param invertY defines if data must be stored with Y axis inverted
  18474. */
  18475. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18476. /**
  18477. * Update a raw cube texture
  18478. * @param texture defines the texture to udpdate
  18479. * @param data defines the data to store
  18480. * @param format defines the data format
  18481. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18482. * @param invertY defines if data must be stored with Y axis inverted
  18483. * @param compression defines the compression used (null by default)
  18484. */
  18485. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18486. /**
  18487. * Update a raw cube texture
  18488. * @param texture defines the texture to udpdate
  18489. * @param data defines the data to store
  18490. * @param format defines the data format
  18491. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18492. * @param invertY defines if data must be stored with Y axis inverted
  18493. * @param compression defines the compression used (null by default)
  18494. * @param level defines which level of the texture to update
  18495. */
  18496. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18497. /**
  18498. * Creates a new raw cube texture from a specified url
  18499. * @param url defines the url where the data is located
  18500. * @param scene defines the current scene
  18501. * @param size defines the size of the textures
  18502. * @param format defines the format of the data
  18503. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18504. * @param noMipmap defines if the engine should avoid generating the mip levels
  18505. * @param callback defines a callback used to extract texture data from loaded data
  18506. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18507. * @param onLoad defines a callback called when texture is loaded
  18508. * @param onError defines a callback called if there is an error
  18509. * @returns the cube texture as an InternalTexture
  18510. */
  18511. 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>): InternalTexture;
  18512. /**
  18513. * Creates a new raw cube texture from a specified url
  18514. * @param url defines the url where the data is located
  18515. * @param scene defines the current scene
  18516. * @param size defines the size of the textures
  18517. * @param format defines the format of the data
  18518. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18519. * @param noMipmap defines if the engine should avoid generating the mip levels
  18520. * @param callback defines a callback used to extract texture data from loaded data
  18521. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18522. * @param onLoad defines a callback called when texture is loaded
  18523. * @param onError defines a callback called if there is an error
  18524. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18525. * @param invertY defines if data must be stored with Y axis inverted
  18526. * @returns the cube texture as an InternalTexture
  18527. */
  18528. 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;
  18529. /**
  18530. * Creates a new raw 3D texture
  18531. * @param data defines the data used to create the texture
  18532. * @param width defines the width of the texture
  18533. * @param height defines the height of the texture
  18534. * @param depth defines the depth of the texture
  18535. * @param format defines the format of the texture
  18536. * @param generateMipMaps defines if the engine must generate mip levels
  18537. * @param invertY defines if data must be stored with Y axis inverted
  18538. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18539. * @param compression defines the compressed used (can be null)
  18540. * @param textureType defines the compressed used (can be null)
  18541. * @returns a new raw 3D texture (stored in an InternalTexture)
  18542. */
  18543. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18544. /**
  18545. * Update a raw 3D texture
  18546. * @param texture defines the texture to update
  18547. * @param data defines the data to store
  18548. * @param format defines the data format
  18549. * @param invertY defines if data must be stored with Y axis inverted
  18550. */
  18551. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18552. /**
  18553. * Update a raw 3D texture
  18554. * @param texture defines the texture to update
  18555. * @param data defines the data to store
  18556. * @param format defines the data format
  18557. * @param invertY defines if data must be stored with Y axis inverted
  18558. * @param compression defines the used compression (can be null)
  18559. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18560. */
  18561. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18562. }
  18563. }
  18564. declare module BABYLON {
  18565. /**
  18566. * Raw texture can help creating a texture directly from an array of data.
  18567. * This can be super useful if you either get the data from an uncompressed source or
  18568. * if you wish to create your texture pixel by pixel.
  18569. */
  18570. export class RawTexture extends Texture {
  18571. /**
  18572. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18573. */
  18574. format: number;
  18575. private _engine;
  18576. /**
  18577. * Instantiates a new RawTexture.
  18578. * Raw texture can help creating a texture directly from an array of data.
  18579. * This can be super useful if you either get the data from an uncompressed source or
  18580. * if you wish to create your texture pixel by pixel.
  18581. * @param data define the array of data to use to create the texture
  18582. * @param width define the width of the texture
  18583. * @param height define the height of the texture
  18584. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18585. * @param scene define the scene the texture belongs to
  18586. * @param generateMipMaps define whether mip maps should be generated or not
  18587. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18588. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18589. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18590. */
  18591. constructor(data: ArrayBufferView, width: number, height: number,
  18592. /**
  18593. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18594. */
  18595. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18596. /**
  18597. * Updates the texture underlying data.
  18598. * @param data Define the new data of the texture
  18599. */
  18600. update(data: ArrayBufferView): void;
  18601. /**
  18602. * Creates a luminance texture from some data.
  18603. * @param data Define the texture data
  18604. * @param width Define the width of the texture
  18605. * @param height Define the height of the texture
  18606. * @param scene Define the scene the texture belongs to
  18607. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18608. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18609. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18610. * @returns the luminance texture
  18611. */
  18612. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18613. /**
  18614. * Creates a luminance alpha texture from some data.
  18615. * @param data Define the texture data
  18616. * @param width Define the width of the texture
  18617. * @param height Define the height of the texture
  18618. * @param scene Define the scene the texture belongs to
  18619. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18620. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18621. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18622. * @returns the luminance alpha texture
  18623. */
  18624. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18625. /**
  18626. * Creates an alpha texture from some data.
  18627. * @param data Define the texture data
  18628. * @param width Define the width of the texture
  18629. * @param height Define the height of the texture
  18630. * @param scene Define the scene the texture belongs to
  18631. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18632. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18633. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18634. * @returns the alpha texture
  18635. */
  18636. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18637. /**
  18638. * Creates a RGB texture from some data.
  18639. * @param data Define the texture data
  18640. * @param width Define the width of the texture
  18641. * @param height Define the height of the texture
  18642. * @param scene Define the scene the texture belongs to
  18643. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18644. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18645. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18646. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18647. * @returns the RGB alpha texture
  18648. */
  18649. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18650. /**
  18651. * Creates a RGBA texture from some data.
  18652. * @param data Define the texture data
  18653. * @param width Define the width of the texture
  18654. * @param height Define the height of the texture
  18655. * @param scene Define the scene the texture belongs to
  18656. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18657. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18658. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18659. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18660. * @returns the RGBA texture
  18661. */
  18662. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18663. /**
  18664. * Creates a R texture from some data.
  18665. * @param data Define the texture data
  18666. * @param width Define the width of the texture
  18667. * @param height Define the height of the texture
  18668. * @param scene Define the scene the texture belongs to
  18669. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18670. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18671. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18672. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18673. * @returns the R texture
  18674. */
  18675. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18676. }
  18677. }
  18678. declare module BABYLON {
  18679. /**
  18680. * Defines a runtime animation
  18681. */
  18682. export class RuntimeAnimation {
  18683. private _events;
  18684. /**
  18685. * The current frame of the runtime animation
  18686. */
  18687. private _currentFrame;
  18688. /**
  18689. * The animation used by the runtime animation
  18690. */
  18691. private _animation;
  18692. /**
  18693. * The target of the runtime animation
  18694. */
  18695. private _target;
  18696. /**
  18697. * The initiating animatable
  18698. */
  18699. private _host;
  18700. /**
  18701. * The original value of the runtime animation
  18702. */
  18703. private _originalValue;
  18704. /**
  18705. * The original blend value of the runtime animation
  18706. */
  18707. private _originalBlendValue;
  18708. /**
  18709. * The offsets cache of the runtime animation
  18710. */
  18711. private _offsetsCache;
  18712. /**
  18713. * The high limits cache of the runtime animation
  18714. */
  18715. private _highLimitsCache;
  18716. /**
  18717. * Specifies if the runtime animation has been stopped
  18718. */
  18719. private _stopped;
  18720. /**
  18721. * The blending factor of the runtime animation
  18722. */
  18723. private _blendingFactor;
  18724. /**
  18725. * The BabylonJS scene
  18726. */
  18727. private _scene;
  18728. /**
  18729. * The current value of the runtime animation
  18730. */
  18731. private _currentValue;
  18732. /** @hidden */
  18733. _animationState: _IAnimationState;
  18734. /**
  18735. * The active target of the runtime animation
  18736. */
  18737. private _activeTargets;
  18738. private _currentActiveTarget;
  18739. private _directTarget;
  18740. /**
  18741. * The target path of the runtime animation
  18742. */
  18743. private _targetPath;
  18744. /**
  18745. * The weight of the runtime animation
  18746. */
  18747. private _weight;
  18748. /**
  18749. * The ratio offset of the runtime animation
  18750. */
  18751. private _ratioOffset;
  18752. /**
  18753. * The previous delay of the runtime animation
  18754. */
  18755. private _previousDelay;
  18756. /**
  18757. * The previous ratio of the runtime animation
  18758. */
  18759. private _previousRatio;
  18760. private _enableBlending;
  18761. private _keys;
  18762. private _minFrame;
  18763. private _maxFrame;
  18764. private _minValue;
  18765. private _maxValue;
  18766. private _targetIsArray;
  18767. /**
  18768. * Gets the current frame of the runtime animation
  18769. */
  18770. readonly currentFrame: number;
  18771. /**
  18772. * Gets the weight of the runtime animation
  18773. */
  18774. readonly weight: number;
  18775. /**
  18776. * Gets the current value of the runtime animation
  18777. */
  18778. readonly currentValue: any;
  18779. /**
  18780. * Gets the target path of the runtime animation
  18781. */
  18782. readonly targetPath: string;
  18783. /**
  18784. * Gets the actual target of the runtime animation
  18785. */
  18786. readonly target: any;
  18787. /** @hidden */
  18788. _onLoop: () => void;
  18789. /**
  18790. * Create a new RuntimeAnimation object
  18791. * @param target defines the target of the animation
  18792. * @param animation defines the source animation object
  18793. * @param scene defines the hosting scene
  18794. * @param host defines the initiating Animatable
  18795. */
  18796. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18797. private _preparePath;
  18798. /**
  18799. * Gets the animation from the runtime animation
  18800. */
  18801. readonly animation: Animation;
  18802. /**
  18803. * Resets the runtime animation to the beginning
  18804. * @param restoreOriginal defines whether to restore the target property to the original value
  18805. */
  18806. reset(restoreOriginal?: boolean): void;
  18807. /**
  18808. * Specifies if the runtime animation is stopped
  18809. * @returns Boolean specifying if the runtime animation is stopped
  18810. */
  18811. isStopped(): boolean;
  18812. /**
  18813. * Disposes of the runtime animation
  18814. */
  18815. dispose(): void;
  18816. /**
  18817. * Apply the interpolated value to the target
  18818. * @param currentValue defines the value computed by the animation
  18819. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18820. */
  18821. setValue(currentValue: any, weight: number): void;
  18822. private _getOriginalValues;
  18823. private _setValue;
  18824. /**
  18825. * Gets the loop pmode of the runtime animation
  18826. * @returns Loop Mode
  18827. */
  18828. private _getCorrectLoopMode;
  18829. /**
  18830. * Move the current animation to a given frame
  18831. * @param frame defines the frame to move to
  18832. */
  18833. goToFrame(frame: number): void;
  18834. /**
  18835. * @hidden Internal use only
  18836. */
  18837. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18838. /**
  18839. * Execute the current animation
  18840. * @param delay defines the delay to add to the current frame
  18841. * @param from defines the lower bound of the animation range
  18842. * @param to defines the upper bound of the animation range
  18843. * @param loop defines if the current animation must loop
  18844. * @param speedRatio defines the current speed ratio
  18845. * @param weight defines the weight of the animation (default is -1 so no weight)
  18846. * @param onLoop optional callback called when animation loops
  18847. * @returns a boolean indicating if the animation is running
  18848. */
  18849. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18850. }
  18851. }
  18852. declare module BABYLON {
  18853. /**
  18854. * Class used to store an actual running animation
  18855. */
  18856. export class Animatable {
  18857. /** defines the target object */
  18858. target: any;
  18859. /** defines the starting frame number (default is 0) */
  18860. fromFrame: number;
  18861. /** defines the ending frame number (default is 100) */
  18862. toFrame: number;
  18863. /** defines if the animation must loop (default is false) */
  18864. loopAnimation: boolean;
  18865. /** defines a callback to call when animation ends if it is not looping */
  18866. onAnimationEnd?: (() => void) | null | undefined;
  18867. /** defines a callback to call when animation loops */
  18868. onAnimationLoop?: (() => void) | null | undefined;
  18869. private _localDelayOffset;
  18870. private _pausedDelay;
  18871. private _runtimeAnimations;
  18872. private _paused;
  18873. private _scene;
  18874. private _speedRatio;
  18875. private _weight;
  18876. private _syncRoot;
  18877. /**
  18878. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18879. * This will only apply for non looping animation (default is true)
  18880. */
  18881. disposeOnEnd: boolean;
  18882. /**
  18883. * Gets a boolean indicating if the animation has started
  18884. */
  18885. animationStarted: boolean;
  18886. /**
  18887. * Observer raised when the animation ends
  18888. */
  18889. onAnimationEndObservable: Observable<Animatable>;
  18890. /**
  18891. * Observer raised when the animation loops
  18892. */
  18893. onAnimationLoopObservable: Observable<Animatable>;
  18894. /**
  18895. * Gets the root Animatable used to synchronize and normalize animations
  18896. */
  18897. readonly syncRoot: Nullable<Animatable>;
  18898. /**
  18899. * Gets the current frame of the first RuntimeAnimation
  18900. * Used to synchronize Animatables
  18901. */
  18902. readonly masterFrame: number;
  18903. /**
  18904. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18905. */
  18906. weight: number;
  18907. /**
  18908. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18909. */
  18910. speedRatio: number;
  18911. /**
  18912. * Creates a new Animatable
  18913. * @param scene defines the hosting scene
  18914. * @param target defines the target object
  18915. * @param fromFrame defines the starting frame number (default is 0)
  18916. * @param toFrame defines the ending frame number (default is 100)
  18917. * @param loopAnimation defines if the animation must loop (default is false)
  18918. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18919. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18920. * @param animations defines a group of animation to add to the new Animatable
  18921. * @param onAnimationLoop defines a callback to call when animation loops
  18922. */
  18923. constructor(scene: Scene,
  18924. /** defines the target object */
  18925. target: any,
  18926. /** defines the starting frame number (default is 0) */
  18927. fromFrame?: number,
  18928. /** defines the ending frame number (default is 100) */
  18929. toFrame?: number,
  18930. /** defines if the animation must loop (default is false) */
  18931. loopAnimation?: boolean, speedRatio?: number,
  18932. /** defines a callback to call when animation ends if it is not looping */
  18933. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18934. /** defines a callback to call when animation loops */
  18935. onAnimationLoop?: (() => void) | null | undefined);
  18936. /**
  18937. * Synchronize and normalize current Animatable with a source Animatable
  18938. * This is useful when using animation weights and when animations are not of the same length
  18939. * @param root defines the root Animatable to synchronize with
  18940. * @returns the current Animatable
  18941. */
  18942. syncWith(root: Animatable): Animatable;
  18943. /**
  18944. * Gets the list of runtime animations
  18945. * @returns an array of RuntimeAnimation
  18946. */
  18947. getAnimations(): RuntimeAnimation[];
  18948. /**
  18949. * Adds more animations to the current animatable
  18950. * @param target defines the target of the animations
  18951. * @param animations defines the new animations to add
  18952. */
  18953. appendAnimations(target: any, animations: Animation[]): void;
  18954. /**
  18955. * Gets the source animation for a specific property
  18956. * @param property defines the propertyu to look for
  18957. * @returns null or the source animation for the given property
  18958. */
  18959. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18960. /**
  18961. * Gets the runtime animation for a specific property
  18962. * @param property defines the propertyu to look for
  18963. * @returns null or the runtime animation for the given property
  18964. */
  18965. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18966. /**
  18967. * Resets the animatable to its original state
  18968. */
  18969. reset(): void;
  18970. /**
  18971. * Allows the animatable to blend with current running animations
  18972. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18973. * @param blendingSpeed defines the blending speed to use
  18974. */
  18975. enableBlending(blendingSpeed: number): void;
  18976. /**
  18977. * Disable animation blending
  18978. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18979. */
  18980. disableBlending(): void;
  18981. /**
  18982. * Jump directly to a given frame
  18983. * @param frame defines the frame to jump to
  18984. */
  18985. goToFrame(frame: number): void;
  18986. /**
  18987. * Pause the animation
  18988. */
  18989. pause(): void;
  18990. /**
  18991. * Restart the animation
  18992. */
  18993. restart(): void;
  18994. private _raiseOnAnimationEnd;
  18995. /**
  18996. * Stop and delete the current animation
  18997. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18998. * @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)
  18999. */
  19000. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19001. /**
  19002. * Wait asynchronously for the animation to end
  19003. * @returns a promise which will be fullfilled when the animation ends
  19004. */
  19005. waitAsync(): Promise<Animatable>;
  19006. /** @hidden */
  19007. _animate(delay: number): boolean;
  19008. }
  19009. interface Scene {
  19010. /** @hidden */
  19011. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19012. /** @hidden */
  19013. _processLateAnimationBindingsForMatrices(holder: {
  19014. totalWeight: number;
  19015. animations: RuntimeAnimation[];
  19016. originalValue: Matrix;
  19017. }): any;
  19018. /** @hidden */
  19019. _processLateAnimationBindingsForQuaternions(holder: {
  19020. totalWeight: number;
  19021. animations: RuntimeAnimation[];
  19022. originalValue: Quaternion;
  19023. }, refQuaternion: Quaternion): Quaternion;
  19024. /** @hidden */
  19025. _processLateAnimationBindings(): void;
  19026. /**
  19027. * Will start the animation sequence of a given target
  19028. * @param target defines the target
  19029. * @param from defines from which frame should animation start
  19030. * @param to defines until which frame should animation run.
  19031. * @param weight defines the weight to apply to the animation (1.0 by default)
  19032. * @param loop defines if the animation loops
  19033. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19034. * @param onAnimationEnd defines the function to be executed when the animation ends
  19035. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19036. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19037. * @param onAnimationLoop defines the callback to call when an animation loops
  19038. * @returns the animatable object created for this animation
  19039. */
  19040. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19041. /**
  19042. * Will start the animation sequence of a given target
  19043. * @param target defines the target
  19044. * @param from defines from which frame should animation start
  19045. * @param to defines until which frame should animation run.
  19046. * @param loop defines if the animation loops
  19047. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19048. * @param onAnimationEnd defines the function to be executed when the animation ends
  19049. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19050. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19051. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19052. * @param onAnimationLoop defines the callback to call when an animation loops
  19053. * @returns the animatable object created for this animation
  19054. */
  19055. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19056. /**
  19057. * Will start the animation sequence of a given target and its hierarchy
  19058. * @param target defines the target
  19059. * @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.
  19060. * @param from defines from which frame should animation start
  19061. * @param to defines until which frame should animation run.
  19062. * @param loop defines if the animation loops
  19063. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19064. * @param onAnimationEnd defines the function to be executed when the animation ends
  19065. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19066. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19067. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19068. * @param onAnimationLoop defines the callback to call when an animation loops
  19069. * @returns the list of created animatables
  19070. */
  19071. 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[];
  19072. /**
  19073. * Begin a new animation on a given node
  19074. * @param target defines the target where the animation will take place
  19075. * @param animations defines the list of animations to start
  19076. * @param from defines the initial value
  19077. * @param to defines the final value
  19078. * @param loop defines if you want animation to loop (off by default)
  19079. * @param speedRatio defines the speed ratio to apply to all animations
  19080. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19081. * @param onAnimationLoop defines the callback to call when an animation loops
  19082. * @returns the list of created animatables
  19083. */
  19084. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19085. /**
  19086. * Begin a new animation on a given node and its hierarchy
  19087. * @param target defines the root node where the animation will take place
  19088. * @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.
  19089. * @param animations defines the list of animations to start
  19090. * @param from defines the initial value
  19091. * @param to defines the final value
  19092. * @param loop defines if you want animation to loop (off by default)
  19093. * @param speedRatio defines the speed ratio to apply to all animations
  19094. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19095. * @param onAnimationLoop defines the callback to call when an animation loops
  19096. * @returns the list of animatables created for all nodes
  19097. */
  19098. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19099. /**
  19100. * Gets the animatable associated with a specific target
  19101. * @param target defines the target of the animatable
  19102. * @returns the required animatable if found
  19103. */
  19104. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19105. /**
  19106. * Gets all animatables associated with a given target
  19107. * @param target defines the target to look animatables for
  19108. * @returns an array of Animatables
  19109. */
  19110. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19111. /**
  19112. * Stops and removes all animations that have been applied to the scene
  19113. */
  19114. stopAllAnimations(): void;
  19115. }
  19116. interface Bone {
  19117. /**
  19118. * Copy an animation range from another bone
  19119. * @param source defines the source bone
  19120. * @param rangeName defines the range name to copy
  19121. * @param frameOffset defines the frame offset
  19122. * @param rescaleAsRequired defines if rescaling must be applied if required
  19123. * @param skelDimensionsRatio defines the scaling ratio
  19124. * @returns true if operation was successful
  19125. */
  19126. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19127. }
  19128. }
  19129. declare module BABYLON {
  19130. /**
  19131. * Class used to handle skinning animations
  19132. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19133. */
  19134. export class Skeleton implements IAnimatable {
  19135. /** defines the skeleton name */
  19136. name: string;
  19137. /** defines the skeleton Id */
  19138. id: string;
  19139. /**
  19140. * Defines the list of child bones
  19141. */
  19142. bones: Bone[];
  19143. /**
  19144. * Defines an estimate of the dimension of the skeleton at rest
  19145. */
  19146. dimensionsAtRest: Vector3;
  19147. /**
  19148. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19149. */
  19150. needInitialSkinMatrix: boolean;
  19151. /**
  19152. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19153. */
  19154. overrideMesh: Nullable<AbstractMesh>;
  19155. /**
  19156. * Gets the list of animations attached to this skeleton
  19157. */
  19158. animations: Array<Animation>;
  19159. private _scene;
  19160. private _isDirty;
  19161. private _transformMatrices;
  19162. private _transformMatrixTexture;
  19163. private _meshesWithPoseMatrix;
  19164. private _animatables;
  19165. private _identity;
  19166. private _synchronizedWithMesh;
  19167. private _ranges;
  19168. private _lastAbsoluteTransformsUpdateId;
  19169. private _canUseTextureForBones;
  19170. private _uniqueId;
  19171. /** @hidden */
  19172. _numBonesWithLinkedTransformNode: number;
  19173. /** @hidden */
  19174. _hasWaitingData: Nullable<boolean>;
  19175. /**
  19176. * Specifies if the skeleton should be serialized
  19177. */
  19178. doNotSerialize: boolean;
  19179. private _useTextureToStoreBoneMatrices;
  19180. /**
  19181. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19182. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19183. */
  19184. useTextureToStoreBoneMatrices: boolean;
  19185. private _animationPropertiesOverride;
  19186. /**
  19187. * Gets or sets the animation properties override
  19188. */
  19189. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19190. /**
  19191. * List of inspectable custom properties (used by the Inspector)
  19192. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19193. */
  19194. inspectableCustomProperties: IInspectable[];
  19195. /**
  19196. * An observable triggered before computing the skeleton's matrices
  19197. */
  19198. onBeforeComputeObservable: Observable<Skeleton>;
  19199. /**
  19200. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19201. */
  19202. readonly isUsingTextureForMatrices: boolean;
  19203. /**
  19204. * Gets the unique ID of this skeleton
  19205. */
  19206. readonly uniqueId: number;
  19207. /**
  19208. * Creates a new skeleton
  19209. * @param name defines the skeleton name
  19210. * @param id defines the skeleton Id
  19211. * @param scene defines the hosting scene
  19212. */
  19213. constructor(
  19214. /** defines the skeleton name */
  19215. name: string,
  19216. /** defines the skeleton Id */
  19217. id: string, scene: Scene);
  19218. /**
  19219. * Gets the current object class name.
  19220. * @return the class name
  19221. */
  19222. getClassName(): string;
  19223. /**
  19224. * Returns an array containing the root bones
  19225. * @returns an array containing the root bones
  19226. */
  19227. getChildren(): Array<Bone>;
  19228. /**
  19229. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19230. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19231. * @returns a Float32Array containing matrices data
  19232. */
  19233. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19234. /**
  19235. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19236. * @returns a raw texture containing the data
  19237. */
  19238. getTransformMatrixTexture(): Nullable<RawTexture>;
  19239. /**
  19240. * Gets the current hosting scene
  19241. * @returns a scene object
  19242. */
  19243. getScene(): Scene;
  19244. /**
  19245. * Gets a string representing the current skeleton data
  19246. * @param fullDetails defines a boolean indicating if we want a verbose version
  19247. * @returns a string representing the current skeleton data
  19248. */
  19249. toString(fullDetails?: boolean): string;
  19250. /**
  19251. * Get bone's index searching by name
  19252. * @param name defines bone's name to search for
  19253. * @return the indice of the bone. Returns -1 if not found
  19254. */
  19255. getBoneIndexByName(name: string): number;
  19256. /**
  19257. * Creater a new animation range
  19258. * @param name defines the name of the range
  19259. * @param from defines the start key
  19260. * @param to defines the end key
  19261. */
  19262. createAnimationRange(name: string, from: number, to: number): void;
  19263. /**
  19264. * Delete a specific animation range
  19265. * @param name defines the name of the range
  19266. * @param deleteFrames defines if frames must be removed as well
  19267. */
  19268. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19269. /**
  19270. * Gets a specific animation range
  19271. * @param name defines the name of the range to look for
  19272. * @returns the requested animation range or null if not found
  19273. */
  19274. getAnimationRange(name: string): Nullable<AnimationRange>;
  19275. /**
  19276. * Gets the list of all animation ranges defined on this skeleton
  19277. * @returns an array
  19278. */
  19279. getAnimationRanges(): Nullable<AnimationRange>[];
  19280. /**
  19281. * Copy animation range from a source skeleton.
  19282. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19283. * @param source defines the source skeleton
  19284. * @param name defines the name of the range to copy
  19285. * @param rescaleAsRequired defines if rescaling must be applied if required
  19286. * @returns true if operation was successful
  19287. */
  19288. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19289. /**
  19290. * Forces the skeleton to go to rest pose
  19291. */
  19292. returnToRest(): void;
  19293. private _getHighestAnimationFrame;
  19294. /**
  19295. * Begin a specific animation range
  19296. * @param name defines the name of the range to start
  19297. * @param loop defines if looping must be turned on (false by default)
  19298. * @param speedRatio defines the speed ratio to apply (1 by default)
  19299. * @param onAnimationEnd defines a callback which will be called when animation will end
  19300. * @returns a new animatable
  19301. */
  19302. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19303. /** @hidden */
  19304. _markAsDirty(): void;
  19305. /** @hidden */
  19306. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19307. /** @hidden */
  19308. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19309. private _computeTransformMatrices;
  19310. /**
  19311. * Build all resources required to render a skeleton
  19312. */
  19313. prepare(): void;
  19314. /**
  19315. * Gets the list of animatables currently running for this skeleton
  19316. * @returns an array of animatables
  19317. */
  19318. getAnimatables(): IAnimatable[];
  19319. /**
  19320. * Clone the current skeleton
  19321. * @param name defines the name of the new skeleton
  19322. * @param id defines the id of the new skeleton
  19323. * @returns the new skeleton
  19324. */
  19325. clone(name: string, id: string): Skeleton;
  19326. /**
  19327. * Enable animation blending for this skeleton
  19328. * @param blendingSpeed defines the blending speed to apply
  19329. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19330. */
  19331. enableBlending(blendingSpeed?: number): void;
  19332. /**
  19333. * Releases all resources associated with the current skeleton
  19334. */
  19335. dispose(): void;
  19336. /**
  19337. * Serialize the skeleton in a JSON object
  19338. * @returns a JSON object
  19339. */
  19340. serialize(): any;
  19341. /**
  19342. * Creates a new skeleton from serialized data
  19343. * @param parsedSkeleton defines the serialized data
  19344. * @param scene defines the hosting scene
  19345. * @returns a new skeleton
  19346. */
  19347. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19348. /**
  19349. * Compute all node absolute transforms
  19350. * @param forceUpdate defines if computation must be done even if cache is up to date
  19351. */
  19352. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19353. /**
  19354. * Gets the root pose matrix
  19355. * @returns a matrix
  19356. */
  19357. getPoseMatrix(): Nullable<Matrix>;
  19358. /**
  19359. * Sorts bones per internal index
  19360. */
  19361. sortBones(): void;
  19362. private _sortBones;
  19363. }
  19364. }
  19365. declare module BABYLON {
  19366. /**
  19367. * Defines a target to use with MorphTargetManager
  19368. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19369. */
  19370. export class MorphTarget implements IAnimatable {
  19371. /** defines the name of the target */
  19372. name: string;
  19373. /**
  19374. * Gets or sets the list of animations
  19375. */
  19376. animations: Animation[];
  19377. private _scene;
  19378. private _positions;
  19379. private _normals;
  19380. private _tangents;
  19381. private _influence;
  19382. /**
  19383. * Observable raised when the influence changes
  19384. */
  19385. onInfluenceChanged: Observable<boolean>;
  19386. /** @hidden */
  19387. _onDataLayoutChanged: Observable<void>;
  19388. /**
  19389. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19390. */
  19391. influence: number;
  19392. /**
  19393. * Gets or sets the id of the morph Target
  19394. */
  19395. id: string;
  19396. private _animationPropertiesOverride;
  19397. /**
  19398. * Gets or sets the animation properties override
  19399. */
  19400. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19401. /**
  19402. * Creates a new MorphTarget
  19403. * @param name defines the name of the target
  19404. * @param influence defines the influence to use
  19405. * @param scene defines the scene the morphtarget belongs to
  19406. */
  19407. constructor(
  19408. /** defines the name of the target */
  19409. name: string, influence?: number, scene?: Nullable<Scene>);
  19410. /**
  19411. * Gets a boolean defining if the target contains position data
  19412. */
  19413. readonly hasPositions: boolean;
  19414. /**
  19415. * Gets a boolean defining if the target contains normal data
  19416. */
  19417. readonly hasNormals: boolean;
  19418. /**
  19419. * Gets a boolean defining if the target contains tangent data
  19420. */
  19421. readonly hasTangents: boolean;
  19422. /**
  19423. * Affects position data to this target
  19424. * @param data defines the position data to use
  19425. */
  19426. setPositions(data: Nullable<FloatArray>): void;
  19427. /**
  19428. * Gets the position data stored in this target
  19429. * @returns a FloatArray containing the position data (or null if not present)
  19430. */
  19431. getPositions(): Nullable<FloatArray>;
  19432. /**
  19433. * Affects normal data to this target
  19434. * @param data defines the normal data to use
  19435. */
  19436. setNormals(data: Nullable<FloatArray>): void;
  19437. /**
  19438. * Gets the normal data stored in this target
  19439. * @returns a FloatArray containing the normal data (or null if not present)
  19440. */
  19441. getNormals(): Nullable<FloatArray>;
  19442. /**
  19443. * Affects tangent data to this target
  19444. * @param data defines the tangent data to use
  19445. */
  19446. setTangents(data: Nullable<FloatArray>): void;
  19447. /**
  19448. * Gets the tangent data stored in this target
  19449. * @returns a FloatArray containing the tangent data (or null if not present)
  19450. */
  19451. getTangents(): Nullable<FloatArray>;
  19452. /**
  19453. * Serializes the current target into a Serialization object
  19454. * @returns the serialized object
  19455. */
  19456. serialize(): any;
  19457. /**
  19458. * Returns the string "MorphTarget"
  19459. * @returns "MorphTarget"
  19460. */
  19461. getClassName(): string;
  19462. /**
  19463. * Creates a new target from serialized data
  19464. * @param serializationObject defines the serialized data to use
  19465. * @returns a new MorphTarget
  19466. */
  19467. static Parse(serializationObject: any): MorphTarget;
  19468. /**
  19469. * Creates a MorphTarget from mesh data
  19470. * @param mesh defines the source mesh
  19471. * @param name defines the name to use for the new target
  19472. * @param influence defines the influence to attach to the target
  19473. * @returns a new MorphTarget
  19474. */
  19475. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19476. }
  19477. }
  19478. declare module BABYLON {
  19479. /**
  19480. * This class is used to deform meshes using morphing between different targets
  19481. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19482. */
  19483. export class MorphTargetManager {
  19484. private _targets;
  19485. private _targetInfluenceChangedObservers;
  19486. private _targetDataLayoutChangedObservers;
  19487. private _activeTargets;
  19488. private _scene;
  19489. private _influences;
  19490. private _supportsNormals;
  19491. private _supportsTangents;
  19492. private _vertexCount;
  19493. private _uniqueId;
  19494. private _tempInfluences;
  19495. /**
  19496. * Creates a new MorphTargetManager
  19497. * @param scene defines the current scene
  19498. */
  19499. constructor(scene?: Nullable<Scene>);
  19500. /**
  19501. * Gets the unique ID of this manager
  19502. */
  19503. readonly uniqueId: number;
  19504. /**
  19505. * Gets the number of vertices handled by this manager
  19506. */
  19507. readonly vertexCount: number;
  19508. /**
  19509. * Gets a boolean indicating if this manager supports morphing of normals
  19510. */
  19511. readonly supportsNormals: boolean;
  19512. /**
  19513. * Gets a boolean indicating if this manager supports morphing of tangents
  19514. */
  19515. readonly supportsTangents: boolean;
  19516. /**
  19517. * Gets the number of targets stored in this manager
  19518. */
  19519. readonly numTargets: number;
  19520. /**
  19521. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19522. */
  19523. readonly numInfluencers: number;
  19524. /**
  19525. * Gets the list of influences (one per target)
  19526. */
  19527. readonly influences: Float32Array;
  19528. /**
  19529. * Gets the active target at specified index. An active target is a target with an influence > 0
  19530. * @param index defines the index to check
  19531. * @returns the requested target
  19532. */
  19533. getActiveTarget(index: number): MorphTarget;
  19534. /**
  19535. * Gets the target at specified index
  19536. * @param index defines the index to check
  19537. * @returns the requested target
  19538. */
  19539. getTarget(index: number): MorphTarget;
  19540. /**
  19541. * Add a new target to this manager
  19542. * @param target defines the target to add
  19543. */
  19544. addTarget(target: MorphTarget): void;
  19545. /**
  19546. * Removes a target from the manager
  19547. * @param target defines the target to remove
  19548. */
  19549. removeTarget(target: MorphTarget): void;
  19550. /**
  19551. * Serializes the current manager into a Serialization object
  19552. * @returns the serialized object
  19553. */
  19554. serialize(): any;
  19555. private _syncActiveTargets;
  19556. /**
  19557. * Syncrhonize the targets with all the meshes using this morph target manager
  19558. */
  19559. synchronize(): void;
  19560. /**
  19561. * Creates a new MorphTargetManager from serialized data
  19562. * @param serializationObject defines the serialized data
  19563. * @param scene defines the hosting scene
  19564. * @returns the new MorphTargetManager
  19565. */
  19566. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19567. }
  19568. }
  19569. declare module BABYLON {
  19570. /**
  19571. * Class used to represent a specific level of detail of a mesh
  19572. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19573. */
  19574. export class MeshLODLevel {
  19575. /** Defines the distance where this level should star being displayed */
  19576. distance: number;
  19577. /** Defines the mesh to use to render this level */
  19578. mesh: Nullable<Mesh>;
  19579. /**
  19580. * Creates a new LOD level
  19581. * @param distance defines the distance where this level should star being displayed
  19582. * @param mesh defines the mesh to use to render this level
  19583. */
  19584. constructor(
  19585. /** Defines the distance where this level should star being displayed */
  19586. distance: number,
  19587. /** Defines the mesh to use to render this level */
  19588. mesh: Nullable<Mesh>);
  19589. }
  19590. }
  19591. declare module BABYLON {
  19592. /**
  19593. * Mesh representing the gorund
  19594. */
  19595. export class GroundMesh extends Mesh {
  19596. /** If octree should be generated */
  19597. generateOctree: boolean;
  19598. private _heightQuads;
  19599. /** @hidden */
  19600. _subdivisionsX: number;
  19601. /** @hidden */
  19602. _subdivisionsY: number;
  19603. /** @hidden */
  19604. _width: number;
  19605. /** @hidden */
  19606. _height: number;
  19607. /** @hidden */
  19608. _minX: number;
  19609. /** @hidden */
  19610. _maxX: number;
  19611. /** @hidden */
  19612. _minZ: number;
  19613. /** @hidden */
  19614. _maxZ: number;
  19615. constructor(name: string, scene: Scene);
  19616. /**
  19617. * "GroundMesh"
  19618. * @returns "GroundMesh"
  19619. */
  19620. getClassName(): string;
  19621. /**
  19622. * The minimum of x and y subdivisions
  19623. */
  19624. readonly subdivisions: number;
  19625. /**
  19626. * X subdivisions
  19627. */
  19628. readonly subdivisionsX: number;
  19629. /**
  19630. * Y subdivisions
  19631. */
  19632. readonly subdivisionsY: number;
  19633. /**
  19634. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19635. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19636. * @param chunksCount the number of subdivisions for x and y
  19637. * @param octreeBlocksSize (Default: 32)
  19638. */
  19639. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19640. /**
  19641. * Returns a height (y) value in the Worl system :
  19642. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19643. * @param x x coordinate
  19644. * @param z z coordinate
  19645. * @returns the ground y position if (x, z) are outside the ground surface.
  19646. */
  19647. getHeightAtCoordinates(x: number, z: number): number;
  19648. /**
  19649. * Returns a normalized vector (Vector3) orthogonal to the ground
  19650. * at the ground coordinates (x, z) expressed in the World system.
  19651. * @param x x coordinate
  19652. * @param z z coordinate
  19653. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19654. */
  19655. getNormalAtCoordinates(x: number, z: number): Vector3;
  19656. /**
  19657. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19658. * at the ground coordinates (x, z) expressed in the World system.
  19659. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19660. * @param x x coordinate
  19661. * @param z z coordinate
  19662. * @param ref vector to store the result
  19663. * @returns the GroundMesh.
  19664. */
  19665. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19666. /**
  19667. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19668. * if the ground has been updated.
  19669. * This can be used in the render loop.
  19670. * @returns the GroundMesh.
  19671. */
  19672. updateCoordinateHeights(): GroundMesh;
  19673. private _getFacetAt;
  19674. private _initHeightQuads;
  19675. private _computeHeightQuads;
  19676. /**
  19677. * Serializes this ground mesh
  19678. * @param serializationObject object to write serialization to
  19679. */
  19680. serialize(serializationObject: any): void;
  19681. /**
  19682. * Parses a serialized ground mesh
  19683. * @param parsedMesh the serialized mesh
  19684. * @param scene the scene to create the ground mesh in
  19685. * @returns the created ground mesh
  19686. */
  19687. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19688. }
  19689. }
  19690. declare module BABYLON {
  19691. /**
  19692. * Interface for Physics-Joint data
  19693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19694. */
  19695. export interface PhysicsJointData {
  19696. /**
  19697. * The main pivot of the joint
  19698. */
  19699. mainPivot?: Vector3;
  19700. /**
  19701. * The connected pivot of the joint
  19702. */
  19703. connectedPivot?: Vector3;
  19704. /**
  19705. * The main axis of the joint
  19706. */
  19707. mainAxis?: Vector3;
  19708. /**
  19709. * The connected axis of the joint
  19710. */
  19711. connectedAxis?: Vector3;
  19712. /**
  19713. * The collision of the joint
  19714. */
  19715. collision?: boolean;
  19716. /**
  19717. * Native Oimo/Cannon/Energy data
  19718. */
  19719. nativeParams?: any;
  19720. }
  19721. /**
  19722. * This is a holder class for the physics joint created by the physics plugin
  19723. * It holds a set of functions to control the underlying joint
  19724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19725. */
  19726. export class PhysicsJoint {
  19727. /**
  19728. * The type of the physics joint
  19729. */
  19730. type: number;
  19731. /**
  19732. * The data for the physics joint
  19733. */
  19734. jointData: PhysicsJointData;
  19735. private _physicsJoint;
  19736. protected _physicsPlugin: IPhysicsEnginePlugin;
  19737. /**
  19738. * Initializes the physics joint
  19739. * @param type The type of the physics joint
  19740. * @param jointData The data for the physics joint
  19741. */
  19742. constructor(
  19743. /**
  19744. * The type of the physics joint
  19745. */
  19746. type: number,
  19747. /**
  19748. * The data for the physics joint
  19749. */
  19750. jointData: PhysicsJointData);
  19751. /**
  19752. * Gets the physics joint
  19753. */
  19754. /**
  19755. * Sets the physics joint
  19756. */
  19757. physicsJoint: any;
  19758. /**
  19759. * Sets the physics plugin
  19760. */
  19761. physicsPlugin: IPhysicsEnginePlugin;
  19762. /**
  19763. * Execute a function that is physics-plugin specific.
  19764. * @param {Function} func the function that will be executed.
  19765. * It accepts two parameters: the physics world and the physics joint
  19766. */
  19767. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19768. /**
  19769. * Distance-Joint type
  19770. */
  19771. static DistanceJoint: number;
  19772. /**
  19773. * Hinge-Joint type
  19774. */
  19775. static HingeJoint: number;
  19776. /**
  19777. * Ball-and-Socket joint type
  19778. */
  19779. static BallAndSocketJoint: number;
  19780. /**
  19781. * Wheel-Joint type
  19782. */
  19783. static WheelJoint: number;
  19784. /**
  19785. * Slider-Joint type
  19786. */
  19787. static SliderJoint: number;
  19788. /**
  19789. * Prismatic-Joint type
  19790. */
  19791. static PrismaticJoint: number;
  19792. /**
  19793. * Universal-Joint type
  19794. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19795. */
  19796. static UniversalJoint: number;
  19797. /**
  19798. * Hinge-Joint 2 type
  19799. */
  19800. static Hinge2Joint: number;
  19801. /**
  19802. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19803. */
  19804. static PointToPointJoint: number;
  19805. /**
  19806. * Spring-Joint type
  19807. */
  19808. static SpringJoint: number;
  19809. /**
  19810. * Lock-Joint type
  19811. */
  19812. static LockJoint: number;
  19813. }
  19814. /**
  19815. * A class representing a physics distance joint
  19816. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19817. */
  19818. export class DistanceJoint extends PhysicsJoint {
  19819. /**
  19820. *
  19821. * @param jointData The data for the Distance-Joint
  19822. */
  19823. constructor(jointData: DistanceJointData);
  19824. /**
  19825. * Update the predefined distance.
  19826. * @param maxDistance The maximum preferred distance
  19827. * @param minDistance The minimum preferred distance
  19828. */
  19829. updateDistance(maxDistance: number, minDistance?: number): void;
  19830. }
  19831. /**
  19832. * Represents a Motor-Enabled Joint
  19833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19834. */
  19835. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19836. /**
  19837. * Initializes the Motor-Enabled Joint
  19838. * @param type The type of the joint
  19839. * @param jointData The physica joint data for the joint
  19840. */
  19841. constructor(type: number, jointData: PhysicsJointData);
  19842. /**
  19843. * Set the motor values.
  19844. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19845. * @param force the force to apply
  19846. * @param maxForce max force for this motor.
  19847. */
  19848. setMotor(force?: number, maxForce?: number): void;
  19849. /**
  19850. * Set the motor's limits.
  19851. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19852. * @param upperLimit The upper limit of the motor
  19853. * @param lowerLimit The lower limit of the motor
  19854. */
  19855. setLimit(upperLimit: number, lowerLimit?: number): void;
  19856. }
  19857. /**
  19858. * This class represents a single physics Hinge-Joint
  19859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19860. */
  19861. export class HingeJoint extends MotorEnabledJoint {
  19862. /**
  19863. * Initializes the Hinge-Joint
  19864. * @param jointData The joint data for the Hinge-Joint
  19865. */
  19866. constructor(jointData: PhysicsJointData);
  19867. /**
  19868. * Set the motor values.
  19869. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19870. * @param {number} force the force to apply
  19871. * @param {number} maxForce max force for this motor.
  19872. */
  19873. setMotor(force?: number, maxForce?: number): void;
  19874. /**
  19875. * Set the motor's limits.
  19876. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19877. * @param upperLimit The upper limit of the motor
  19878. * @param lowerLimit The lower limit of the motor
  19879. */
  19880. setLimit(upperLimit: number, lowerLimit?: number): void;
  19881. }
  19882. /**
  19883. * This class represents a dual hinge physics joint (same as wheel joint)
  19884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19885. */
  19886. export class Hinge2Joint extends MotorEnabledJoint {
  19887. /**
  19888. * Initializes the Hinge2-Joint
  19889. * @param jointData The joint data for the Hinge2-Joint
  19890. */
  19891. constructor(jointData: PhysicsJointData);
  19892. /**
  19893. * Set the motor values.
  19894. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19895. * @param {number} targetSpeed the speed the motor is to reach
  19896. * @param {number} maxForce max force for this motor.
  19897. * @param {motorIndex} the motor's index, 0 or 1.
  19898. */
  19899. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19900. /**
  19901. * Set the motor limits.
  19902. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19903. * @param {number} upperLimit the upper limit
  19904. * @param {number} lowerLimit lower limit
  19905. * @param {motorIndex} the motor's index, 0 or 1.
  19906. */
  19907. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19908. }
  19909. /**
  19910. * Interface for a motor enabled joint
  19911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19912. */
  19913. export interface IMotorEnabledJoint {
  19914. /**
  19915. * Physics joint
  19916. */
  19917. physicsJoint: any;
  19918. /**
  19919. * Sets the motor of the motor-enabled joint
  19920. * @param force The force of the motor
  19921. * @param maxForce The maximum force of the motor
  19922. * @param motorIndex The index of the motor
  19923. */
  19924. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19925. /**
  19926. * Sets the limit of the motor
  19927. * @param upperLimit The upper limit of the motor
  19928. * @param lowerLimit The lower limit of the motor
  19929. * @param motorIndex The index of the motor
  19930. */
  19931. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19932. }
  19933. /**
  19934. * Joint data for a Distance-Joint
  19935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19936. */
  19937. export interface DistanceJointData extends PhysicsJointData {
  19938. /**
  19939. * Max distance the 2 joint objects can be apart
  19940. */
  19941. maxDistance: number;
  19942. }
  19943. /**
  19944. * Joint data from a spring joint
  19945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19946. */
  19947. export interface SpringJointData extends PhysicsJointData {
  19948. /**
  19949. * Length of the spring
  19950. */
  19951. length: number;
  19952. /**
  19953. * Stiffness of the spring
  19954. */
  19955. stiffness: number;
  19956. /**
  19957. * Damping of the spring
  19958. */
  19959. damping: number;
  19960. /** this callback will be called when applying the force to the impostors. */
  19961. forceApplicationCallback: () => void;
  19962. }
  19963. }
  19964. declare module BABYLON {
  19965. /**
  19966. * Holds the data for the raycast result
  19967. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19968. */
  19969. export class PhysicsRaycastResult {
  19970. private _hasHit;
  19971. private _hitDistance;
  19972. private _hitNormalWorld;
  19973. private _hitPointWorld;
  19974. private _rayFromWorld;
  19975. private _rayToWorld;
  19976. /**
  19977. * Gets if there was a hit
  19978. */
  19979. readonly hasHit: boolean;
  19980. /**
  19981. * Gets the distance from the hit
  19982. */
  19983. readonly hitDistance: number;
  19984. /**
  19985. * Gets the hit normal/direction in the world
  19986. */
  19987. readonly hitNormalWorld: Vector3;
  19988. /**
  19989. * Gets the hit point in the world
  19990. */
  19991. readonly hitPointWorld: Vector3;
  19992. /**
  19993. * Gets the ray "start point" of the ray in the world
  19994. */
  19995. readonly rayFromWorld: Vector3;
  19996. /**
  19997. * Gets the ray "end point" of the ray in the world
  19998. */
  19999. readonly rayToWorld: Vector3;
  20000. /**
  20001. * Sets the hit data (normal & point in world space)
  20002. * @param hitNormalWorld defines the normal in world space
  20003. * @param hitPointWorld defines the point in world space
  20004. */
  20005. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20006. /**
  20007. * Sets the distance from the start point to the hit point
  20008. * @param distance
  20009. */
  20010. setHitDistance(distance: number): void;
  20011. /**
  20012. * Calculates the distance manually
  20013. */
  20014. calculateHitDistance(): void;
  20015. /**
  20016. * Resets all the values to default
  20017. * @param from The from point on world space
  20018. * @param to The to point on world space
  20019. */
  20020. reset(from?: Vector3, to?: Vector3): void;
  20021. }
  20022. /**
  20023. * Interface for the size containing width and height
  20024. */
  20025. interface IXYZ {
  20026. /**
  20027. * X
  20028. */
  20029. x: number;
  20030. /**
  20031. * Y
  20032. */
  20033. y: number;
  20034. /**
  20035. * Z
  20036. */
  20037. z: number;
  20038. }
  20039. }
  20040. declare module BABYLON {
  20041. /**
  20042. * Interface used to describe a physics joint
  20043. */
  20044. export interface PhysicsImpostorJoint {
  20045. /** Defines the main impostor to which the joint is linked */
  20046. mainImpostor: PhysicsImpostor;
  20047. /** Defines the impostor that is connected to the main impostor using this joint */
  20048. connectedImpostor: PhysicsImpostor;
  20049. /** Defines the joint itself */
  20050. joint: PhysicsJoint;
  20051. }
  20052. /** @hidden */
  20053. export interface IPhysicsEnginePlugin {
  20054. world: any;
  20055. name: string;
  20056. setGravity(gravity: Vector3): void;
  20057. setTimeStep(timeStep: number): void;
  20058. getTimeStep(): number;
  20059. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20060. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20061. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20062. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20063. removePhysicsBody(impostor: PhysicsImpostor): void;
  20064. generateJoint(joint: PhysicsImpostorJoint): void;
  20065. removeJoint(joint: PhysicsImpostorJoint): void;
  20066. isSupported(): boolean;
  20067. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20068. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20069. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20070. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20071. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20072. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20073. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20074. getBodyMass(impostor: PhysicsImpostor): number;
  20075. getBodyFriction(impostor: PhysicsImpostor): number;
  20076. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20077. getBodyRestitution(impostor: PhysicsImpostor): number;
  20078. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20079. getBodyPressure?(impostor: PhysicsImpostor): number;
  20080. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20081. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20082. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20083. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20084. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20085. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20086. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20087. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20088. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20089. sleepBody(impostor: PhysicsImpostor): void;
  20090. wakeUpBody(impostor: PhysicsImpostor): void;
  20091. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20092. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20093. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20094. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20095. getRadius(impostor: PhysicsImpostor): number;
  20096. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20097. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20098. dispose(): void;
  20099. }
  20100. /**
  20101. * Interface used to define a physics engine
  20102. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20103. */
  20104. export interface IPhysicsEngine {
  20105. /**
  20106. * Gets the gravity vector used by the simulation
  20107. */
  20108. gravity: Vector3;
  20109. /**
  20110. * Sets the gravity vector used by the simulation
  20111. * @param gravity defines the gravity vector to use
  20112. */
  20113. setGravity(gravity: Vector3): void;
  20114. /**
  20115. * Set the time step of the physics engine.
  20116. * Default is 1/60.
  20117. * To slow it down, enter 1/600 for example.
  20118. * To speed it up, 1/30
  20119. * @param newTimeStep the new timestep to apply to this world.
  20120. */
  20121. setTimeStep(newTimeStep: number): void;
  20122. /**
  20123. * Get the time step of the physics engine.
  20124. * @returns the current time step
  20125. */
  20126. getTimeStep(): number;
  20127. /**
  20128. * Release all resources
  20129. */
  20130. dispose(): void;
  20131. /**
  20132. * Gets the name of the current physics plugin
  20133. * @returns the name of the plugin
  20134. */
  20135. getPhysicsPluginName(): string;
  20136. /**
  20137. * Adding a new impostor for the impostor tracking.
  20138. * This will be done by the impostor itself.
  20139. * @param impostor the impostor to add
  20140. */
  20141. addImpostor(impostor: PhysicsImpostor): void;
  20142. /**
  20143. * Remove an impostor from the engine.
  20144. * This impostor and its mesh will not longer be updated by the physics engine.
  20145. * @param impostor the impostor to remove
  20146. */
  20147. removeImpostor(impostor: PhysicsImpostor): void;
  20148. /**
  20149. * Add a joint to the physics engine
  20150. * @param mainImpostor defines the main impostor to which the joint is added.
  20151. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20152. * @param joint defines the joint that will connect both impostors.
  20153. */
  20154. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20155. /**
  20156. * Removes a joint from the simulation
  20157. * @param mainImpostor defines the impostor used with the joint
  20158. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20159. * @param joint defines the joint to remove
  20160. */
  20161. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20162. /**
  20163. * Gets the current plugin used to run the simulation
  20164. * @returns current plugin
  20165. */
  20166. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20167. /**
  20168. * Gets the list of physic impostors
  20169. * @returns an array of PhysicsImpostor
  20170. */
  20171. getImpostors(): Array<PhysicsImpostor>;
  20172. /**
  20173. * Gets the impostor for a physics enabled object
  20174. * @param object defines the object impersonated by the impostor
  20175. * @returns the PhysicsImpostor or null if not found
  20176. */
  20177. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20178. /**
  20179. * Gets the impostor for a physics body object
  20180. * @param body defines physics body used by the impostor
  20181. * @returns the PhysicsImpostor or null if not found
  20182. */
  20183. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20184. /**
  20185. * Does a raycast in the physics world
  20186. * @param from when should the ray start?
  20187. * @param to when should the ray end?
  20188. * @returns PhysicsRaycastResult
  20189. */
  20190. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20191. /**
  20192. * Called by the scene. No need to call it.
  20193. * @param delta defines the timespam between frames
  20194. */
  20195. _step(delta: number): void;
  20196. }
  20197. }
  20198. declare module BABYLON {
  20199. /**
  20200. * The interface for the physics imposter parameters
  20201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20202. */
  20203. export interface PhysicsImpostorParameters {
  20204. /**
  20205. * The mass of the physics imposter
  20206. */
  20207. mass: number;
  20208. /**
  20209. * The friction of the physics imposter
  20210. */
  20211. friction?: number;
  20212. /**
  20213. * The coefficient of restitution of the physics imposter
  20214. */
  20215. restitution?: number;
  20216. /**
  20217. * The native options of the physics imposter
  20218. */
  20219. nativeOptions?: any;
  20220. /**
  20221. * Specifies if the parent should be ignored
  20222. */
  20223. ignoreParent?: boolean;
  20224. /**
  20225. * Specifies if bi-directional transformations should be disabled
  20226. */
  20227. disableBidirectionalTransformation?: boolean;
  20228. /**
  20229. * The pressure inside the physics imposter, soft object only
  20230. */
  20231. pressure?: number;
  20232. /**
  20233. * The stiffness the physics imposter, soft object only
  20234. */
  20235. stiffness?: number;
  20236. /**
  20237. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20238. */
  20239. velocityIterations?: number;
  20240. /**
  20241. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20242. */
  20243. positionIterations?: number;
  20244. /**
  20245. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20246. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20247. * Add to fix multiple points
  20248. */
  20249. fixedPoints?: number;
  20250. /**
  20251. * The collision margin around a soft object
  20252. */
  20253. margin?: number;
  20254. /**
  20255. * The collision margin around a soft object
  20256. */
  20257. damping?: number;
  20258. /**
  20259. * The path for a rope based on an extrusion
  20260. */
  20261. path?: any;
  20262. /**
  20263. * The shape of an extrusion used for a rope based on an extrusion
  20264. */
  20265. shape?: any;
  20266. }
  20267. /**
  20268. * Interface for a physics-enabled object
  20269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20270. */
  20271. export interface IPhysicsEnabledObject {
  20272. /**
  20273. * The position of the physics-enabled object
  20274. */
  20275. position: Vector3;
  20276. /**
  20277. * The rotation of the physics-enabled object
  20278. */
  20279. rotationQuaternion: Nullable<Quaternion>;
  20280. /**
  20281. * The scale of the physics-enabled object
  20282. */
  20283. scaling: Vector3;
  20284. /**
  20285. * The rotation of the physics-enabled object
  20286. */
  20287. rotation?: Vector3;
  20288. /**
  20289. * The parent of the physics-enabled object
  20290. */
  20291. parent?: any;
  20292. /**
  20293. * The bounding info of the physics-enabled object
  20294. * @returns The bounding info of the physics-enabled object
  20295. */
  20296. getBoundingInfo(): BoundingInfo;
  20297. /**
  20298. * Computes the world matrix
  20299. * @param force Specifies if the world matrix should be computed by force
  20300. * @returns A world matrix
  20301. */
  20302. computeWorldMatrix(force: boolean): Matrix;
  20303. /**
  20304. * Gets the world matrix
  20305. * @returns A world matrix
  20306. */
  20307. getWorldMatrix?(): Matrix;
  20308. /**
  20309. * Gets the child meshes
  20310. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20311. * @returns An array of abstract meshes
  20312. */
  20313. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20314. /**
  20315. * Gets the vertex data
  20316. * @param kind The type of vertex data
  20317. * @returns A nullable array of numbers, or a float32 array
  20318. */
  20319. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20320. /**
  20321. * Gets the indices from the mesh
  20322. * @returns A nullable array of index arrays
  20323. */
  20324. getIndices?(): Nullable<IndicesArray>;
  20325. /**
  20326. * Gets the scene from the mesh
  20327. * @returns the indices array or null
  20328. */
  20329. getScene?(): Scene;
  20330. /**
  20331. * Gets the absolute position from the mesh
  20332. * @returns the absolute position
  20333. */
  20334. getAbsolutePosition(): Vector3;
  20335. /**
  20336. * Gets the absolute pivot point from the mesh
  20337. * @returns the absolute pivot point
  20338. */
  20339. getAbsolutePivotPoint(): Vector3;
  20340. /**
  20341. * Rotates the mesh
  20342. * @param axis The axis of rotation
  20343. * @param amount The amount of rotation
  20344. * @param space The space of the rotation
  20345. * @returns The rotation transform node
  20346. */
  20347. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20348. /**
  20349. * Translates the mesh
  20350. * @param axis The axis of translation
  20351. * @param distance The distance of translation
  20352. * @param space The space of the translation
  20353. * @returns The transform node
  20354. */
  20355. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20356. /**
  20357. * Sets the absolute position of the mesh
  20358. * @param absolutePosition The absolute position of the mesh
  20359. * @returns The transform node
  20360. */
  20361. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20362. /**
  20363. * Gets the class name of the mesh
  20364. * @returns The class name
  20365. */
  20366. getClassName(): string;
  20367. }
  20368. /**
  20369. * Represents a physics imposter
  20370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20371. */
  20372. export class PhysicsImpostor {
  20373. /**
  20374. * The physics-enabled object used as the physics imposter
  20375. */
  20376. object: IPhysicsEnabledObject;
  20377. /**
  20378. * The type of the physics imposter
  20379. */
  20380. type: number;
  20381. private _options;
  20382. private _scene?;
  20383. /**
  20384. * The default object size of the imposter
  20385. */
  20386. static DEFAULT_OBJECT_SIZE: Vector3;
  20387. /**
  20388. * The identity quaternion of the imposter
  20389. */
  20390. static IDENTITY_QUATERNION: Quaternion;
  20391. /** @hidden */
  20392. _pluginData: any;
  20393. private _physicsEngine;
  20394. private _physicsBody;
  20395. private _bodyUpdateRequired;
  20396. private _onBeforePhysicsStepCallbacks;
  20397. private _onAfterPhysicsStepCallbacks;
  20398. /** @hidden */
  20399. _onPhysicsCollideCallbacks: Array<{
  20400. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20401. otherImpostors: Array<PhysicsImpostor>;
  20402. }>;
  20403. private _deltaPosition;
  20404. private _deltaRotation;
  20405. private _deltaRotationConjugated;
  20406. /** hidden */
  20407. _isFromLine: boolean;
  20408. private _parent;
  20409. private _isDisposed;
  20410. private static _tmpVecs;
  20411. private static _tmpQuat;
  20412. /**
  20413. * Specifies if the physics imposter is disposed
  20414. */
  20415. readonly isDisposed: boolean;
  20416. /**
  20417. * Gets the mass of the physics imposter
  20418. */
  20419. mass: number;
  20420. /**
  20421. * Gets the coefficient of friction
  20422. */
  20423. /**
  20424. * Sets the coefficient of friction
  20425. */
  20426. friction: number;
  20427. /**
  20428. * Gets the coefficient of restitution
  20429. */
  20430. /**
  20431. * Sets the coefficient of restitution
  20432. */
  20433. restitution: number;
  20434. /**
  20435. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20436. */
  20437. /**
  20438. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20439. */
  20440. pressure: number;
  20441. /**
  20442. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20443. */
  20444. /**
  20445. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20446. */
  20447. stiffness: number;
  20448. /**
  20449. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20450. */
  20451. /**
  20452. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20453. */
  20454. velocityIterations: number;
  20455. /**
  20456. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20457. */
  20458. /**
  20459. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20460. */
  20461. positionIterations: number;
  20462. /**
  20463. * The unique id of the physics imposter
  20464. * set by the physics engine when adding this impostor to the array
  20465. */
  20466. uniqueId: number;
  20467. /**
  20468. * @hidden
  20469. */
  20470. soft: boolean;
  20471. /**
  20472. * @hidden
  20473. */
  20474. segments: number;
  20475. private _joints;
  20476. /**
  20477. * Initializes the physics imposter
  20478. * @param object The physics-enabled object used as the physics imposter
  20479. * @param type The type of the physics imposter
  20480. * @param _options The options for the physics imposter
  20481. * @param _scene The Babylon scene
  20482. */
  20483. constructor(
  20484. /**
  20485. * The physics-enabled object used as the physics imposter
  20486. */
  20487. object: IPhysicsEnabledObject,
  20488. /**
  20489. * The type of the physics imposter
  20490. */
  20491. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20492. /**
  20493. * This function will completly initialize this impostor.
  20494. * It will create a new body - but only if this mesh has no parent.
  20495. * If it has, this impostor will not be used other than to define the impostor
  20496. * of the child mesh.
  20497. * @hidden
  20498. */
  20499. _init(): void;
  20500. private _getPhysicsParent;
  20501. /**
  20502. * Should a new body be generated.
  20503. * @returns boolean specifying if body initialization is required
  20504. */
  20505. isBodyInitRequired(): boolean;
  20506. /**
  20507. * Sets the updated scaling
  20508. * @param updated Specifies if the scaling is updated
  20509. */
  20510. setScalingUpdated(): void;
  20511. /**
  20512. * Force a regeneration of this or the parent's impostor's body.
  20513. * Use under cautious - This will remove all joints already implemented.
  20514. */
  20515. forceUpdate(): void;
  20516. /**
  20517. * Gets the body that holds this impostor. Either its own, or its parent.
  20518. */
  20519. /**
  20520. * Set the physics body. Used mainly by the physics engine/plugin
  20521. */
  20522. physicsBody: any;
  20523. /**
  20524. * Get the parent of the physics imposter
  20525. * @returns Physics imposter or null
  20526. */
  20527. /**
  20528. * Sets the parent of the physics imposter
  20529. */
  20530. parent: Nullable<PhysicsImpostor>;
  20531. /**
  20532. * Resets the update flags
  20533. */
  20534. resetUpdateFlags(): void;
  20535. /**
  20536. * Gets the object extend size
  20537. * @returns the object extend size
  20538. */
  20539. getObjectExtendSize(): Vector3;
  20540. /**
  20541. * Gets the object center
  20542. * @returns The object center
  20543. */
  20544. getObjectCenter(): Vector3;
  20545. /**
  20546. * Get a specific parametes from the options parameter
  20547. * @param paramName The object parameter name
  20548. * @returns The object parameter
  20549. */
  20550. getParam(paramName: string): any;
  20551. /**
  20552. * Sets a specific parameter in the options given to the physics plugin
  20553. * @param paramName The parameter name
  20554. * @param value The value of the parameter
  20555. */
  20556. setParam(paramName: string, value: number): void;
  20557. /**
  20558. * Specifically change the body's mass option. Won't recreate the physics body object
  20559. * @param mass The mass of the physics imposter
  20560. */
  20561. setMass(mass: number): void;
  20562. /**
  20563. * Gets the linear velocity
  20564. * @returns linear velocity or null
  20565. */
  20566. getLinearVelocity(): Nullable<Vector3>;
  20567. /**
  20568. * Sets the linear velocity
  20569. * @param velocity linear velocity or null
  20570. */
  20571. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20572. /**
  20573. * Gets the angular velocity
  20574. * @returns angular velocity or null
  20575. */
  20576. getAngularVelocity(): Nullable<Vector3>;
  20577. /**
  20578. * Sets the angular velocity
  20579. * @param velocity The velocity or null
  20580. */
  20581. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20582. /**
  20583. * Execute a function with the physics plugin native code
  20584. * Provide a function the will have two variables - the world object and the physics body object
  20585. * @param func The function to execute with the physics plugin native code
  20586. */
  20587. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20588. /**
  20589. * Register a function that will be executed before the physics world is stepping forward
  20590. * @param func The function to execute before the physics world is stepped forward
  20591. */
  20592. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20593. /**
  20594. * Unregister a function that will be executed before the physics world is stepping forward
  20595. * @param func The function to execute before the physics world is stepped forward
  20596. */
  20597. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20598. /**
  20599. * Register a function that will be executed after the physics step
  20600. * @param func The function to execute after physics step
  20601. */
  20602. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20603. /**
  20604. * Unregisters a function that will be executed after the physics step
  20605. * @param func The function to execute after physics step
  20606. */
  20607. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20608. /**
  20609. * register a function that will be executed when this impostor collides against a different body
  20610. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20611. * @param func Callback that is executed on collision
  20612. */
  20613. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20614. /**
  20615. * Unregisters the physics imposter on contact
  20616. * @param collideAgainst The physics object to collide against
  20617. * @param func Callback to execute on collision
  20618. */
  20619. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20620. private _tmpQuat;
  20621. private _tmpQuat2;
  20622. /**
  20623. * Get the parent rotation
  20624. * @returns The parent rotation
  20625. */
  20626. getParentsRotation(): Quaternion;
  20627. /**
  20628. * this function is executed by the physics engine.
  20629. */
  20630. beforeStep: () => void;
  20631. /**
  20632. * this function is executed by the physics engine
  20633. */
  20634. afterStep: () => void;
  20635. /**
  20636. * Legacy collision detection event support
  20637. */
  20638. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20639. /**
  20640. * event and body object due to cannon's event-based architecture.
  20641. */
  20642. onCollide: (e: {
  20643. body: any;
  20644. }) => void;
  20645. /**
  20646. * Apply a force
  20647. * @param force The force to apply
  20648. * @param contactPoint The contact point for the force
  20649. * @returns The physics imposter
  20650. */
  20651. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20652. /**
  20653. * Apply an impulse
  20654. * @param force The impulse force
  20655. * @param contactPoint The contact point for the impulse force
  20656. * @returns The physics imposter
  20657. */
  20658. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20659. /**
  20660. * A help function to create a joint
  20661. * @param otherImpostor A physics imposter used to create a joint
  20662. * @param jointType The type of joint
  20663. * @param jointData The data for the joint
  20664. * @returns The physics imposter
  20665. */
  20666. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20667. /**
  20668. * Add a joint to this impostor with a different impostor
  20669. * @param otherImpostor A physics imposter used to add a joint
  20670. * @param joint The joint to add
  20671. * @returns The physics imposter
  20672. */
  20673. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20674. /**
  20675. * Add an anchor to a cloth impostor
  20676. * @param otherImpostor rigid impostor to anchor to
  20677. * @param width ratio across width from 0 to 1
  20678. * @param height ratio up height from 0 to 1
  20679. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20680. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20681. * @returns impostor the soft imposter
  20682. */
  20683. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20684. /**
  20685. * Add a hook to a rope impostor
  20686. * @param otherImpostor rigid impostor to anchor to
  20687. * @param length ratio across rope from 0 to 1
  20688. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20689. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20690. * @returns impostor the rope imposter
  20691. */
  20692. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20693. /**
  20694. * Will keep this body still, in a sleep mode.
  20695. * @returns the physics imposter
  20696. */
  20697. sleep(): PhysicsImpostor;
  20698. /**
  20699. * Wake the body up.
  20700. * @returns The physics imposter
  20701. */
  20702. wakeUp(): PhysicsImpostor;
  20703. /**
  20704. * Clones the physics imposter
  20705. * @param newObject The physics imposter clones to this physics-enabled object
  20706. * @returns A nullable physics imposter
  20707. */
  20708. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20709. /**
  20710. * Disposes the physics imposter
  20711. */
  20712. dispose(): void;
  20713. /**
  20714. * Sets the delta position
  20715. * @param position The delta position amount
  20716. */
  20717. setDeltaPosition(position: Vector3): void;
  20718. /**
  20719. * Sets the delta rotation
  20720. * @param rotation The delta rotation amount
  20721. */
  20722. setDeltaRotation(rotation: Quaternion): void;
  20723. /**
  20724. * Gets the box size of the physics imposter and stores the result in the input parameter
  20725. * @param result Stores the box size
  20726. * @returns The physics imposter
  20727. */
  20728. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20729. /**
  20730. * Gets the radius of the physics imposter
  20731. * @returns Radius of the physics imposter
  20732. */
  20733. getRadius(): number;
  20734. /**
  20735. * Sync a bone with this impostor
  20736. * @param bone The bone to sync to the impostor.
  20737. * @param boneMesh The mesh that the bone is influencing.
  20738. * @param jointPivot The pivot of the joint / bone in local space.
  20739. * @param distToJoint Optional distance from the impostor to the joint.
  20740. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20741. */
  20742. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20743. /**
  20744. * Sync impostor to a bone
  20745. * @param bone The bone that the impostor will be synced to.
  20746. * @param boneMesh The mesh that the bone is influencing.
  20747. * @param jointPivot The pivot of the joint / bone in local space.
  20748. * @param distToJoint Optional distance from the impostor to the joint.
  20749. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20750. * @param boneAxis Optional vector3 axis the bone is aligned with
  20751. */
  20752. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20753. /**
  20754. * No-Imposter type
  20755. */
  20756. static NoImpostor: number;
  20757. /**
  20758. * Sphere-Imposter type
  20759. */
  20760. static SphereImpostor: number;
  20761. /**
  20762. * Box-Imposter type
  20763. */
  20764. static BoxImpostor: number;
  20765. /**
  20766. * Plane-Imposter type
  20767. */
  20768. static PlaneImpostor: number;
  20769. /**
  20770. * Mesh-imposter type
  20771. */
  20772. static MeshImpostor: number;
  20773. /**
  20774. * Cylinder-Imposter type
  20775. */
  20776. static CylinderImpostor: number;
  20777. /**
  20778. * Particle-Imposter type
  20779. */
  20780. static ParticleImpostor: number;
  20781. /**
  20782. * Heightmap-Imposter type
  20783. */
  20784. static HeightmapImpostor: number;
  20785. /**
  20786. * ConvexHull-Impostor type (Ammo.js plugin only)
  20787. */
  20788. static ConvexHullImpostor: number;
  20789. /**
  20790. * Rope-Imposter type
  20791. */
  20792. static RopeImpostor: number;
  20793. /**
  20794. * Cloth-Imposter type
  20795. */
  20796. static ClothImpostor: number;
  20797. /**
  20798. * Softbody-Imposter type
  20799. */
  20800. static SoftbodyImpostor: number;
  20801. }
  20802. }
  20803. declare module BABYLON {
  20804. /**
  20805. * @hidden
  20806. **/
  20807. export class _CreationDataStorage {
  20808. closePath?: boolean;
  20809. closeArray?: boolean;
  20810. idx: number[];
  20811. dashSize: number;
  20812. gapSize: number;
  20813. path3D: Path3D;
  20814. pathArray: Vector3[][];
  20815. arc: number;
  20816. radius: number;
  20817. cap: number;
  20818. tessellation: number;
  20819. }
  20820. /**
  20821. * @hidden
  20822. **/
  20823. class _InstanceDataStorage {
  20824. visibleInstances: any;
  20825. batchCache: _InstancesBatch;
  20826. instancesBufferSize: number;
  20827. instancesBuffer: Nullable<Buffer>;
  20828. instancesData: Float32Array;
  20829. overridenInstanceCount: number;
  20830. isFrozen: boolean;
  20831. previousBatch: _InstancesBatch;
  20832. hardwareInstancedRendering: boolean;
  20833. sideOrientation: number;
  20834. }
  20835. /**
  20836. * @hidden
  20837. **/
  20838. export class _InstancesBatch {
  20839. mustReturn: boolean;
  20840. visibleInstances: Nullable<InstancedMesh[]>[];
  20841. renderSelf: boolean[];
  20842. hardwareInstancedRendering: boolean[];
  20843. }
  20844. /**
  20845. * Class used to represent renderable models
  20846. */
  20847. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20848. /**
  20849. * Mesh side orientation : usually the external or front surface
  20850. */
  20851. static readonly FRONTSIDE: number;
  20852. /**
  20853. * Mesh side orientation : usually the internal or back surface
  20854. */
  20855. static readonly BACKSIDE: number;
  20856. /**
  20857. * Mesh side orientation : both internal and external or front and back surfaces
  20858. */
  20859. static readonly DOUBLESIDE: number;
  20860. /**
  20861. * Mesh side orientation : by default, `FRONTSIDE`
  20862. */
  20863. static readonly DEFAULTSIDE: number;
  20864. /**
  20865. * Mesh cap setting : no cap
  20866. */
  20867. static readonly NO_CAP: number;
  20868. /**
  20869. * Mesh cap setting : one cap at the beginning of the mesh
  20870. */
  20871. static readonly CAP_START: number;
  20872. /**
  20873. * Mesh cap setting : one cap at the end of the mesh
  20874. */
  20875. static readonly CAP_END: number;
  20876. /**
  20877. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20878. */
  20879. static readonly CAP_ALL: number;
  20880. /**
  20881. * Gets the default side orientation.
  20882. * @param orientation the orientation to value to attempt to get
  20883. * @returns the default orientation
  20884. * @hidden
  20885. */
  20886. static _GetDefaultSideOrientation(orientation?: number): number;
  20887. private _internalMeshDataInfo;
  20888. /**
  20889. * An event triggered before rendering the mesh
  20890. */
  20891. readonly onBeforeRenderObservable: Observable<Mesh>;
  20892. /**
  20893. * An event triggered before binding the mesh
  20894. */
  20895. readonly onBeforeBindObservable: Observable<Mesh>;
  20896. /**
  20897. * An event triggered after rendering the mesh
  20898. */
  20899. readonly onAfterRenderObservable: Observable<Mesh>;
  20900. /**
  20901. * An event triggered before drawing the mesh
  20902. */
  20903. readonly onBeforeDrawObservable: Observable<Mesh>;
  20904. private _onBeforeDrawObserver;
  20905. /**
  20906. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20907. */
  20908. onBeforeDraw: () => void;
  20909. /**
  20910. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20911. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20912. */
  20913. delayLoadState: number;
  20914. /**
  20915. * Gets the list of instances created from this mesh
  20916. * it is not supposed to be modified manually.
  20917. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20918. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20919. */
  20920. instances: InstancedMesh[];
  20921. /**
  20922. * Gets the file containing delay loading data for this mesh
  20923. */
  20924. delayLoadingFile: string;
  20925. /** @hidden */
  20926. _binaryInfo: any;
  20927. /**
  20928. * User defined function used to change how LOD level selection is done
  20929. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20930. */
  20931. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20932. /**
  20933. * Gets or sets the morph target manager
  20934. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20935. */
  20936. morphTargetManager: Nullable<MorphTargetManager>;
  20937. /** @hidden */
  20938. _creationDataStorage: Nullable<_CreationDataStorage>;
  20939. /** @hidden */
  20940. _geometry: Nullable<Geometry>;
  20941. /** @hidden */
  20942. _delayInfo: Array<string>;
  20943. /** @hidden */
  20944. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20945. /** @hidden */
  20946. _instanceDataStorage: _InstanceDataStorage;
  20947. private _effectiveMaterial;
  20948. /** @hidden */
  20949. _shouldGenerateFlatShading: boolean;
  20950. /** @hidden */
  20951. _originalBuilderSideOrientation: number;
  20952. /**
  20953. * Use this property to change the original side orientation defined at construction time
  20954. */
  20955. overrideMaterialSideOrientation: Nullable<number>;
  20956. /**
  20957. * Gets the source mesh (the one used to clone this one from)
  20958. */
  20959. readonly source: Nullable<Mesh>;
  20960. /**
  20961. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20962. */
  20963. isUnIndexed: boolean;
  20964. /**
  20965. * @constructor
  20966. * @param name The value used by scene.getMeshByName() to do a lookup.
  20967. * @param scene The scene to add this mesh to.
  20968. * @param parent The parent of this mesh, if it has one
  20969. * @param source An optional Mesh from which geometry is shared, cloned.
  20970. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20971. * When false, achieved by calling a clone(), also passing False.
  20972. * This will make creation of children, recursive.
  20973. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20974. */
  20975. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20976. /**
  20977. * Gets the class name
  20978. * @returns the string "Mesh".
  20979. */
  20980. getClassName(): string;
  20981. /** @hidden */
  20982. readonly _isMesh: boolean;
  20983. /**
  20984. * Returns a description of this mesh
  20985. * @param fullDetails define if full details about this mesh must be used
  20986. * @returns a descriptive string representing this mesh
  20987. */
  20988. toString(fullDetails?: boolean): string;
  20989. /** @hidden */
  20990. _unBindEffect(): void;
  20991. /**
  20992. * Gets a boolean indicating if this mesh has LOD
  20993. */
  20994. readonly hasLODLevels: boolean;
  20995. /**
  20996. * Gets the list of MeshLODLevel associated with the current mesh
  20997. * @returns an array of MeshLODLevel
  20998. */
  20999. getLODLevels(): MeshLODLevel[];
  21000. private _sortLODLevels;
  21001. /**
  21002. * Add a mesh as LOD level triggered at the given distance.
  21003. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21004. * @param distance The distance from the center of the object to show this level
  21005. * @param mesh The mesh to be added as LOD level (can be null)
  21006. * @return This mesh (for chaining)
  21007. */
  21008. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21009. /**
  21010. * Returns the LOD level mesh at the passed distance or null if not found.
  21011. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21012. * @param distance The distance from the center of the object to show this level
  21013. * @returns a Mesh or `null`
  21014. */
  21015. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21016. /**
  21017. * Remove a mesh from the LOD array
  21018. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21019. * @param mesh defines the mesh to be removed
  21020. * @return This mesh (for chaining)
  21021. */
  21022. removeLODLevel(mesh: Mesh): Mesh;
  21023. /**
  21024. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21025. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21026. * @param camera defines the camera to use to compute distance
  21027. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21028. * @return This mesh (for chaining)
  21029. */
  21030. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21031. /**
  21032. * Gets the mesh internal Geometry object
  21033. */
  21034. readonly geometry: Nullable<Geometry>;
  21035. /**
  21036. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21037. * @returns the total number of vertices
  21038. */
  21039. getTotalVertices(): number;
  21040. /**
  21041. * Returns the content of an associated vertex buffer
  21042. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21043. * - VertexBuffer.PositionKind
  21044. * - VertexBuffer.UVKind
  21045. * - VertexBuffer.UV2Kind
  21046. * - VertexBuffer.UV3Kind
  21047. * - VertexBuffer.UV4Kind
  21048. * - VertexBuffer.UV5Kind
  21049. * - VertexBuffer.UV6Kind
  21050. * - VertexBuffer.ColorKind
  21051. * - VertexBuffer.MatricesIndicesKind
  21052. * - VertexBuffer.MatricesIndicesExtraKind
  21053. * - VertexBuffer.MatricesWeightsKind
  21054. * - VertexBuffer.MatricesWeightsExtraKind
  21055. * @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
  21056. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21057. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21058. */
  21059. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21060. /**
  21061. * Returns the mesh VertexBuffer object from the requested `kind`
  21062. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21063. * - VertexBuffer.PositionKind
  21064. * - VertexBuffer.UVKind
  21065. * - VertexBuffer.UV2Kind
  21066. * - VertexBuffer.UV3Kind
  21067. * - VertexBuffer.UV4Kind
  21068. * - VertexBuffer.UV5Kind
  21069. * - VertexBuffer.UV6Kind
  21070. * - VertexBuffer.ColorKind
  21071. * - VertexBuffer.MatricesIndicesKind
  21072. * - VertexBuffer.MatricesIndicesExtraKind
  21073. * - VertexBuffer.MatricesWeightsKind
  21074. * - VertexBuffer.MatricesWeightsExtraKind
  21075. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21076. */
  21077. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21078. /**
  21079. * Tests if a specific vertex buffer is associated with this mesh
  21080. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21081. * - VertexBuffer.PositionKind
  21082. * - VertexBuffer.UVKind
  21083. * - VertexBuffer.UV2Kind
  21084. * - VertexBuffer.UV3Kind
  21085. * - VertexBuffer.UV4Kind
  21086. * - VertexBuffer.UV5Kind
  21087. * - VertexBuffer.UV6Kind
  21088. * - VertexBuffer.ColorKind
  21089. * - VertexBuffer.MatricesIndicesKind
  21090. * - VertexBuffer.MatricesIndicesExtraKind
  21091. * - VertexBuffer.MatricesWeightsKind
  21092. * - VertexBuffer.MatricesWeightsExtraKind
  21093. * @returns a boolean
  21094. */
  21095. isVerticesDataPresent(kind: string): boolean;
  21096. /**
  21097. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21098. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21099. * - VertexBuffer.PositionKind
  21100. * - VertexBuffer.UVKind
  21101. * - VertexBuffer.UV2Kind
  21102. * - VertexBuffer.UV3Kind
  21103. * - VertexBuffer.UV4Kind
  21104. * - VertexBuffer.UV5Kind
  21105. * - VertexBuffer.UV6Kind
  21106. * - VertexBuffer.ColorKind
  21107. * - VertexBuffer.MatricesIndicesKind
  21108. * - VertexBuffer.MatricesIndicesExtraKind
  21109. * - VertexBuffer.MatricesWeightsKind
  21110. * - VertexBuffer.MatricesWeightsExtraKind
  21111. * @returns a boolean
  21112. */
  21113. isVertexBufferUpdatable(kind: string): boolean;
  21114. /**
  21115. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21116. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21117. * - VertexBuffer.PositionKind
  21118. * - VertexBuffer.UVKind
  21119. * - VertexBuffer.UV2Kind
  21120. * - VertexBuffer.UV3Kind
  21121. * - VertexBuffer.UV4Kind
  21122. * - VertexBuffer.UV5Kind
  21123. * - VertexBuffer.UV6Kind
  21124. * - VertexBuffer.ColorKind
  21125. * - VertexBuffer.MatricesIndicesKind
  21126. * - VertexBuffer.MatricesIndicesExtraKind
  21127. * - VertexBuffer.MatricesWeightsKind
  21128. * - VertexBuffer.MatricesWeightsExtraKind
  21129. * @returns an array of strings
  21130. */
  21131. getVerticesDataKinds(): string[];
  21132. /**
  21133. * Returns a positive integer : the total number of indices in this mesh geometry.
  21134. * @returns the numner of indices or zero if the mesh has no geometry.
  21135. */
  21136. getTotalIndices(): number;
  21137. /**
  21138. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21139. * @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.
  21140. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21141. * @returns the indices array or an empty array if the mesh has no geometry
  21142. */
  21143. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21144. readonly isBlocked: boolean;
  21145. /**
  21146. * Determine if the current mesh is ready to be rendered
  21147. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21148. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21149. * @returns true if all associated assets are ready (material, textures, shaders)
  21150. */
  21151. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21152. /**
  21153. * 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.
  21154. */
  21155. readonly areNormalsFrozen: boolean;
  21156. /**
  21157. * 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.
  21158. * @returns the current mesh
  21159. */
  21160. freezeNormals(): Mesh;
  21161. /**
  21162. * 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
  21163. * @returns the current mesh
  21164. */
  21165. unfreezeNormals(): Mesh;
  21166. /**
  21167. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21168. */
  21169. overridenInstanceCount: number;
  21170. /** @hidden */
  21171. _preActivate(): Mesh;
  21172. /** @hidden */
  21173. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21174. /** @hidden */
  21175. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21176. /**
  21177. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21178. * This means the mesh underlying bounding box and sphere are recomputed.
  21179. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21180. * @returns the current mesh
  21181. */
  21182. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21183. /** @hidden */
  21184. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21185. /**
  21186. * This function will subdivide the mesh into multiple submeshes
  21187. * @param count defines the expected number of submeshes
  21188. */
  21189. subdivide(count: number): void;
  21190. /**
  21191. * Copy a FloatArray into a specific associated vertex buffer
  21192. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21193. * - VertexBuffer.PositionKind
  21194. * - VertexBuffer.UVKind
  21195. * - VertexBuffer.UV2Kind
  21196. * - VertexBuffer.UV3Kind
  21197. * - VertexBuffer.UV4Kind
  21198. * - VertexBuffer.UV5Kind
  21199. * - VertexBuffer.UV6Kind
  21200. * - VertexBuffer.ColorKind
  21201. * - VertexBuffer.MatricesIndicesKind
  21202. * - VertexBuffer.MatricesIndicesExtraKind
  21203. * - VertexBuffer.MatricesWeightsKind
  21204. * - VertexBuffer.MatricesWeightsExtraKind
  21205. * @param data defines the data source
  21206. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21207. * @param stride defines the data stride size (can be null)
  21208. * @returns the current mesh
  21209. */
  21210. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21211. /**
  21212. * Flags an associated vertex buffer as updatable
  21213. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21214. * - VertexBuffer.PositionKind
  21215. * - VertexBuffer.UVKind
  21216. * - VertexBuffer.UV2Kind
  21217. * - VertexBuffer.UV3Kind
  21218. * - VertexBuffer.UV4Kind
  21219. * - VertexBuffer.UV5Kind
  21220. * - VertexBuffer.UV6Kind
  21221. * - VertexBuffer.ColorKind
  21222. * - VertexBuffer.MatricesIndicesKind
  21223. * - VertexBuffer.MatricesIndicesExtraKind
  21224. * - VertexBuffer.MatricesWeightsKind
  21225. * - VertexBuffer.MatricesWeightsExtraKind
  21226. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21227. */
  21228. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21229. /**
  21230. * Sets the mesh global Vertex Buffer
  21231. * @param buffer defines the buffer to use
  21232. * @returns the current mesh
  21233. */
  21234. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21235. /**
  21236. * Update a specific associated vertex buffer
  21237. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21238. * - VertexBuffer.PositionKind
  21239. * - VertexBuffer.UVKind
  21240. * - VertexBuffer.UV2Kind
  21241. * - VertexBuffer.UV3Kind
  21242. * - VertexBuffer.UV4Kind
  21243. * - VertexBuffer.UV5Kind
  21244. * - VertexBuffer.UV6Kind
  21245. * - VertexBuffer.ColorKind
  21246. * - VertexBuffer.MatricesIndicesKind
  21247. * - VertexBuffer.MatricesIndicesExtraKind
  21248. * - VertexBuffer.MatricesWeightsKind
  21249. * - VertexBuffer.MatricesWeightsExtraKind
  21250. * @param data defines the data source
  21251. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21252. * @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)
  21253. * @returns the current mesh
  21254. */
  21255. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21256. /**
  21257. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21258. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21259. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21260. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21261. * @returns the current mesh
  21262. */
  21263. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21264. /**
  21265. * Creates a un-shared specific occurence of the geometry for the mesh.
  21266. * @returns the current mesh
  21267. */
  21268. makeGeometryUnique(): Mesh;
  21269. /**
  21270. * Set the index buffer of this mesh
  21271. * @param indices defines the source data
  21272. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21273. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21274. * @returns the current mesh
  21275. */
  21276. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21277. /**
  21278. * Update the current index buffer
  21279. * @param indices defines the source data
  21280. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21281. * @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)
  21282. * @returns the current mesh
  21283. */
  21284. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21285. /**
  21286. * Invert the geometry to move from a right handed system to a left handed one.
  21287. * @returns the current mesh
  21288. */
  21289. toLeftHanded(): Mesh;
  21290. /** @hidden */
  21291. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21292. /** @hidden */
  21293. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21294. /**
  21295. * Registers for this mesh a javascript function called just before the rendering process
  21296. * @param func defines the function to call before rendering this mesh
  21297. * @returns the current mesh
  21298. */
  21299. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21300. /**
  21301. * Disposes a previously registered javascript function called before the rendering
  21302. * @param func defines the function to remove
  21303. * @returns the current mesh
  21304. */
  21305. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21306. /**
  21307. * Registers for this mesh a javascript function called just after the rendering is complete
  21308. * @param func defines the function to call after rendering this mesh
  21309. * @returns the current mesh
  21310. */
  21311. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21312. /**
  21313. * Disposes a previously registered javascript function called after the rendering.
  21314. * @param func defines the function to remove
  21315. * @returns the current mesh
  21316. */
  21317. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21318. /** @hidden */
  21319. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21320. /** @hidden */
  21321. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21322. /** @hidden */
  21323. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21324. /** @hidden */
  21325. _freeze(): void;
  21326. /** @hidden */
  21327. _unFreeze(): void;
  21328. /**
  21329. * 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
  21330. * @param subMesh defines the subMesh to render
  21331. * @param enableAlphaMode defines if alpha mode can be changed
  21332. * @returns the current mesh
  21333. */
  21334. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21335. private _onBeforeDraw;
  21336. /**
  21337. * Renormalize the mesh and patch it up if there are no weights
  21338. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21339. * However in the case of zero weights then we set just a single influence to 1.
  21340. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21341. */
  21342. cleanMatrixWeights(): void;
  21343. private normalizeSkinFourWeights;
  21344. private normalizeSkinWeightsAndExtra;
  21345. /**
  21346. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21347. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21348. * the user know there was an issue with importing the mesh
  21349. * @returns a validation object with skinned, valid and report string
  21350. */
  21351. validateSkinning(): {
  21352. skinned: boolean;
  21353. valid: boolean;
  21354. report: string;
  21355. };
  21356. /** @hidden */
  21357. _checkDelayState(): Mesh;
  21358. private _queueLoad;
  21359. /**
  21360. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21361. * A mesh is in the frustum if its bounding box intersects the frustum
  21362. * @param frustumPlanes defines the frustum to test
  21363. * @returns true if the mesh is in the frustum planes
  21364. */
  21365. isInFrustum(frustumPlanes: Plane[]): boolean;
  21366. /**
  21367. * Sets the mesh material by the material or multiMaterial `id` property
  21368. * @param id is a string identifying the material or the multiMaterial
  21369. * @returns the current mesh
  21370. */
  21371. setMaterialByID(id: string): Mesh;
  21372. /**
  21373. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21374. * @returns an array of IAnimatable
  21375. */
  21376. getAnimatables(): IAnimatable[];
  21377. /**
  21378. * Modifies the mesh geometry according to the passed transformation matrix.
  21379. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21380. * The mesh normals are modified using the same transformation.
  21381. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21382. * @param transform defines the transform matrix to use
  21383. * @see http://doc.babylonjs.com/resources/baking_transformations
  21384. * @returns the current mesh
  21385. */
  21386. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21387. /**
  21388. * Modifies the mesh geometry according to its own current World Matrix.
  21389. * The mesh World Matrix is then reset.
  21390. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21391. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21392. * @see http://doc.babylonjs.com/resources/baking_transformations
  21393. * @returns the current mesh
  21394. */
  21395. bakeCurrentTransformIntoVertices(): Mesh;
  21396. /** @hidden */
  21397. readonly _positions: Nullable<Vector3[]>;
  21398. /** @hidden */
  21399. _resetPointsArrayCache(): Mesh;
  21400. /** @hidden */
  21401. _generatePointsArray(): boolean;
  21402. /**
  21403. * Returns a new Mesh object generated from the current mesh properties.
  21404. * This method must not get confused with createInstance()
  21405. * @param name is a string, the name given to the new mesh
  21406. * @param newParent can be any Node object (default `null`)
  21407. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21408. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21409. * @returns a new mesh
  21410. */
  21411. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21412. /**
  21413. * Releases resources associated with this mesh.
  21414. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21415. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21416. */
  21417. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21418. /**
  21419. * Modifies the mesh geometry according to a displacement map.
  21420. * 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.
  21421. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21422. * @param url is a string, the URL from the image file is to be downloaded.
  21423. * @param minHeight is the lower limit of the displacement.
  21424. * @param maxHeight is the upper limit of the displacement.
  21425. * @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.
  21426. * @param uvOffset is an optional vector2 used to offset UV.
  21427. * @param uvScale is an optional vector2 used to scale UV.
  21428. * @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.
  21429. * @returns the Mesh.
  21430. */
  21431. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21432. /**
  21433. * Modifies the mesh geometry according to a displacementMap buffer.
  21434. * 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.
  21435. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21436. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21437. * @param heightMapWidth is the width of the buffer image.
  21438. * @param heightMapHeight is the height of the buffer image.
  21439. * @param minHeight is the lower limit of the displacement.
  21440. * @param maxHeight is the upper limit of the displacement.
  21441. * @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.
  21442. * @param uvOffset is an optional vector2 used to offset UV.
  21443. * @param uvScale is an optional vector2 used to scale UV.
  21444. * @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.
  21445. * @returns the Mesh.
  21446. */
  21447. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21448. /**
  21449. * Modify the mesh to get a flat shading rendering.
  21450. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21451. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21452. * @returns current mesh
  21453. */
  21454. convertToFlatShadedMesh(): Mesh;
  21455. /**
  21456. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21457. * In other words, more vertices, no more indices and a single bigger VBO.
  21458. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21459. * @returns current mesh
  21460. */
  21461. convertToUnIndexedMesh(): Mesh;
  21462. /**
  21463. * Inverses facet orientations.
  21464. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21465. * @param flipNormals will also inverts the normals
  21466. * @returns current mesh
  21467. */
  21468. flipFaces(flipNormals?: boolean): Mesh;
  21469. /**
  21470. * Increase the number of facets and hence vertices in a mesh
  21471. * Vertex normals are interpolated from existing vertex normals
  21472. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21473. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21474. */
  21475. increaseVertices(numberPerEdge: number): void;
  21476. /**
  21477. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21478. * This will undo any application of covertToFlatShadedMesh
  21479. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21480. */
  21481. forceSharedVertices(): void;
  21482. /** @hidden */
  21483. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21484. /** @hidden */
  21485. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21486. /**
  21487. * Creates a new InstancedMesh object from the mesh model.
  21488. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21489. * @param name defines the name of the new instance
  21490. * @returns a new InstancedMesh
  21491. */
  21492. createInstance(name: string): InstancedMesh;
  21493. /**
  21494. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21495. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21496. * @returns the current mesh
  21497. */
  21498. synchronizeInstances(): Mesh;
  21499. /**
  21500. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21501. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21502. * This should be used together with the simplification to avoid disappearing triangles.
  21503. * @param successCallback an optional success callback to be called after the optimization finished.
  21504. * @returns the current mesh
  21505. */
  21506. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21507. /**
  21508. * Serialize current mesh
  21509. * @param serializationObject defines the object which will receive the serialization data
  21510. */
  21511. serialize(serializationObject: any): void;
  21512. /** @hidden */
  21513. _syncGeometryWithMorphTargetManager(): void;
  21514. /** @hidden */
  21515. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21516. /**
  21517. * Returns a new Mesh object parsed from the source provided.
  21518. * @param parsedMesh is the source
  21519. * @param scene defines the hosting scene
  21520. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21521. * @returns a new Mesh
  21522. */
  21523. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21524. /**
  21525. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21526. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21527. * @param name defines the name of the mesh to create
  21528. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21529. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21530. * @param closePath creates a seam between the first and the last points of each path of the path array
  21531. * @param offset is taken in account only if the `pathArray` is containing a single path
  21532. * @param scene defines the hosting scene
  21533. * @param updatable defines if the mesh must be flagged as updatable
  21534. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21535. * @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)
  21536. * @returns a new Mesh
  21537. */
  21538. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21539. /**
  21540. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21541. * @param name defines the name of the mesh to create
  21542. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21543. * @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
  21544. * @param scene defines the hosting scene
  21545. * @param updatable defines if the mesh must be flagged as updatable
  21546. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21547. * @returns a new Mesh
  21548. */
  21549. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21550. /**
  21551. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21552. * @param name defines the name of the mesh to create
  21553. * @param size sets the size (float) of each box side (default 1)
  21554. * @param scene defines the hosting scene
  21555. * @param updatable defines if the mesh must be flagged as updatable
  21556. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21557. * @returns a new Mesh
  21558. */
  21559. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21560. /**
  21561. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21562. * @param name defines the name of the mesh to create
  21563. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21564. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21565. * @param scene defines the hosting scene
  21566. * @param updatable defines if the mesh must be flagged as updatable
  21567. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21568. * @returns a new Mesh
  21569. */
  21570. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21571. /**
  21572. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21573. * @param name defines the name of the mesh to create
  21574. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21575. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21576. * @param scene defines the hosting scene
  21577. * @returns a new Mesh
  21578. */
  21579. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21580. /**
  21581. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21582. * @param name defines the name of the mesh to create
  21583. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21584. * @param diameterTop set the top cap diameter (floats, default 1)
  21585. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21586. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21587. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21588. * @param scene defines the hosting scene
  21589. * @param updatable defines if the mesh must be flagged as updatable
  21590. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21591. * @returns a new Mesh
  21592. */
  21593. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21594. /**
  21595. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21596. * @param name defines the name of the mesh to create
  21597. * @param diameter sets the diameter size (float) of the torus (default 1)
  21598. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21599. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21600. * @param scene defines the hosting scene
  21601. * @param updatable defines if the mesh must be flagged as updatable
  21602. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21603. * @returns a new Mesh
  21604. */
  21605. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21606. /**
  21607. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21608. * @param name defines the name of the mesh to create
  21609. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21610. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21611. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21612. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21613. * @param p the number of windings on X axis (positive integers, default 2)
  21614. * @param q the number of windings on Y axis (positive integers, default 3)
  21615. * @param scene defines the hosting scene
  21616. * @param updatable defines if the mesh must be flagged as updatable
  21617. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21618. * @returns a new Mesh
  21619. */
  21620. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21621. /**
  21622. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21623. * @param name defines the name of the mesh to create
  21624. * @param points is an array successive Vector3
  21625. * @param scene defines the hosting scene
  21626. * @param updatable defines if the mesh must be flagged as updatable
  21627. * @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).
  21628. * @returns a new Mesh
  21629. */
  21630. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21631. /**
  21632. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21633. * @param name defines the name of the mesh to create
  21634. * @param points is an array successive Vector3
  21635. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21636. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21637. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21638. * @param scene defines the hosting scene
  21639. * @param updatable defines if the mesh must be flagged as updatable
  21640. * @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)
  21641. * @returns a new Mesh
  21642. */
  21643. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21644. /**
  21645. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21646. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21647. * 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.
  21648. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21649. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21650. * Remember you can only change the shape positions, not their number when updating a polygon.
  21651. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21652. * @param name defines the name of the mesh to create
  21653. * @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
  21654. * @param scene defines the hosting scene
  21655. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21656. * @param updatable defines if the mesh must be flagged as updatable
  21657. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21658. * @param earcutInjection can be used to inject your own earcut reference
  21659. * @returns a new Mesh
  21660. */
  21661. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21662. /**
  21663. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21664. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21665. * @param name defines the name of the mesh to create
  21666. * @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
  21667. * @param depth defines the height of extrusion
  21668. * @param scene defines the hosting scene
  21669. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21670. * @param updatable defines if the mesh must be flagged as updatable
  21671. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21672. * @param earcutInjection can be used to inject your own earcut reference
  21673. * @returns a new Mesh
  21674. */
  21675. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21676. /**
  21677. * Creates an extruded shape mesh.
  21678. * 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
  21679. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21680. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21681. * @param name defines the name of the mesh to create
  21682. * @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
  21683. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21684. * @param scale is the value to scale the shape
  21685. * @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
  21686. * @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
  21687. * @param scene defines the hosting scene
  21688. * @param updatable defines if the mesh must be flagged as updatable
  21689. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21690. * @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)
  21691. * @returns a new Mesh
  21692. */
  21693. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21694. /**
  21695. * Creates an custom extruded shape mesh.
  21696. * The custom extrusion is a parametric shape.
  21697. * It has no predefined shape. Its final shape will depend on the input parameters.
  21698. * Please consider using the same method from the MeshBuilder class instead
  21699. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21700. * @param name defines the name of the mesh to create
  21701. * @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
  21702. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21703. * @param scaleFunction is a custom Javascript function called on each path point
  21704. * @param rotationFunction is a custom Javascript function called on each path point
  21705. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21706. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21707. * @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
  21708. * @param scene defines the hosting scene
  21709. * @param updatable defines if the mesh must be flagged as updatable
  21710. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21711. * @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)
  21712. * @returns a new Mesh
  21713. */
  21714. 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;
  21715. /**
  21716. * Creates lathe mesh.
  21717. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21718. * Please consider using the same method from the MeshBuilder class instead
  21719. * @param name defines the name of the mesh to create
  21720. * @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
  21721. * @param radius is the radius value of the lathe
  21722. * @param tessellation is the side number of the lathe.
  21723. * @param scene defines the hosting scene
  21724. * @param updatable defines if the mesh must be flagged as updatable
  21725. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21726. * @returns a new Mesh
  21727. */
  21728. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21729. /**
  21730. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21731. * @param name defines the name of the mesh to create
  21732. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21733. * @param scene defines the hosting scene
  21734. * @param updatable defines if the mesh must be flagged as updatable
  21735. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21736. * @returns a new Mesh
  21737. */
  21738. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21739. /**
  21740. * Creates a ground mesh.
  21741. * Please consider using the same method from the MeshBuilder class instead
  21742. * @param name defines the name of the mesh to create
  21743. * @param width set the width of the ground
  21744. * @param height set the height of the ground
  21745. * @param subdivisions sets the number of subdivisions per side
  21746. * @param scene defines the hosting scene
  21747. * @param updatable defines if the mesh must be flagged as updatable
  21748. * @returns a new Mesh
  21749. */
  21750. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21751. /**
  21752. * Creates a tiled ground mesh.
  21753. * Please consider using the same method from the MeshBuilder class instead
  21754. * @param name defines the name of the mesh to create
  21755. * @param xmin set the ground minimum X coordinate
  21756. * @param zmin set the ground minimum Y coordinate
  21757. * @param xmax set the ground maximum X coordinate
  21758. * @param zmax set the ground maximum Z coordinate
  21759. * @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
  21760. * @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
  21761. * @param scene defines the hosting scene
  21762. * @param updatable defines if the mesh must be flagged as updatable
  21763. * @returns a new Mesh
  21764. */
  21765. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21766. w: number;
  21767. h: number;
  21768. }, precision: {
  21769. w: number;
  21770. h: number;
  21771. }, scene: Scene, updatable?: boolean): Mesh;
  21772. /**
  21773. * Creates a ground mesh from a height map.
  21774. * Please consider using the same method from the MeshBuilder class instead
  21775. * @see http://doc.babylonjs.com/babylon101/height_map
  21776. * @param name defines the name of the mesh to create
  21777. * @param url sets the URL of the height map image resource
  21778. * @param width set the ground width size
  21779. * @param height set the ground height size
  21780. * @param subdivisions sets the number of subdivision per side
  21781. * @param minHeight is the minimum altitude on the ground
  21782. * @param maxHeight is the maximum altitude on the ground
  21783. * @param scene defines the hosting scene
  21784. * @param updatable defines if the mesh must be flagged as updatable
  21785. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21786. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21787. * @returns a new Mesh
  21788. */
  21789. 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;
  21790. /**
  21791. * Creates a tube mesh.
  21792. * The tube is a parametric shape.
  21793. * It has no predefined shape. Its final shape will depend on the input parameters.
  21794. * Please consider using the same method from the MeshBuilder class instead
  21795. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21796. * @param name defines the name of the mesh to create
  21797. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21798. * @param radius sets the tube radius size
  21799. * @param tessellation is the number of sides on the tubular surface
  21800. * @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
  21801. * @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
  21802. * @param scene defines the hosting scene
  21803. * @param updatable defines if the mesh must be flagged as updatable
  21804. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21805. * @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)
  21806. * @returns a new Mesh
  21807. */
  21808. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21809. (i: number, distance: number): number;
  21810. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21811. /**
  21812. * Creates a polyhedron mesh.
  21813. * Please consider using the same method from the MeshBuilder class instead.
  21814. * * 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
  21815. * * The parameter `size` (positive float, default 1) sets the polygon size
  21816. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21817. * * 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`
  21818. * * 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
  21819. * * 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)`)
  21820. * * 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
  21821. * * 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
  21822. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21823. * * 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
  21824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21825. * @param name defines the name of the mesh to create
  21826. * @param options defines the options used to create the mesh
  21827. * @param scene defines the hosting scene
  21828. * @returns a new Mesh
  21829. */
  21830. static CreatePolyhedron(name: string, options: {
  21831. type?: number;
  21832. size?: number;
  21833. sizeX?: number;
  21834. sizeY?: number;
  21835. sizeZ?: number;
  21836. custom?: any;
  21837. faceUV?: Vector4[];
  21838. faceColors?: Color4[];
  21839. updatable?: boolean;
  21840. sideOrientation?: number;
  21841. }, scene: Scene): Mesh;
  21842. /**
  21843. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21844. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21845. * * 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`)
  21846. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21847. * * 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
  21848. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21849. * * 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
  21850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21851. * @param name defines the name of the mesh
  21852. * @param options defines the options used to create the mesh
  21853. * @param scene defines the hosting scene
  21854. * @returns a new Mesh
  21855. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21856. */
  21857. static CreateIcoSphere(name: string, options: {
  21858. radius?: number;
  21859. flat?: boolean;
  21860. subdivisions?: number;
  21861. sideOrientation?: number;
  21862. updatable?: boolean;
  21863. }, scene: Scene): Mesh;
  21864. /**
  21865. * Creates a decal mesh.
  21866. * Please consider using the same method from the MeshBuilder class instead.
  21867. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21868. * @param name defines the name of the mesh
  21869. * @param sourceMesh defines the mesh receiving the decal
  21870. * @param position sets the position of the decal in world coordinates
  21871. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21872. * @param size sets the decal scaling
  21873. * @param angle sets the angle to rotate the decal
  21874. * @returns a new Mesh
  21875. */
  21876. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21877. /**
  21878. * Prepare internal position array for software CPU skinning
  21879. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21880. */
  21881. setPositionsForCPUSkinning(): Float32Array;
  21882. /**
  21883. * Prepare internal normal array for software CPU skinning
  21884. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21885. */
  21886. setNormalsForCPUSkinning(): Float32Array;
  21887. /**
  21888. * Updates the vertex buffer by applying transformation from the bones
  21889. * @param skeleton defines the skeleton to apply to current mesh
  21890. * @returns the current mesh
  21891. */
  21892. applySkeleton(skeleton: Skeleton): Mesh;
  21893. /**
  21894. * 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
  21895. * @param meshes defines the list of meshes to scan
  21896. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21897. */
  21898. static MinMax(meshes: AbstractMesh[]): {
  21899. min: Vector3;
  21900. max: Vector3;
  21901. };
  21902. /**
  21903. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21904. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21905. * @returns a vector3
  21906. */
  21907. static Center(meshesOrMinMaxVector: {
  21908. min: Vector3;
  21909. max: Vector3;
  21910. } | AbstractMesh[]): Vector3;
  21911. /**
  21912. * Merge the array of meshes into a single mesh for performance reasons.
  21913. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21914. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21915. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21916. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21917. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21918. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21919. * @returns a new mesh
  21920. */
  21921. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21922. /** @hidden */
  21923. addInstance(instance: InstancedMesh): void;
  21924. /** @hidden */
  21925. removeInstance(instance: InstancedMesh): void;
  21926. }
  21927. }
  21928. declare module BABYLON {
  21929. /**
  21930. * Base class for the main features of a material in Babylon.js
  21931. */
  21932. export class Material implements IAnimatable {
  21933. /**
  21934. * Returns the triangle fill mode
  21935. */
  21936. static readonly TriangleFillMode: number;
  21937. /**
  21938. * Returns the wireframe mode
  21939. */
  21940. static readonly WireFrameFillMode: number;
  21941. /**
  21942. * Returns the point fill mode
  21943. */
  21944. static readonly PointFillMode: number;
  21945. /**
  21946. * Returns the point list draw mode
  21947. */
  21948. static readonly PointListDrawMode: number;
  21949. /**
  21950. * Returns the line list draw mode
  21951. */
  21952. static readonly LineListDrawMode: number;
  21953. /**
  21954. * Returns the line loop draw mode
  21955. */
  21956. static readonly LineLoopDrawMode: number;
  21957. /**
  21958. * Returns the line strip draw mode
  21959. */
  21960. static readonly LineStripDrawMode: number;
  21961. /**
  21962. * Returns the triangle strip draw mode
  21963. */
  21964. static readonly TriangleStripDrawMode: number;
  21965. /**
  21966. * Returns the triangle fan draw mode
  21967. */
  21968. static readonly TriangleFanDrawMode: number;
  21969. /**
  21970. * Stores the clock-wise side orientation
  21971. */
  21972. static readonly ClockWiseSideOrientation: number;
  21973. /**
  21974. * Stores the counter clock-wise side orientation
  21975. */
  21976. static readonly CounterClockWiseSideOrientation: number;
  21977. /**
  21978. * The dirty texture flag value
  21979. */
  21980. static readonly TextureDirtyFlag: number;
  21981. /**
  21982. * The dirty light flag value
  21983. */
  21984. static readonly LightDirtyFlag: number;
  21985. /**
  21986. * The dirty fresnel flag value
  21987. */
  21988. static readonly FresnelDirtyFlag: number;
  21989. /**
  21990. * The dirty attribute flag value
  21991. */
  21992. static readonly AttributesDirtyFlag: number;
  21993. /**
  21994. * The dirty misc flag value
  21995. */
  21996. static readonly MiscDirtyFlag: number;
  21997. /**
  21998. * The all dirty flag value
  21999. */
  22000. static readonly AllDirtyFlag: number;
  22001. /**
  22002. * The ID of the material
  22003. */
  22004. id: string;
  22005. /**
  22006. * Gets or sets the unique id of the material
  22007. */
  22008. uniqueId: number;
  22009. /**
  22010. * The name of the material
  22011. */
  22012. name: string;
  22013. /**
  22014. * Gets or sets user defined metadata
  22015. */
  22016. metadata: any;
  22017. /**
  22018. * For internal use only. Please do not use.
  22019. */
  22020. reservedDataStore: any;
  22021. /**
  22022. * Specifies if the ready state should be checked on each call
  22023. */
  22024. checkReadyOnEveryCall: boolean;
  22025. /**
  22026. * Specifies if the ready state should be checked once
  22027. */
  22028. checkReadyOnlyOnce: boolean;
  22029. /**
  22030. * The state of the material
  22031. */
  22032. state: string;
  22033. /**
  22034. * The alpha value of the material
  22035. */
  22036. protected _alpha: number;
  22037. /**
  22038. * List of inspectable custom properties (used by the Inspector)
  22039. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22040. */
  22041. inspectableCustomProperties: IInspectable[];
  22042. /**
  22043. * Sets the alpha value of the material
  22044. */
  22045. /**
  22046. * Gets the alpha value of the material
  22047. */
  22048. alpha: number;
  22049. /**
  22050. * Specifies if back face culling is enabled
  22051. */
  22052. protected _backFaceCulling: boolean;
  22053. /**
  22054. * Sets the back-face culling state
  22055. */
  22056. /**
  22057. * Gets the back-face culling state
  22058. */
  22059. backFaceCulling: boolean;
  22060. /**
  22061. * Stores the value for side orientation
  22062. */
  22063. sideOrientation: number;
  22064. /**
  22065. * Callback triggered when the material is compiled
  22066. */
  22067. onCompiled: Nullable<(effect: Effect) => void>;
  22068. /**
  22069. * Callback triggered when an error occurs
  22070. */
  22071. onError: Nullable<(effect: Effect, errors: string) => void>;
  22072. /**
  22073. * Callback triggered to get the render target textures
  22074. */
  22075. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22076. /**
  22077. * Gets a boolean indicating that current material needs to register RTT
  22078. */
  22079. readonly hasRenderTargetTextures: boolean;
  22080. /**
  22081. * Specifies if the material should be serialized
  22082. */
  22083. doNotSerialize: boolean;
  22084. /**
  22085. * @hidden
  22086. */
  22087. _storeEffectOnSubMeshes: boolean;
  22088. /**
  22089. * Stores the animations for the material
  22090. */
  22091. animations: Nullable<Array<Animation>>;
  22092. /**
  22093. * An event triggered when the material is disposed
  22094. */
  22095. onDisposeObservable: Observable<Material>;
  22096. /**
  22097. * An observer which watches for dispose events
  22098. */
  22099. private _onDisposeObserver;
  22100. private _onUnBindObservable;
  22101. /**
  22102. * Called during a dispose event
  22103. */
  22104. onDispose: () => void;
  22105. private _onBindObservable;
  22106. /**
  22107. * An event triggered when the material is bound
  22108. */
  22109. readonly onBindObservable: Observable<AbstractMesh>;
  22110. /**
  22111. * An observer which watches for bind events
  22112. */
  22113. private _onBindObserver;
  22114. /**
  22115. * Called during a bind event
  22116. */
  22117. onBind: (Mesh: AbstractMesh) => void;
  22118. /**
  22119. * An event triggered when the material is unbound
  22120. */
  22121. readonly onUnBindObservable: Observable<Material>;
  22122. /**
  22123. * Stores the value of the alpha mode
  22124. */
  22125. private _alphaMode;
  22126. /**
  22127. * Sets the value of the alpha mode.
  22128. *
  22129. * | Value | Type | Description |
  22130. * | --- | --- | --- |
  22131. * | 0 | ALPHA_DISABLE | |
  22132. * | 1 | ALPHA_ADD | |
  22133. * | 2 | ALPHA_COMBINE | |
  22134. * | 3 | ALPHA_SUBTRACT | |
  22135. * | 4 | ALPHA_MULTIPLY | |
  22136. * | 5 | ALPHA_MAXIMIZED | |
  22137. * | 6 | ALPHA_ONEONE | |
  22138. * | 7 | ALPHA_PREMULTIPLIED | |
  22139. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22140. * | 9 | ALPHA_INTERPOLATE | |
  22141. * | 10 | ALPHA_SCREENMODE | |
  22142. *
  22143. */
  22144. /**
  22145. * Gets the value of the alpha mode
  22146. */
  22147. alphaMode: number;
  22148. /**
  22149. * Stores the state of the need depth pre-pass value
  22150. */
  22151. private _needDepthPrePass;
  22152. /**
  22153. * Sets the need depth pre-pass value
  22154. */
  22155. /**
  22156. * Gets the depth pre-pass value
  22157. */
  22158. needDepthPrePass: boolean;
  22159. /**
  22160. * Specifies if depth writing should be disabled
  22161. */
  22162. disableDepthWrite: boolean;
  22163. /**
  22164. * Specifies if depth writing should be forced
  22165. */
  22166. forceDepthWrite: boolean;
  22167. /**
  22168. * Specifies if there should be a separate pass for culling
  22169. */
  22170. separateCullingPass: boolean;
  22171. /**
  22172. * Stores the state specifing if fog should be enabled
  22173. */
  22174. private _fogEnabled;
  22175. /**
  22176. * Sets the state for enabling fog
  22177. */
  22178. /**
  22179. * Gets the value of the fog enabled state
  22180. */
  22181. fogEnabled: boolean;
  22182. /**
  22183. * Stores the size of points
  22184. */
  22185. pointSize: number;
  22186. /**
  22187. * Stores the z offset value
  22188. */
  22189. zOffset: number;
  22190. /**
  22191. * Gets a value specifying if wireframe mode is enabled
  22192. */
  22193. /**
  22194. * Sets the state of wireframe mode
  22195. */
  22196. wireframe: boolean;
  22197. /**
  22198. * Gets the value specifying if point clouds are enabled
  22199. */
  22200. /**
  22201. * Sets the state of point cloud mode
  22202. */
  22203. pointsCloud: boolean;
  22204. /**
  22205. * Gets the material fill mode
  22206. */
  22207. /**
  22208. * Sets the material fill mode
  22209. */
  22210. fillMode: number;
  22211. /**
  22212. * @hidden
  22213. * Stores the effects for the material
  22214. */
  22215. _effect: Nullable<Effect>;
  22216. /**
  22217. * @hidden
  22218. * Specifies if the material was previously ready
  22219. */
  22220. _wasPreviouslyReady: boolean;
  22221. /**
  22222. * Specifies if uniform buffers should be used
  22223. */
  22224. private _useUBO;
  22225. /**
  22226. * Stores a reference to the scene
  22227. */
  22228. private _scene;
  22229. /**
  22230. * Stores the fill mode state
  22231. */
  22232. private _fillMode;
  22233. /**
  22234. * Specifies if the depth write state should be cached
  22235. */
  22236. private _cachedDepthWriteState;
  22237. /**
  22238. * Stores the uniform buffer
  22239. */
  22240. protected _uniformBuffer: UniformBuffer;
  22241. /** @hidden */
  22242. _indexInSceneMaterialArray: number;
  22243. /** @hidden */
  22244. meshMap: Nullable<{
  22245. [id: string]: AbstractMesh | undefined;
  22246. }>;
  22247. /**
  22248. * Creates a material instance
  22249. * @param name defines the name of the material
  22250. * @param scene defines the scene to reference
  22251. * @param doNotAdd specifies if the material should be added to the scene
  22252. */
  22253. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22254. /**
  22255. * Returns a string representation of the current material
  22256. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22257. * @returns a string with material information
  22258. */
  22259. toString(fullDetails?: boolean): string;
  22260. /**
  22261. * Gets the class name of the material
  22262. * @returns a string with the class name of the material
  22263. */
  22264. getClassName(): string;
  22265. /**
  22266. * Specifies if updates for the material been locked
  22267. */
  22268. readonly isFrozen: boolean;
  22269. /**
  22270. * Locks updates for the material
  22271. */
  22272. freeze(): void;
  22273. /**
  22274. * Unlocks updates for the material
  22275. */
  22276. unfreeze(): void;
  22277. /**
  22278. * Specifies if the material is ready to be used
  22279. * @param mesh defines the mesh to check
  22280. * @param useInstances specifies if instances should be used
  22281. * @returns a boolean indicating if the material is ready to be used
  22282. */
  22283. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22284. /**
  22285. * Specifies that the submesh is ready to be used
  22286. * @param mesh defines the mesh to check
  22287. * @param subMesh defines which submesh to check
  22288. * @param useInstances specifies that instances should be used
  22289. * @returns a boolean indicating that the submesh is ready or not
  22290. */
  22291. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22292. /**
  22293. * Returns the material effect
  22294. * @returns the effect associated with the material
  22295. */
  22296. getEffect(): Nullable<Effect>;
  22297. /**
  22298. * Returns the current scene
  22299. * @returns a Scene
  22300. */
  22301. getScene(): Scene;
  22302. /**
  22303. * Specifies if the material will require alpha blending
  22304. * @returns a boolean specifying if alpha blending is needed
  22305. */
  22306. needAlphaBlending(): boolean;
  22307. /**
  22308. * Specifies if the mesh will require alpha blending
  22309. * @param mesh defines the mesh to check
  22310. * @returns a boolean specifying if alpha blending is needed for the mesh
  22311. */
  22312. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22313. /**
  22314. * Specifies if this material should be rendered in alpha test mode
  22315. * @returns a boolean specifying if an alpha test is needed.
  22316. */
  22317. needAlphaTesting(): boolean;
  22318. /**
  22319. * Gets the texture used for the alpha test
  22320. * @returns the texture to use for alpha testing
  22321. */
  22322. getAlphaTestTexture(): Nullable<BaseTexture>;
  22323. /**
  22324. * Marks the material to indicate that it needs to be re-calculated
  22325. */
  22326. markDirty(): void;
  22327. /** @hidden */
  22328. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22329. /**
  22330. * Binds the material to the mesh
  22331. * @param world defines the world transformation matrix
  22332. * @param mesh defines the mesh to bind the material to
  22333. */
  22334. bind(world: Matrix, mesh?: Mesh): void;
  22335. /**
  22336. * Binds the submesh to the material
  22337. * @param world defines the world transformation matrix
  22338. * @param mesh defines the mesh containing the submesh
  22339. * @param subMesh defines the submesh to bind the material to
  22340. */
  22341. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22342. /**
  22343. * Binds the world matrix to the material
  22344. * @param world defines the world transformation matrix
  22345. */
  22346. bindOnlyWorldMatrix(world: Matrix): void;
  22347. /**
  22348. * Binds the scene's uniform buffer to the effect.
  22349. * @param effect defines the effect to bind to the scene uniform buffer
  22350. * @param sceneUbo defines the uniform buffer storing scene data
  22351. */
  22352. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22353. /**
  22354. * Binds the view matrix to the effect
  22355. * @param effect defines the effect to bind the view matrix to
  22356. */
  22357. bindView(effect: Effect): void;
  22358. /**
  22359. * Binds the view projection matrix to the effect
  22360. * @param effect defines the effect to bind the view projection matrix to
  22361. */
  22362. bindViewProjection(effect: Effect): void;
  22363. /**
  22364. * Specifies if material alpha testing should be turned on for the mesh
  22365. * @param mesh defines the mesh to check
  22366. */
  22367. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22368. /**
  22369. * Processes to execute after binding the material to a mesh
  22370. * @param mesh defines the rendered mesh
  22371. */
  22372. protected _afterBind(mesh?: Mesh): void;
  22373. /**
  22374. * Unbinds the material from the mesh
  22375. */
  22376. unbind(): void;
  22377. /**
  22378. * Gets the active textures from the material
  22379. * @returns an array of textures
  22380. */
  22381. getActiveTextures(): BaseTexture[];
  22382. /**
  22383. * Specifies if the material uses a texture
  22384. * @param texture defines the texture to check against the material
  22385. * @returns a boolean specifying if the material uses the texture
  22386. */
  22387. hasTexture(texture: BaseTexture): boolean;
  22388. /**
  22389. * Makes a duplicate of the material, and gives it a new name
  22390. * @param name defines the new name for the duplicated material
  22391. * @returns the cloned material
  22392. */
  22393. clone(name: string): Nullable<Material>;
  22394. /**
  22395. * Gets the meshes bound to the material
  22396. * @returns an array of meshes bound to the material
  22397. */
  22398. getBindedMeshes(): AbstractMesh[];
  22399. /**
  22400. * Force shader compilation
  22401. * @param mesh defines the mesh associated with this material
  22402. * @param onCompiled defines a function to execute once the material is compiled
  22403. * @param options defines the options to configure the compilation
  22404. */
  22405. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22406. clipPlane: boolean;
  22407. }>): void;
  22408. /**
  22409. * Force shader compilation
  22410. * @param mesh defines the mesh that will use this material
  22411. * @param options defines additional options for compiling the shaders
  22412. * @returns a promise that resolves when the compilation completes
  22413. */
  22414. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22415. clipPlane: boolean;
  22416. }>): Promise<void>;
  22417. private static readonly _ImageProcessingDirtyCallBack;
  22418. private static readonly _TextureDirtyCallBack;
  22419. private static readonly _FresnelDirtyCallBack;
  22420. private static readonly _MiscDirtyCallBack;
  22421. private static readonly _LightsDirtyCallBack;
  22422. private static readonly _AttributeDirtyCallBack;
  22423. private static _FresnelAndMiscDirtyCallBack;
  22424. private static _TextureAndMiscDirtyCallBack;
  22425. private static readonly _DirtyCallbackArray;
  22426. private static readonly _RunDirtyCallBacks;
  22427. /**
  22428. * Marks a define in the material to indicate that it needs to be re-computed
  22429. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22430. */
  22431. markAsDirty(flag: number): void;
  22432. /**
  22433. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22434. * @param func defines a function which checks material defines against the submeshes
  22435. */
  22436. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22437. /**
  22438. * Indicates that image processing needs to be re-calculated for all submeshes
  22439. */
  22440. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22441. /**
  22442. * Indicates that textures need to be re-calculated for all submeshes
  22443. */
  22444. protected _markAllSubMeshesAsTexturesDirty(): void;
  22445. /**
  22446. * Indicates that fresnel needs to be re-calculated for all submeshes
  22447. */
  22448. protected _markAllSubMeshesAsFresnelDirty(): void;
  22449. /**
  22450. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22451. */
  22452. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22453. /**
  22454. * Indicates that lights need to be re-calculated for all submeshes
  22455. */
  22456. protected _markAllSubMeshesAsLightsDirty(): void;
  22457. /**
  22458. * Indicates that attributes need to be re-calculated for all submeshes
  22459. */
  22460. protected _markAllSubMeshesAsAttributesDirty(): void;
  22461. /**
  22462. * Indicates that misc needs to be re-calculated for all submeshes
  22463. */
  22464. protected _markAllSubMeshesAsMiscDirty(): void;
  22465. /**
  22466. * Indicates that textures and misc need to be re-calculated for all submeshes
  22467. */
  22468. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22469. /**
  22470. * Disposes the material
  22471. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22472. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22473. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22474. */
  22475. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22476. /** @hidden */
  22477. private releaseVertexArrayObject;
  22478. /**
  22479. * Serializes this material
  22480. * @returns the serialized material object
  22481. */
  22482. serialize(): any;
  22483. /**
  22484. * Creates a material from parsed material data
  22485. * @param parsedMaterial defines parsed material data
  22486. * @param scene defines the hosting scene
  22487. * @param rootUrl defines the root URL to use to load textures
  22488. * @returns a new material
  22489. */
  22490. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22491. }
  22492. }
  22493. declare module BABYLON {
  22494. /**
  22495. * Base class for submeshes
  22496. */
  22497. export class BaseSubMesh {
  22498. /** @hidden */
  22499. _materialDefines: Nullable<MaterialDefines>;
  22500. /** @hidden */
  22501. _materialEffect: Nullable<Effect>;
  22502. /**
  22503. * Gets associated effect
  22504. */
  22505. readonly effect: Nullable<Effect>;
  22506. /**
  22507. * Sets associated effect (effect used to render this submesh)
  22508. * @param effect defines the effect to associate with
  22509. * @param defines defines the set of defines used to compile this effect
  22510. */
  22511. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22512. }
  22513. /**
  22514. * Defines a subdivision inside a mesh
  22515. */
  22516. export class SubMesh extends BaseSubMesh implements ICullable {
  22517. /** the material index to use */
  22518. materialIndex: number;
  22519. /** vertex index start */
  22520. verticesStart: number;
  22521. /** vertices count */
  22522. verticesCount: number;
  22523. /** index start */
  22524. indexStart: number;
  22525. /** indices count */
  22526. indexCount: number;
  22527. /** @hidden */
  22528. _linesIndexCount: number;
  22529. private _mesh;
  22530. private _renderingMesh;
  22531. private _boundingInfo;
  22532. private _linesIndexBuffer;
  22533. /** @hidden */
  22534. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22535. /** @hidden */
  22536. _trianglePlanes: Plane[];
  22537. /** @hidden */
  22538. _lastColliderTransformMatrix: Nullable<Matrix>;
  22539. /** @hidden */
  22540. _renderId: number;
  22541. /** @hidden */
  22542. _alphaIndex: number;
  22543. /** @hidden */
  22544. _distanceToCamera: number;
  22545. /** @hidden */
  22546. _id: number;
  22547. private _currentMaterial;
  22548. /**
  22549. * Add a new submesh to a mesh
  22550. * @param materialIndex defines the material index to use
  22551. * @param verticesStart defines vertex index start
  22552. * @param verticesCount defines vertices count
  22553. * @param indexStart defines index start
  22554. * @param indexCount defines indices count
  22555. * @param mesh defines the parent mesh
  22556. * @param renderingMesh defines an optional rendering mesh
  22557. * @param createBoundingBox defines if bounding box should be created for this submesh
  22558. * @returns the new submesh
  22559. */
  22560. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22561. /**
  22562. * Creates a new submesh
  22563. * @param materialIndex defines the material index to use
  22564. * @param verticesStart defines vertex index start
  22565. * @param verticesCount defines vertices count
  22566. * @param indexStart defines index start
  22567. * @param indexCount defines indices count
  22568. * @param mesh defines the parent mesh
  22569. * @param renderingMesh defines an optional rendering mesh
  22570. * @param createBoundingBox defines if bounding box should be created for this submesh
  22571. */
  22572. constructor(
  22573. /** the material index to use */
  22574. materialIndex: number,
  22575. /** vertex index start */
  22576. verticesStart: number,
  22577. /** vertices count */
  22578. verticesCount: number,
  22579. /** index start */
  22580. indexStart: number,
  22581. /** indices count */
  22582. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22583. /**
  22584. * Returns true if this submesh covers the entire parent mesh
  22585. * @ignorenaming
  22586. */
  22587. readonly IsGlobal: boolean;
  22588. /**
  22589. * Returns the submesh BoudingInfo object
  22590. * @returns current bounding info (or mesh's one if the submesh is global)
  22591. */
  22592. getBoundingInfo(): BoundingInfo;
  22593. /**
  22594. * Sets the submesh BoundingInfo
  22595. * @param boundingInfo defines the new bounding info to use
  22596. * @returns the SubMesh
  22597. */
  22598. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22599. /**
  22600. * Returns the mesh of the current submesh
  22601. * @return the parent mesh
  22602. */
  22603. getMesh(): AbstractMesh;
  22604. /**
  22605. * Returns the rendering mesh of the submesh
  22606. * @returns the rendering mesh (could be different from parent mesh)
  22607. */
  22608. getRenderingMesh(): Mesh;
  22609. /**
  22610. * Returns the submesh material
  22611. * @returns null or the current material
  22612. */
  22613. getMaterial(): Nullable<Material>;
  22614. /**
  22615. * Sets a new updated BoundingInfo object to the submesh
  22616. * @param data defines an optional position array to use to determine the bounding info
  22617. * @returns the SubMesh
  22618. */
  22619. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22620. /** @hidden */
  22621. _checkCollision(collider: Collider): boolean;
  22622. /**
  22623. * Updates the submesh BoundingInfo
  22624. * @param world defines the world matrix to use to update the bounding info
  22625. * @returns the submesh
  22626. */
  22627. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22628. /**
  22629. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22630. * @param frustumPlanes defines the frustum planes
  22631. * @returns true if the submesh is intersecting with the frustum
  22632. */
  22633. isInFrustum(frustumPlanes: Plane[]): boolean;
  22634. /**
  22635. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22636. * @param frustumPlanes defines the frustum planes
  22637. * @returns true if the submesh is inside the frustum
  22638. */
  22639. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22640. /**
  22641. * Renders the submesh
  22642. * @param enableAlphaMode defines if alpha needs to be used
  22643. * @returns the submesh
  22644. */
  22645. render(enableAlphaMode: boolean): SubMesh;
  22646. /**
  22647. * @hidden
  22648. */
  22649. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22650. /**
  22651. * Checks if the submesh intersects with a ray
  22652. * @param ray defines the ray to test
  22653. * @returns true is the passed ray intersects the submesh bounding box
  22654. */
  22655. canIntersects(ray: Ray): boolean;
  22656. /**
  22657. * Intersects current submesh with a ray
  22658. * @param ray defines the ray to test
  22659. * @param positions defines mesh's positions array
  22660. * @param indices defines mesh's indices array
  22661. * @param fastCheck defines if only bounding info should be used
  22662. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22663. * @returns intersection info or null if no intersection
  22664. */
  22665. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22666. /** @hidden */
  22667. private _intersectLines;
  22668. /** @hidden */
  22669. private _intersectUnIndexedLines;
  22670. /** @hidden */
  22671. private _intersectTriangles;
  22672. /** @hidden */
  22673. private _intersectUnIndexedTriangles;
  22674. /** @hidden */
  22675. _rebuild(): void;
  22676. /**
  22677. * Creates a new submesh from the passed mesh
  22678. * @param newMesh defines the new hosting mesh
  22679. * @param newRenderingMesh defines an optional rendering mesh
  22680. * @returns the new submesh
  22681. */
  22682. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22683. /**
  22684. * Release associated resources
  22685. */
  22686. dispose(): void;
  22687. /**
  22688. * Gets the class name
  22689. * @returns the string "SubMesh".
  22690. */
  22691. getClassName(): string;
  22692. /**
  22693. * Creates a new submesh from indices data
  22694. * @param materialIndex the index of the main mesh material
  22695. * @param startIndex the index where to start the copy in the mesh indices array
  22696. * @param indexCount the number of indices to copy then from the startIndex
  22697. * @param mesh the main mesh to create the submesh from
  22698. * @param renderingMesh the optional rendering mesh
  22699. * @returns a new submesh
  22700. */
  22701. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22702. }
  22703. }
  22704. declare module BABYLON {
  22705. /**
  22706. * Class used to store geometry data (vertex buffers + index buffer)
  22707. */
  22708. export class Geometry implements IGetSetVerticesData {
  22709. /**
  22710. * Gets or sets the ID of the geometry
  22711. */
  22712. id: string;
  22713. /**
  22714. * Gets or sets the unique ID of the geometry
  22715. */
  22716. uniqueId: number;
  22717. /**
  22718. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22719. */
  22720. delayLoadState: number;
  22721. /**
  22722. * Gets the file containing the data to load when running in delay load state
  22723. */
  22724. delayLoadingFile: Nullable<string>;
  22725. /**
  22726. * Callback called when the geometry is updated
  22727. */
  22728. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22729. private _scene;
  22730. private _engine;
  22731. private _meshes;
  22732. private _totalVertices;
  22733. /** @hidden */
  22734. _indices: IndicesArray;
  22735. /** @hidden */
  22736. _vertexBuffers: {
  22737. [key: string]: VertexBuffer;
  22738. };
  22739. private _isDisposed;
  22740. private _extend;
  22741. private _boundingBias;
  22742. /** @hidden */
  22743. _delayInfo: Array<string>;
  22744. private _indexBuffer;
  22745. private _indexBufferIsUpdatable;
  22746. /** @hidden */
  22747. _boundingInfo: Nullable<BoundingInfo>;
  22748. /** @hidden */
  22749. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22750. /** @hidden */
  22751. _softwareSkinningFrameId: number;
  22752. private _vertexArrayObjects;
  22753. private _updatable;
  22754. /** @hidden */
  22755. _positions: Nullable<Vector3[]>;
  22756. /**
  22757. * 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
  22758. */
  22759. /**
  22760. * 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
  22761. */
  22762. boundingBias: Vector2;
  22763. /**
  22764. * Static function used to attach a new empty geometry to a mesh
  22765. * @param mesh defines the mesh to attach the geometry to
  22766. * @returns the new Geometry
  22767. */
  22768. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22769. /**
  22770. * Creates a new geometry
  22771. * @param id defines the unique ID
  22772. * @param scene defines the hosting scene
  22773. * @param vertexData defines the VertexData used to get geometry data
  22774. * @param updatable defines if geometry must be updatable (false by default)
  22775. * @param mesh defines the mesh that will be associated with the geometry
  22776. */
  22777. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22778. /**
  22779. * Gets the current extend of the geometry
  22780. */
  22781. readonly extend: {
  22782. minimum: Vector3;
  22783. maximum: Vector3;
  22784. };
  22785. /**
  22786. * Gets the hosting scene
  22787. * @returns the hosting Scene
  22788. */
  22789. getScene(): Scene;
  22790. /**
  22791. * Gets the hosting engine
  22792. * @returns the hosting Engine
  22793. */
  22794. getEngine(): Engine;
  22795. /**
  22796. * Defines if the geometry is ready to use
  22797. * @returns true if the geometry is ready to be used
  22798. */
  22799. isReady(): boolean;
  22800. /**
  22801. * Gets a value indicating that the geometry should not be serialized
  22802. */
  22803. readonly doNotSerialize: boolean;
  22804. /** @hidden */
  22805. _rebuild(): void;
  22806. /**
  22807. * Affects all geometry data in one call
  22808. * @param vertexData defines the geometry data
  22809. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22810. */
  22811. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22812. /**
  22813. * Set specific vertex data
  22814. * @param kind defines the data kind (Position, normal, etc...)
  22815. * @param data defines the vertex data to use
  22816. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22817. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22818. */
  22819. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22820. /**
  22821. * Removes a specific vertex data
  22822. * @param kind defines the data kind (Position, normal, etc...)
  22823. */
  22824. removeVerticesData(kind: string): void;
  22825. /**
  22826. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22827. * @param buffer defines the vertex buffer to use
  22828. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22829. */
  22830. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22831. /**
  22832. * Update a specific vertex buffer
  22833. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22834. * It will do nothing if the buffer is not updatable
  22835. * @param kind defines the data kind (Position, normal, etc...)
  22836. * @param data defines the data to use
  22837. * @param offset defines the offset in the target buffer where to store the data
  22838. * @param useBytes set to true if the offset is in bytes
  22839. */
  22840. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22841. /**
  22842. * Update a specific vertex buffer
  22843. * This function will create a new buffer if the current one is not updatable
  22844. * @param kind defines the data kind (Position, normal, etc...)
  22845. * @param data defines the data to use
  22846. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22847. */
  22848. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22849. private _updateBoundingInfo;
  22850. /** @hidden */
  22851. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22852. /**
  22853. * Gets total number of vertices
  22854. * @returns the total number of vertices
  22855. */
  22856. getTotalVertices(): number;
  22857. /**
  22858. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22859. * @param kind defines the data kind (Position, normal, etc...)
  22860. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22861. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22862. * @returns a float array containing vertex data
  22863. */
  22864. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22865. /**
  22866. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22867. * @param kind defines the data kind (Position, normal, etc...)
  22868. * @returns true if the vertex buffer with the specified kind is updatable
  22869. */
  22870. isVertexBufferUpdatable(kind: string): boolean;
  22871. /**
  22872. * Gets a specific vertex buffer
  22873. * @param kind defines the data kind (Position, normal, etc...)
  22874. * @returns a VertexBuffer
  22875. */
  22876. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22877. /**
  22878. * Returns all vertex buffers
  22879. * @return an object holding all vertex buffers indexed by kind
  22880. */
  22881. getVertexBuffers(): Nullable<{
  22882. [key: string]: VertexBuffer;
  22883. }>;
  22884. /**
  22885. * Gets a boolean indicating if specific vertex buffer is present
  22886. * @param kind defines the data kind (Position, normal, etc...)
  22887. * @returns true if data is present
  22888. */
  22889. isVerticesDataPresent(kind: string): boolean;
  22890. /**
  22891. * Gets a list of all attached data kinds (Position, normal, etc...)
  22892. * @returns a list of string containing all kinds
  22893. */
  22894. getVerticesDataKinds(): string[];
  22895. /**
  22896. * Update index buffer
  22897. * @param indices defines the indices to store in the index buffer
  22898. * @param offset defines the offset in the target buffer where to store the data
  22899. * @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)
  22900. */
  22901. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22902. /**
  22903. * Creates a new index buffer
  22904. * @param indices defines the indices to store in the index buffer
  22905. * @param totalVertices defines the total number of vertices (could be null)
  22906. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22907. */
  22908. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22909. /**
  22910. * Return the total number of indices
  22911. * @returns the total number of indices
  22912. */
  22913. getTotalIndices(): number;
  22914. /**
  22915. * Gets the index buffer array
  22916. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22917. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22918. * @returns the index buffer array
  22919. */
  22920. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22921. /**
  22922. * Gets the index buffer
  22923. * @return the index buffer
  22924. */
  22925. getIndexBuffer(): Nullable<DataBuffer>;
  22926. /** @hidden */
  22927. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22928. /**
  22929. * Release the associated resources for a specific mesh
  22930. * @param mesh defines the source mesh
  22931. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22932. */
  22933. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22934. /**
  22935. * Apply current geometry to a given mesh
  22936. * @param mesh defines the mesh to apply geometry to
  22937. */
  22938. applyToMesh(mesh: Mesh): void;
  22939. private _updateExtend;
  22940. private _applyToMesh;
  22941. private notifyUpdate;
  22942. /**
  22943. * Load the geometry if it was flagged as delay loaded
  22944. * @param scene defines the hosting scene
  22945. * @param onLoaded defines a callback called when the geometry is loaded
  22946. */
  22947. load(scene: Scene, onLoaded?: () => void): void;
  22948. private _queueLoad;
  22949. /**
  22950. * Invert the geometry to move from a right handed system to a left handed one.
  22951. */
  22952. toLeftHanded(): void;
  22953. /** @hidden */
  22954. _resetPointsArrayCache(): void;
  22955. /** @hidden */
  22956. _generatePointsArray(): boolean;
  22957. /**
  22958. * Gets a value indicating if the geometry is disposed
  22959. * @returns true if the geometry was disposed
  22960. */
  22961. isDisposed(): boolean;
  22962. private _disposeVertexArrayObjects;
  22963. /**
  22964. * Free all associated resources
  22965. */
  22966. dispose(): void;
  22967. /**
  22968. * Clone the current geometry into a new geometry
  22969. * @param id defines the unique ID of the new geometry
  22970. * @returns a new geometry object
  22971. */
  22972. copy(id: string): Geometry;
  22973. /**
  22974. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22975. * @return a JSON representation of the current geometry data (without the vertices data)
  22976. */
  22977. serialize(): any;
  22978. private toNumberArray;
  22979. /**
  22980. * Serialize all vertices data into a JSON oject
  22981. * @returns a JSON representation of the current geometry data
  22982. */
  22983. serializeVerticeData(): any;
  22984. /**
  22985. * Extracts a clone of a mesh geometry
  22986. * @param mesh defines the source mesh
  22987. * @param id defines the unique ID of the new geometry object
  22988. * @returns the new geometry object
  22989. */
  22990. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22991. /**
  22992. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22993. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22994. * Be aware Math.random() could cause collisions, but:
  22995. * "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"
  22996. * @returns a string containing a new GUID
  22997. */
  22998. static RandomId(): string;
  22999. /** @hidden */
  23000. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23001. private static _CleanMatricesWeights;
  23002. /**
  23003. * Create a new geometry from persisted data (Using .babylon file format)
  23004. * @param parsedVertexData defines the persisted data
  23005. * @param scene defines the hosting scene
  23006. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23007. * @returns the new geometry object
  23008. */
  23009. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23010. }
  23011. }
  23012. declare module BABYLON {
  23013. /**
  23014. * Define an interface for all classes that will get and set the data on vertices
  23015. */
  23016. export interface IGetSetVerticesData {
  23017. /**
  23018. * Gets a boolean indicating if specific vertex data is present
  23019. * @param kind defines the vertex data kind to use
  23020. * @returns true is data kind is present
  23021. */
  23022. isVerticesDataPresent(kind: string): boolean;
  23023. /**
  23024. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23025. * @param kind defines the data kind (Position, normal, etc...)
  23026. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23027. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23028. * @returns a float array containing vertex data
  23029. */
  23030. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23031. /**
  23032. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23033. * @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.
  23034. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23035. * @returns the indices array or an empty array if the mesh has no geometry
  23036. */
  23037. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23038. /**
  23039. * Set specific vertex data
  23040. * @param kind defines the data kind (Position, normal, etc...)
  23041. * @param data defines the vertex data to use
  23042. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23043. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23044. */
  23045. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23046. /**
  23047. * Update a specific associated vertex buffer
  23048. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23049. * - VertexBuffer.PositionKind
  23050. * - VertexBuffer.UVKind
  23051. * - VertexBuffer.UV2Kind
  23052. * - VertexBuffer.UV3Kind
  23053. * - VertexBuffer.UV4Kind
  23054. * - VertexBuffer.UV5Kind
  23055. * - VertexBuffer.UV6Kind
  23056. * - VertexBuffer.ColorKind
  23057. * - VertexBuffer.MatricesIndicesKind
  23058. * - VertexBuffer.MatricesIndicesExtraKind
  23059. * - VertexBuffer.MatricesWeightsKind
  23060. * - VertexBuffer.MatricesWeightsExtraKind
  23061. * @param data defines the data source
  23062. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23063. * @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)
  23064. */
  23065. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23066. /**
  23067. * Creates a new index buffer
  23068. * @param indices defines the indices to store in the index buffer
  23069. * @param totalVertices defines the total number of vertices (could be null)
  23070. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23071. */
  23072. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23073. }
  23074. /**
  23075. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23076. */
  23077. export class VertexData {
  23078. /**
  23079. * Mesh side orientation : usually the external or front surface
  23080. */
  23081. static readonly FRONTSIDE: number;
  23082. /**
  23083. * Mesh side orientation : usually the internal or back surface
  23084. */
  23085. static readonly BACKSIDE: number;
  23086. /**
  23087. * Mesh side orientation : both internal and external or front and back surfaces
  23088. */
  23089. static readonly DOUBLESIDE: number;
  23090. /**
  23091. * Mesh side orientation : by default, `FRONTSIDE`
  23092. */
  23093. static readonly DEFAULTSIDE: number;
  23094. /**
  23095. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23096. */
  23097. positions: Nullable<FloatArray>;
  23098. /**
  23099. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23100. */
  23101. normals: Nullable<FloatArray>;
  23102. /**
  23103. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23104. */
  23105. tangents: Nullable<FloatArray>;
  23106. /**
  23107. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23108. */
  23109. uvs: Nullable<FloatArray>;
  23110. /**
  23111. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23112. */
  23113. uvs2: Nullable<FloatArray>;
  23114. /**
  23115. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23116. */
  23117. uvs3: Nullable<FloatArray>;
  23118. /**
  23119. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23120. */
  23121. uvs4: Nullable<FloatArray>;
  23122. /**
  23123. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23124. */
  23125. uvs5: Nullable<FloatArray>;
  23126. /**
  23127. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23128. */
  23129. uvs6: Nullable<FloatArray>;
  23130. /**
  23131. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23132. */
  23133. colors: Nullable<FloatArray>;
  23134. /**
  23135. * 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).
  23136. */
  23137. matricesIndices: Nullable<FloatArray>;
  23138. /**
  23139. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23140. */
  23141. matricesWeights: Nullable<FloatArray>;
  23142. /**
  23143. * An array extending the number of possible indices
  23144. */
  23145. matricesIndicesExtra: Nullable<FloatArray>;
  23146. /**
  23147. * An array extending the number of possible weights when the number of indices is extended
  23148. */
  23149. matricesWeightsExtra: Nullable<FloatArray>;
  23150. /**
  23151. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23152. */
  23153. indices: Nullable<IndicesArray>;
  23154. /**
  23155. * Uses the passed data array to set the set the values for the specified kind of data
  23156. * @param data a linear array of floating numbers
  23157. * @param kind the type of data that is being set, eg positions, colors etc
  23158. */
  23159. set(data: FloatArray, kind: string): void;
  23160. /**
  23161. * Associates the vertexData to the passed Mesh.
  23162. * Sets it as updatable or not (default `false`)
  23163. * @param mesh the mesh the vertexData is applied to
  23164. * @param updatable when used and having the value true allows new data to update the vertexData
  23165. * @returns the VertexData
  23166. */
  23167. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23168. /**
  23169. * Associates the vertexData to the passed Geometry.
  23170. * Sets it as updatable or not (default `false`)
  23171. * @param geometry the geometry the vertexData is applied to
  23172. * @param updatable when used and having the value true allows new data to update the vertexData
  23173. * @returns VertexData
  23174. */
  23175. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23176. /**
  23177. * Updates the associated mesh
  23178. * @param mesh the mesh to be updated
  23179. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23180. * @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
  23181. * @returns VertexData
  23182. */
  23183. updateMesh(mesh: Mesh): VertexData;
  23184. /**
  23185. * Updates the associated geometry
  23186. * @param geometry the geometry to be updated
  23187. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23188. * @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
  23189. * @returns VertexData.
  23190. */
  23191. updateGeometry(geometry: Geometry): VertexData;
  23192. private _applyTo;
  23193. private _update;
  23194. /**
  23195. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23196. * @param matrix the transforming matrix
  23197. * @returns the VertexData
  23198. */
  23199. transform(matrix: Matrix): VertexData;
  23200. /**
  23201. * Merges the passed VertexData into the current one
  23202. * @param other the VertexData to be merged into the current one
  23203. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23204. * @returns the modified VertexData
  23205. */
  23206. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23207. private _mergeElement;
  23208. private _validate;
  23209. /**
  23210. * Serializes the VertexData
  23211. * @returns a serialized object
  23212. */
  23213. serialize(): any;
  23214. /**
  23215. * Extracts the vertexData from a mesh
  23216. * @param mesh the mesh from which to extract the VertexData
  23217. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23218. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23219. * @returns the object VertexData associated to the passed mesh
  23220. */
  23221. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23222. /**
  23223. * Extracts the vertexData from the geometry
  23224. * @param geometry the geometry from which to extract the VertexData
  23225. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23226. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23227. * @returns the object VertexData associated to the passed mesh
  23228. */
  23229. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23230. private static _ExtractFrom;
  23231. /**
  23232. * Creates the VertexData for a Ribbon
  23233. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23234. * * pathArray array of paths, each of which an array of successive Vector3
  23235. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23236. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23237. * * 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
  23238. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23239. * * 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)
  23240. * * 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)
  23241. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23242. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23243. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23244. * @returns the VertexData of the ribbon
  23245. */
  23246. static CreateRibbon(options: {
  23247. pathArray: Vector3[][];
  23248. closeArray?: boolean;
  23249. closePath?: boolean;
  23250. offset?: number;
  23251. sideOrientation?: number;
  23252. frontUVs?: Vector4;
  23253. backUVs?: Vector4;
  23254. invertUV?: boolean;
  23255. uvs?: Vector2[];
  23256. colors?: Color4[];
  23257. }): VertexData;
  23258. /**
  23259. * Creates the VertexData for a box
  23260. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23261. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23262. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23263. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23264. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23265. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23266. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23267. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23268. * * 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)
  23269. * * 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)
  23270. * @returns the VertexData of the box
  23271. */
  23272. static CreateBox(options: {
  23273. size?: number;
  23274. width?: number;
  23275. height?: number;
  23276. depth?: number;
  23277. faceUV?: Vector4[];
  23278. faceColors?: Color4[];
  23279. sideOrientation?: number;
  23280. frontUVs?: Vector4;
  23281. backUVs?: Vector4;
  23282. }): VertexData;
  23283. /**
  23284. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23285. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23286. * * segments sets the number of horizontal strips optional, default 32
  23287. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23288. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23289. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23290. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23291. * * 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
  23292. * * 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
  23293. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23294. * * 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)
  23295. * * 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)
  23296. * @returns the VertexData of the ellipsoid
  23297. */
  23298. static CreateSphere(options: {
  23299. segments?: number;
  23300. diameter?: number;
  23301. diameterX?: number;
  23302. diameterY?: number;
  23303. diameterZ?: number;
  23304. arc?: number;
  23305. slice?: number;
  23306. sideOrientation?: number;
  23307. frontUVs?: Vector4;
  23308. backUVs?: Vector4;
  23309. }): VertexData;
  23310. /**
  23311. * Creates the VertexData for a cylinder, cone or prism
  23312. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23313. * * height sets the height (y direction) of the cylinder, optional, default 2
  23314. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23315. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23316. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23317. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23318. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23319. * * 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
  23320. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23321. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23322. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23323. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23324. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23325. * * 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)
  23326. * * 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)
  23327. * @returns the VertexData of the cylinder, cone or prism
  23328. */
  23329. static CreateCylinder(options: {
  23330. height?: number;
  23331. diameterTop?: number;
  23332. diameterBottom?: number;
  23333. diameter?: number;
  23334. tessellation?: number;
  23335. subdivisions?: number;
  23336. arc?: number;
  23337. faceColors?: Color4[];
  23338. faceUV?: Vector4[];
  23339. hasRings?: boolean;
  23340. enclose?: boolean;
  23341. sideOrientation?: number;
  23342. frontUVs?: Vector4;
  23343. backUVs?: Vector4;
  23344. }): VertexData;
  23345. /**
  23346. * Creates the VertexData for a torus
  23347. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23348. * * diameter the diameter of the torus, optional default 1
  23349. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23350. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23352. * * 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)
  23353. * * 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)
  23354. * @returns the VertexData of the torus
  23355. */
  23356. static CreateTorus(options: {
  23357. diameter?: number;
  23358. thickness?: number;
  23359. tessellation?: number;
  23360. sideOrientation?: number;
  23361. frontUVs?: Vector4;
  23362. backUVs?: Vector4;
  23363. }): VertexData;
  23364. /**
  23365. * Creates the VertexData of the LineSystem
  23366. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23367. * - lines an array of lines, each line being an array of successive Vector3
  23368. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23369. * @returns the VertexData of the LineSystem
  23370. */
  23371. static CreateLineSystem(options: {
  23372. lines: Vector3[][];
  23373. colors?: Nullable<Color4[][]>;
  23374. }): VertexData;
  23375. /**
  23376. * Create the VertexData for a DashedLines
  23377. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23378. * - points an array successive Vector3
  23379. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23380. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23381. * - dashNb the intended total number of dashes, optional, default 200
  23382. * @returns the VertexData for the DashedLines
  23383. */
  23384. static CreateDashedLines(options: {
  23385. points: Vector3[];
  23386. dashSize?: number;
  23387. gapSize?: number;
  23388. dashNb?: number;
  23389. }): VertexData;
  23390. /**
  23391. * Creates the VertexData for a Ground
  23392. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23393. * - width the width (x direction) of the ground, optional, default 1
  23394. * - height the height (z direction) of the ground, optional, default 1
  23395. * - subdivisions the number of subdivisions per side, optional, default 1
  23396. * @returns the VertexData of the Ground
  23397. */
  23398. static CreateGround(options: {
  23399. width?: number;
  23400. height?: number;
  23401. subdivisions?: number;
  23402. subdivisionsX?: number;
  23403. subdivisionsY?: number;
  23404. }): VertexData;
  23405. /**
  23406. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23407. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23408. * * xmin the ground minimum X coordinate, optional, default -1
  23409. * * zmin the ground minimum Z coordinate, optional, default -1
  23410. * * xmax the ground maximum X coordinate, optional, default 1
  23411. * * zmax the ground maximum Z coordinate, optional, default 1
  23412. * * 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}
  23413. * * 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}
  23414. * @returns the VertexData of the TiledGround
  23415. */
  23416. static CreateTiledGround(options: {
  23417. xmin: number;
  23418. zmin: number;
  23419. xmax: number;
  23420. zmax: number;
  23421. subdivisions?: {
  23422. w: number;
  23423. h: number;
  23424. };
  23425. precision?: {
  23426. w: number;
  23427. h: number;
  23428. };
  23429. }): VertexData;
  23430. /**
  23431. * Creates the VertexData of the Ground designed from a heightmap
  23432. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23433. * * width the width (x direction) of the ground
  23434. * * height the height (z direction) of the ground
  23435. * * subdivisions the number of subdivisions per side
  23436. * * minHeight the minimum altitude on the ground, optional, default 0
  23437. * * maxHeight the maximum altitude on the ground, optional default 1
  23438. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23439. * * buffer the array holding the image color data
  23440. * * bufferWidth the width of image
  23441. * * bufferHeight the height of image
  23442. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23443. * @returns the VertexData of the Ground designed from a heightmap
  23444. */
  23445. static CreateGroundFromHeightMap(options: {
  23446. width: number;
  23447. height: number;
  23448. subdivisions: number;
  23449. minHeight: number;
  23450. maxHeight: number;
  23451. colorFilter: Color3;
  23452. buffer: Uint8Array;
  23453. bufferWidth: number;
  23454. bufferHeight: number;
  23455. alphaFilter: number;
  23456. }): VertexData;
  23457. /**
  23458. * Creates the VertexData for a Plane
  23459. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23460. * * size sets the width and height of the plane to the value of size, optional default 1
  23461. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23462. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23463. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23464. * * 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)
  23465. * * 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)
  23466. * @returns the VertexData of the box
  23467. */
  23468. static CreatePlane(options: {
  23469. size?: number;
  23470. width?: number;
  23471. height?: number;
  23472. sideOrientation?: number;
  23473. frontUVs?: Vector4;
  23474. backUVs?: Vector4;
  23475. }): VertexData;
  23476. /**
  23477. * Creates the VertexData of the Disc or regular Polygon
  23478. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23479. * * radius the radius of the disc, optional default 0.5
  23480. * * tessellation the number of polygon sides, optional, default 64
  23481. * * 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
  23482. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23483. * * 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)
  23484. * * 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)
  23485. * @returns the VertexData of the box
  23486. */
  23487. static CreateDisc(options: {
  23488. radius?: number;
  23489. tessellation?: number;
  23490. arc?: number;
  23491. sideOrientation?: number;
  23492. frontUVs?: Vector4;
  23493. backUVs?: Vector4;
  23494. }): VertexData;
  23495. /**
  23496. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23497. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23498. * @param polygon a mesh built from polygonTriangulation.build()
  23499. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23500. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23501. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23502. * @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)
  23503. * @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)
  23504. * @returns the VertexData of the Polygon
  23505. */
  23506. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23507. /**
  23508. * Creates the VertexData of the IcoSphere
  23509. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23510. * * radius the radius of the IcoSphere, optional default 1
  23511. * * radiusX allows stretching in the x direction, optional, default radius
  23512. * * radiusY allows stretching in the y direction, optional, default radius
  23513. * * radiusZ allows stretching in the z direction, optional, default radius
  23514. * * flat when true creates a flat shaded mesh, optional, default true
  23515. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23516. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23517. * * 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)
  23518. * * 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)
  23519. * @returns the VertexData of the IcoSphere
  23520. */
  23521. static CreateIcoSphere(options: {
  23522. radius?: number;
  23523. radiusX?: number;
  23524. radiusY?: number;
  23525. radiusZ?: number;
  23526. flat?: boolean;
  23527. subdivisions?: number;
  23528. sideOrientation?: number;
  23529. frontUVs?: Vector4;
  23530. backUVs?: Vector4;
  23531. }): VertexData;
  23532. /**
  23533. * Creates the VertexData for a Polyhedron
  23534. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23535. * * type provided types are:
  23536. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23537. * * 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)
  23538. * * size the size of the IcoSphere, optional default 1
  23539. * * sizeX allows stretching in the x direction, optional, default size
  23540. * * sizeY allows stretching in the y direction, optional, default size
  23541. * * sizeZ allows stretching in the z direction, optional, default size
  23542. * * 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
  23543. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23544. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23545. * * flat when true creates a flat shaded mesh, optional, default true
  23546. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23547. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23548. * * 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)
  23549. * * 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)
  23550. * @returns the VertexData of the Polyhedron
  23551. */
  23552. static CreatePolyhedron(options: {
  23553. type?: number;
  23554. size?: number;
  23555. sizeX?: number;
  23556. sizeY?: number;
  23557. sizeZ?: number;
  23558. custom?: any;
  23559. faceUV?: Vector4[];
  23560. faceColors?: Color4[];
  23561. flat?: boolean;
  23562. sideOrientation?: number;
  23563. frontUVs?: Vector4;
  23564. backUVs?: Vector4;
  23565. }): VertexData;
  23566. /**
  23567. * Creates the VertexData for a TorusKnot
  23568. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23569. * * radius the radius of the torus knot, optional, default 2
  23570. * * tube the thickness of the tube, optional, default 0.5
  23571. * * radialSegments the number of sides on each tube segments, optional, default 32
  23572. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23573. * * p the number of windings around the z axis, optional, default 2
  23574. * * q the number of windings around the x axis, optional, default 3
  23575. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23576. * * 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)
  23577. * * 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)
  23578. * @returns the VertexData of the Torus Knot
  23579. */
  23580. static CreateTorusKnot(options: {
  23581. radius?: number;
  23582. tube?: number;
  23583. radialSegments?: number;
  23584. tubularSegments?: number;
  23585. p?: number;
  23586. q?: number;
  23587. sideOrientation?: number;
  23588. frontUVs?: Vector4;
  23589. backUVs?: Vector4;
  23590. }): VertexData;
  23591. /**
  23592. * Compute normals for given positions and indices
  23593. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23594. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23595. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23596. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23597. * * facetNormals : optional array of facet normals (vector3)
  23598. * * facetPositions : optional array of facet positions (vector3)
  23599. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23600. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23601. * * bInfo : optional bounding info, required for facetPartitioning computation
  23602. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23603. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23604. * * useRightHandedSystem: optional boolean to for right handed system computation
  23605. * * depthSort : optional boolean to enable the facet depth sort computation
  23606. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23607. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23608. */
  23609. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23610. facetNormals?: any;
  23611. facetPositions?: any;
  23612. facetPartitioning?: any;
  23613. ratio?: number;
  23614. bInfo?: any;
  23615. bbSize?: Vector3;
  23616. subDiv?: any;
  23617. useRightHandedSystem?: boolean;
  23618. depthSort?: boolean;
  23619. distanceTo?: Vector3;
  23620. depthSortedFacets?: any;
  23621. }): void;
  23622. /** @hidden */
  23623. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23624. /**
  23625. * Applies VertexData created from the imported parameters to the geometry
  23626. * @param parsedVertexData the parsed data from an imported file
  23627. * @param geometry the geometry to apply the VertexData to
  23628. */
  23629. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23630. }
  23631. }
  23632. declare module BABYLON {
  23633. /**
  23634. * Class containing static functions to help procedurally build meshes
  23635. */
  23636. export class DiscBuilder {
  23637. /**
  23638. * Creates a plane polygonal mesh. By default, this is a disc
  23639. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23640. * * 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
  23641. * * 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
  23642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23643. * * 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
  23644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23645. * @param name defines the name of the mesh
  23646. * @param options defines the options used to create the mesh
  23647. * @param scene defines the hosting scene
  23648. * @returns the plane polygonal mesh
  23649. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23650. */
  23651. static CreateDisc(name: string, options: {
  23652. radius?: number;
  23653. tessellation?: number;
  23654. arc?: number;
  23655. updatable?: boolean;
  23656. sideOrientation?: number;
  23657. frontUVs?: Vector4;
  23658. backUVs?: Vector4;
  23659. }, scene?: Nullable<Scene>): Mesh;
  23660. }
  23661. }
  23662. declare module BABYLON {
  23663. /**
  23664. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23665. *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.
  23666. * The SPS is also a particle system. It provides some methods to manage the particles.
  23667. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23668. *
  23669. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23670. */
  23671. export class SolidParticleSystem implements IDisposable {
  23672. /**
  23673. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23674. * Example : var p = SPS.particles[i];
  23675. */
  23676. particles: SolidParticle[];
  23677. /**
  23678. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23679. */
  23680. nbParticles: number;
  23681. /**
  23682. * If the particles must ever face the camera (default false). Useful for planar particles.
  23683. */
  23684. billboard: boolean;
  23685. /**
  23686. * Recompute normals when adding a shape
  23687. */
  23688. recomputeNormals: boolean;
  23689. /**
  23690. * This a counter ofr your own usage. It's not set by any SPS functions.
  23691. */
  23692. counter: number;
  23693. /**
  23694. * The SPS name. This name is also given to the underlying mesh.
  23695. */
  23696. name: string;
  23697. /**
  23698. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23699. */
  23700. mesh: Mesh;
  23701. /**
  23702. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23703. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23704. */
  23705. vars: any;
  23706. /**
  23707. * This array is populated when the SPS is set as 'pickable'.
  23708. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23709. * Each element of this array is an object `{idx: int, faceId: int}`.
  23710. * `idx` is the picked particle index in the `SPS.particles` array
  23711. * `faceId` is the picked face index counted within this particle.
  23712. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23713. */
  23714. pickedParticles: {
  23715. idx: number;
  23716. faceId: number;
  23717. }[];
  23718. /**
  23719. * This array is populated when `enableDepthSort` is set to true.
  23720. * Each element of this array is an instance of the class DepthSortedParticle.
  23721. */
  23722. depthSortedParticles: DepthSortedParticle[];
  23723. /**
  23724. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23725. * @hidden
  23726. */
  23727. _bSphereOnly: boolean;
  23728. /**
  23729. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23730. * @hidden
  23731. */
  23732. _bSphereRadiusFactor: number;
  23733. private _scene;
  23734. private _positions;
  23735. private _indices;
  23736. private _normals;
  23737. private _colors;
  23738. private _uvs;
  23739. private _indices32;
  23740. private _positions32;
  23741. private _normals32;
  23742. private _fixedNormal32;
  23743. private _colors32;
  23744. private _uvs32;
  23745. private _index;
  23746. private _updatable;
  23747. private _pickable;
  23748. private _isVisibilityBoxLocked;
  23749. private _alwaysVisible;
  23750. private _depthSort;
  23751. private _shapeCounter;
  23752. private _copy;
  23753. private _color;
  23754. private _computeParticleColor;
  23755. private _computeParticleTexture;
  23756. private _computeParticleRotation;
  23757. private _computeParticleVertex;
  23758. private _computeBoundingBox;
  23759. private _depthSortParticles;
  23760. private _camera;
  23761. private _mustUnrotateFixedNormals;
  23762. private _particlesIntersect;
  23763. private _needs32Bits;
  23764. /**
  23765. * Creates a SPS (Solid Particle System) object.
  23766. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23767. * @param scene (Scene) is the scene in which the SPS is added.
  23768. * @param options defines the options of the sps e.g.
  23769. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23770. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23771. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23772. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23773. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23774. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23775. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23776. */
  23777. constructor(name: string, scene: Scene, options?: {
  23778. updatable?: boolean;
  23779. isPickable?: boolean;
  23780. enableDepthSort?: boolean;
  23781. particleIntersection?: boolean;
  23782. boundingSphereOnly?: boolean;
  23783. bSphereRadiusFactor?: number;
  23784. });
  23785. /**
  23786. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23787. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23788. * @returns the created mesh
  23789. */
  23790. buildMesh(): Mesh;
  23791. /**
  23792. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23793. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23794. * Thus the particles generated from `digest()` have their property `position` set yet.
  23795. * @param mesh ( Mesh ) is the mesh to be digested
  23796. * @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
  23797. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23798. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23799. * @returns the current SPS
  23800. */
  23801. digest(mesh: Mesh, options?: {
  23802. facetNb?: number;
  23803. number?: number;
  23804. delta?: number;
  23805. }): SolidParticleSystem;
  23806. private _unrotateFixedNormals;
  23807. private _resetCopy;
  23808. private _meshBuilder;
  23809. private _posToShape;
  23810. private _uvsToShapeUV;
  23811. private _addParticle;
  23812. /**
  23813. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23814. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23815. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23816. * @param nb (positive integer) the number of particles to be created from this model
  23817. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23818. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23819. * @returns the number of shapes in the system
  23820. */
  23821. addShape(mesh: Mesh, nb: number, options?: {
  23822. positionFunction?: any;
  23823. vertexFunction?: any;
  23824. }): number;
  23825. private _rebuildParticle;
  23826. /**
  23827. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23828. * @returns the SPS.
  23829. */
  23830. rebuildMesh(): SolidParticleSystem;
  23831. /**
  23832. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23833. * This method calls `updateParticle()` for each particle of the SPS.
  23834. * For an animated SPS, it is usually called within the render loop.
  23835. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23836. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23837. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23838. * @returns the SPS.
  23839. */
  23840. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23841. /**
  23842. * Disposes the SPS.
  23843. */
  23844. dispose(): void;
  23845. /**
  23846. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23847. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23848. * @returns the SPS.
  23849. */
  23850. refreshVisibleSize(): SolidParticleSystem;
  23851. /**
  23852. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23853. * @param size the size (float) of the visibility box
  23854. * note : this doesn't lock the SPS mesh bounding box.
  23855. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23856. */
  23857. setVisibilityBox(size: number): void;
  23858. /**
  23859. * Gets whether the SPS as always visible or not
  23860. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23861. */
  23862. /**
  23863. * Sets the SPS as always visible or not
  23864. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23865. */
  23866. isAlwaysVisible: boolean;
  23867. /**
  23868. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23869. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23870. */
  23871. /**
  23872. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23873. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23874. */
  23875. isVisibilityBoxLocked: boolean;
  23876. /**
  23877. * Tells to `setParticles()` to compute the particle rotations or not.
  23878. * Default value : true. The SPS is faster when it's set to false.
  23879. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23880. */
  23881. /**
  23882. * Gets if `setParticles()` computes the particle rotations or not.
  23883. * Default value : true. The SPS is faster when it's set to false.
  23884. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23885. */
  23886. computeParticleRotation: boolean;
  23887. /**
  23888. * Tells to `setParticles()` to compute the particle colors or not.
  23889. * Default value : true. The SPS is faster when it's set to false.
  23890. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23891. */
  23892. /**
  23893. * Gets if `setParticles()` computes the particle colors or not.
  23894. * Default value : true. The SPS is faster when it's set to false.
  23895. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23896. */
  23897. computeParticleColor: boolean;
  23898. /**
  23899. * Gets if `setParticles()` computes the particle textures or not.
  23900. * Default value : true. The SPS is faster when it's set to false.
  23901. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23902. */
  23903. computeParticleTexture: boolean;
  23904. /**
  23905. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23906. * Default value : false. The SPS is faster when it's set to false.
  23907. * Note : the particle custom vertex positions aren't stored values.
  23908. */
  23909. /**
  23910. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23911. * Default value : false. The SPS is faster when it's set to false.
  23912. * Note : the particle custom vertex positions aren't stored values.
  23913. */
  23914. computeParticleVertex: boolean;
  23915. /**
  23916. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23917. */
  23918. /**
  23919. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23920. */
  23921. computeBoundingBox: boolean;
  23922. /**
  23923. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23924. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23925. * Default : `true`
  23926. */
  23927. /**
  23928. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23929. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23930. * Default : `true`
  23931. */
  23932. depthSortParticles: boolean;
  23933. /**
  23934. * This function does nothing. It may be overwritten to set all the particle first values.
  23935. * The SPS doesn't call this function, you may have to call it by your own.
  23936. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23937. */
  23938. initParticles(): void;
  23939. /**
  23940. * This function does nothing. It may be overwritten to recycle a particle.
  23941. * The SPS doesn't call this function, you may have to call it by your own.
  23942. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23943. * @param particle The particle to recycle
  23944. * @returns the recycled particle
  23945. */
  23946. recycleParticle(particle: SolidParticle): SolidParticle;
  23947. /**
  23948. * Updates a particle : this function should be overwritten by the user.
  23949. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23950. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23951. * @example : just set a particle position or velocity and recycle conditions
  23952. * @param particle The particle to update
  23953. * @returns the updated particle
  23954. */
  23955. updateParticle(particle: SolidParticle): SolidParticle;
  23956. /**
  23957. * Updates a vertex of a particle : it can be overwritten by the user.
  23958. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23959. * @param particle the current particle
  23960. * @param vertex the current index of the current particle
  23961. * @param pt the index of the current vertex in the particle shape
  23962. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23963. * @example : just set a vertex particle position
  23964. * @returns the updated vertex
  23965. */
  23966. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23967. /**
  23968. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23969. * This does nothing and may be overwritten by the user.
  23970. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23971. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23972. * @param update the boolean update value actually passed to setParticles()
  23973. */
  23974. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23975. /**
  23976. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23977. * This will be passed three parameters.
  23978. * This does nothing and may be overwritten by the user.
  23979. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23980. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23981. * @param update the boolean update value actually passed to setParticles()
  23982. */
  23983. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23984. }
  23985. }
  23986. declare module BABYLON {
  23987. /**
  23988. * Represents one particle of a solid particle system.
  23989. */
  23990. export class SolidParticle {
  23991. /**
  23992. * particle global index
  23993. */
  23994. idx: number;
  23995. /**
  23996. * The color of the particle
  23997. */
  23998. color: Nullable<Color4>;
  23999. /**
  24000. * The world space position of the particle.
  24001. */
  24002. position: Vector3;
  24003. /**
  24004. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24005. */
  24006. rotation: Vector3;
  24007. /**
  24008. * The world space rotation quaternion of the particle.
  24009. */
  24010. rotationQuaternion: Nullable<Quaternion>;
  24011. /**
  24012. * The scaling of the particle.
  24013. */
  24014. scaling: Vector3;
  24015. /**
  24016. * The uvs of the particle.
  24017. */
  24018. uvs: Vector4;
  24019. /**
  24020. * The current speed of the particle.
  24021. */
  24022. velocity: Vector3;
  24023. /**
  24024. * The pivot point in the particle local space.
  24025. */
  24026. pivot: Vector3;
  24027. /**
  24028. * Must the particle be translated from its pivot point in its local space ?
  24029. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24030. * Default : false
  24031. */
  24032. translateFromPivot: boolean;
  24033. /**
  24034. * Is the particle active or not ?
  24035. */
  24036. alive: boolean;
  24037. /**
  24038. * Is the particle visible or not ?
  24039. */
  24040. isVisible: boolean;
  24041. /**
  24042. * Index of this particle in the global "positions" array (Internal use)
  24043. * @hidden
  24044. */
  24045. _pos: number;
  24046. /**
  24047. * @hidden Index of this particle in the global "indices" array (Internal use)
  24048. */
  24049. _ind: number;
  24050. /**
  24051. * @hidden ModelShape of this particle (Internal use)
  24052. */
  24053. _model: ModelShape;
  24054. /**
  24055. * ModelShape id of this particle
  24056. */
  24057. shapeId: number;
  24058. /**
  24059. * Index of the particle in its shape id (Internal use)
  24060. */
  24061. idxInShape: number;
  24062. /**
  24063. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24064. */
  24065. _modelBoundingInfo: BoundingInfo;
  24066. /**
  24067. * @hidden Particle BoundingInfo object (Internal use)
  24068. */
  24069. _boundingInfo: BoundingInfo;
  24070. /**
  24071. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24072. */
  24073. _sps: SolidParticleSystem;
  24074. /**
  24075. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24076. */
  24077. _stillInvisible: boolean;
  24078. /**
  24079. * @hidden Last computed particle rotation matrix
  24080. */
  24081. _rotationMatrix: number[];
  24082. /**
  24083. * Parent particle Id, if any.
  24084. * Default null.
  24085. */
  24086. parentId: Nullable<number>;
  24087. /**
  24088. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24089. * The possible values are :
  24090. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24091. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24092. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24093. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24094. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24095. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24096. * */
  24097. cullingStrategy: number;
  24098. /**
  24099. * @hidden Internal global position in the SPS.
  24100. */
  24101. _globalPosition: Vector3;
  24102. /**
  24103. * Creates a Solid Particle object.
  24104. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24105. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24106. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24107. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24108. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24109. * @param shapeId (integer) is the model shape identifier in the SPS.
  24110. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24111. * @param sps defines the sps it is associated to
  24112. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24113. */
  24114. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24115. /**
  24116. * Legacy support, changed scale to scaling
  24117. */
  24118. /**
  24119. * Legacy support, changed scale to scaling
  24120. */
  24121. scale: Vector3;
  24122. /**
  24123. * Legacy support, changed quaternion to rotationQuaternion
  24124. */
  24125. /**
  24126. * Legacy support, changed quaternion to rotationQuaternion
  24127. */
  24128. quaternion: Nullable<Quaternion>;
  24129. /**
  24130. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24131. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24132. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24133. * @returns true if it intersects
  24134. */
  24135. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24136. /**
  24137. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24138. * A particle is in the frustum if its bounding box intersects the frustum
  24139. * @param frustumPlanes defines the frustum to test
  24140. * @returns true if the particle is in the frustum planes
  24141. */
  24142. isInFrustum(frustumPlanes: Plane[]): boolean;
  24143. /**
  24144. * get the rotation matrix of the particle
  24145. * @hidden
  24146. */
  24147. getRotationMatrix(m: Matrix): void;
  24148. }
  24149. /**
  24150. * Represents the shape of the model used by one particle of a solid particle system.
  24151. * SPS internal tool, don't use it manually.
  24152. */
  24153. export class ModelShape {
  24154. /**
  24155. * The shape id
  24156. * @hidden
  24157. */
  24158. shapeID: number;
  24159. /**
  24160. * flat array of model positions (internal use)
  24161. * @hidden
  24162. */
  24163. _shape: Vector3[];
  24164. /**
  24165. * flat array of model UVs (internal use)
  24166. * @hidden
  24167. */
  24168. _shapeUV: number[];
  24169. /**
  24170. * length of the shape in the model indices array (internal use)
  24171. * @hidden
  24172. */
  24173. _indicesLength: number;
  24174. /**
  24175. * Custom position function (internal use)
  24176. * @hidden
  24177. */
  24178. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24179. /**
  24180. * Custom vertex function (internal use)
  24181. * @hidden
  24182. */
  24183. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24184. /**
  24185. * 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.
  24186. * SPS internal tool, don't use it manually.
  24187. * @hidden
  24188. */
  24189. 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>);
  24190. }
  24191. /**
  24192. * Represents a Depth Sorted Particle in the solid particle system.
  24193. */
  24194. export class DepthSortedParticle {
  24195. /**
  24196. * Index of the particle in the "indices" array
  24197. */
  24198. ind: number;
  24199. /**
  24200. * Length of the particle shape in the "indices" array
  24201. */
  24202. indicesLength: number;
  24203. /**
  24204. * Squared distance from the particle to the camera
  24205. */
  24206. sqDistance: number;
  24207. }
  24208. }
  24209. declare module BABYLON {
  24210. /**
  24211. * @hidden
  24212. */
  24213. export class _MeshCollisionData {
  24214. _checkCollisions: boolean;
  24215. _collisionMask: number;
  24216. _collisionGroup: number;
  24217. _collider: Nullable<Collider>;
  24218. _oldPositionForCollisions: Vector3;
  24219. _diffPositionForCollisions: Vector3;
  24220. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24221. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24222. }
  24223. }
  24224. declare module BABYLON {
  24225. /** @hidden */
  24226. class _FacetDataStorage {
  24227. facetPositions: Vector3[];
  24228. facetNormals: Vector3[];
  24229. facetPartitioning: number[][];
  24230. facetNb: number;
  24231. partitioningSubdivisions: number;
  24232. partitioningBBoxRatio: number;
  24233. facetDataEnabled: boolean;
  24234. facetParameters: any;
  24235. bbSize: Vector3;
  24236. subDiv: {
  24237. max: number;
  24238. X: number;
  24239. Y: number;
  24240. Z: number;
  24241. };
  24242. facetDepthSort: boolean;
  24243. facetDepthSortEnabled: boolean;
  24244. depthSortedIndices: IndicesArray;
  24245. depthSortedFacets: {
  24246. ind: number;
  24247. sqDistance: number;
  24248. }[];
  24249. facetDepthSortFunction: (f1: {
  24250. ind: number;
  24251. sqDistance: number;
  24252. }, f2: {
  24253. ind: number;
  24254. sqDistance: number;
  24255. }) => number;
  24256. facetDepthSortFrom: Vector3;
  24257. facetDepthSortOrigin: Vector3;
  24258. invertedMatrix: Matrix;
  24259. }
  24260. /**
  24261. * @hidden
  24262. **/
  24263. class _InternalAbstractMeshDataInfo {
  24264. _hasVertexAlpha: boolean;
  24265. _useVertexColors: boolean;
  24266. _numBoneInfluencers: number;
  24267. _applyFog: boolean;
  24268. _receiveShadows: boolean;
  24269. _facetData: _FacetDataStorage;
  24270. _visibility: number;
  24271. _skeleton: Nullable<Skeleton>;
  24272. _layerMask: number;
  24273. _computeBonesUsingShaders: boolean;
  24274. _isActive: boolean;
  24275. _onlyForInstances: boolean;
  24276. _isActiveIntermediate: boolean;
  24277. _onlyForInstancesIntermediate: boolean;
  24278. }
  24279. /**
  24280. * Class used to store all common mesh properties
  24281. */
  24282. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24283. /** No occlusion */
  24284. static OCCLUSION_TYPE_NONE: number;
  24285. /** Occlusion set to optimisitic */
  24286. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24287. /** Occlusion set to strict */
  24288. static OCCLUSION_TYPE_STRICT: number;
  24289. /** Use an accurante occlusion algorithm */
  24290. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24291. /** Use a conservative occlusion algorithm */
  24292. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24293. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24294. * Test order :
  24295. * Is the bounding sphere outside the frustum ?
  24296. * If not, are the bounding box vertices outside the frustum ?
  24297. * It not, then the cullable object is in the frustum.
  24298. */
  24299. static readonly CULLINGSTRATEGY_STANDARD: number;
  24300. /** Culling strategy : Bounding Sphere Only.
  24301. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24302. * It's also less accurate than the standard because some not visible objects can still be selected.
  24303. * Test : is the bounding sphere outside the frustum ?
  24304. * If not, then the cullable object is in the frustum.
  24305. */
  24306. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24307. /** Culling strategy : Optimistic Inclusion.
  24308. * This in an inclusion test first, then the standard exclusion test.
  24309. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24310. * 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.
  24311. * Anyway, it's as accurate as the standard strategy.
  24312. * Test :
  24313. * Is the cullable object bounding sphere center in the frustum ?
  24314. * If not, apply the default culling strategy.
  24315. */
  24316. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24317. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24318. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24319. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24320. * 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.
  24321. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24322. * Test :
  24323. * Is the cullable object bounding sphere center in the frustum ?
  24324. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24325. */
  24326. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24327. /**
  24328. * No billboard
  24329. */
  24330. static readonly BILLBOARDMODE_NONE: number;
  24331. /** Billboard on X axis */
  24332. static readonly BILLBOARDMODE_X: number;
  24333. /** Billboard on Y axis */
  24334. static readonly BILLBOARDMODE_Y: number;
  24335. /** Billboard on Z axis */
  24336. static readonly BILLBOARDMODE_Z: number;
  24337. /** Billboard on all axes */
  24338. static readonly BILLBOARDMODE_ALL: number;
  24339. /** @hidden */
  24340. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  24341. /**
  24342. * The culling strategy to use to check whether the mesh must be rendered or not.
  24343. * This value can be changed at any time and will be used on the next render mesh selection.
  24344. * The possible values are :
  24345. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24346. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24347. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24348. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24349. * Please read each static variable documentation to get details about the culling process.
  24350. * */
  24351. cullingStrategy: number;
  24352. /**
  24353. * Gets the number of facets in the mesh
  24354. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24355. */
  24356. readonly facetNb: number;
  24357. /**
  24358. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24359. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24360. */
  24361. partitioningSubdivisions: number;
  24362. /**
  24363. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24364. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24365. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24366. */
  24367. partitioningBBoxRatio: number;
  24368. /**
  24369. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24370. * Works only for updatable meshes.
  24371. * Doesn't work with multi-materials
  24372. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24373. */
  24374. mustDepthSortFacets: boolean;
  24375. /**
  24376. * The location (Vector3) where the facet depth sort must be computed from.
  24377. * By default, the active camera position.
  24378. * Used only when facet depth sort is enabled
  24379. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24380. */
  24381. facetDepthSortFrom: Vector3;
  24382. /**
  24383. * gets a boolean indicating if facetData is enabled
  24384. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24385. */
  24386. readonly isFacetDataEnabled: boolean;
  24387. /** @hidden */
  24388. _updateNonUniformScalingState(value: boolean): boolean;
  24389. /**
  24390. * An event triggered when this mesh collides with another one
  24391. */
  24392. onCollideObservable: Observable<AbstractMesh>;
  24393. /** Set a function to call when this mesh collides with another one */
  24394. onCollide: () => void;
  24395. /**
  24396. * An event triggered when the collision's position changes
  24397. */
  24398. onCollisionPositionChangeObservable: Observable<Vector3>;
  24399. /** Set a function to call when the collision's position changes */
  24400. onCollisionPositionChange: () => void;
  24401. /**
  24402. * An event triggered when material is changed
  24403. */
  24404. onMaterialChangedObservable: Observable<AbstractMesh>;
  24405. /**
  24406. * Gets or sets the orientation for POV movement & rotation
  24407. */
  24408. definedFacingForward: boolean;
  24409. /** @hidden */
  24410. _occlusionQuery: Nullable<WebGLQuery>;
  24411. /** @hidden */
  24412. _renderingGroup: Nullable<RenderingGroup>;
  24413. /**
  24414. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24415. */
  24416. /**
  24417. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24418. */
  24419. visibility: number;
  24420. /** Gets or sets the alpha index used to sort transparent meshes
  24421. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24422. */
  24423. alphaIndex: number;
  24424. /**
  24425. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24426. */
  24427. isVisible: boolean;
  24428. /**
  24429. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24430. */
  24431. isPickable: boolean;
  24432. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24433. showSubMeshesBoundingBox: boolean;
  24434. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24435. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24436. */
  24437. isBlocker: boolean;
  24438. /**
  24439. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24440. */
  24441. enablePointerMoveEvents: boolean;
  24442. /**
  24443. * Specifies the rendering group id for this mesh (0 by default)
  24444. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24445. */
  24446. renderingGroupId: number;
  24447. private _material;
  24448. /** Gets or sets current material */
  24449. material: Nullable<Material>;
  24450. /**
  24451. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24452. * @see http://doc.babylonjs.com/babylon101/shadows
  24453. */
  24454. receiveShadows: boolean;
  24455. /** Defines color to use when rendering outline */
  24456. outlineColor: Color3;
  24457. /** Define width to use when rendering outline */
  24458. outlineWidth: number;
  24459. /** Defines color to use when rendering overlay */
  24460. overlayColor: Color3;
  24461. /** Defines alpha to use when rendering overlay */
  24462. overlayAlpha: number;
  24463. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24464. hasVertexAlpha: boolean;
  24465. /** 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) */
  24466. useVertexColors: boolean;
  24467. /**
  24468. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24469. */
  24470. computeBonesUsingShaders: boolean;
  24471. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24472. numBoneInfluencers: number;
  24473. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24474. applyFog: boolean;
  24475. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24476. useOctreeForRenderingSelection: boolean;
  24477. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24478. useOctreeForPicking: boolean;
  24479. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24480. useOctreeForCollisions: boolean;
  24481. /**
  24482. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24483. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24484. */
  24485. layerMask: number;
  24486. /**
  24487. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24488. */
  24489. alwaysSelectAsActiveMesh: boolean;
  24490. /**
  24491. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24492. */
  24493. doNotSyncBoundingInfo: boolean;
  24494. /**
  24495. * Gets or sets the current action manager
  24496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24497. */
  24498. actionManager: Nullable<AbstractActionManager>;
  24499. private _meshCollisionData;
  24500. /**
  24501. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24502. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24503. */
  24504. ellipsoid: Vector3;
  24505. /**
  24506. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24507. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24508. */
  24509. ellipsoidOffset: Vector3;
  24510. /**
  24511. * Gets or sets a collision mask used to mask collisions (default is -1).
  24512. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24513. */
  24514. collisionMask: number;
  24515. /**
  24516. * Gets or sets the current collision group mask (-1 by default).
  24517. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24518. */
  24519. collisionGroup: number;
  24520. /**
  24521. * Defines edge width used when edgesRenderer is enabled
  24522. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24523. */
  24524. edgesWidth: number;
  24525. /**
  24526. * Defines edge color used when edgesRenderer is enabled
  24527. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24528. */
  24529. edgesColor: Color4;
  24530. /** @hidden */
  24531. _edgesRenderer: Nullable<IEdgesRenderer>;
  24532. /** @hidden */
  24533. _masterMesh: Nullable<AbstractMesh>;
  24534. /** @hidden */
  24535. _boundingInfo: Nullable<BoundingInfo>;
  24536. /** @hidden */
  24537. _renderId: number;
  24538. /**
  24539. * Gets or sets the list of subMeshes
  24540. * @see http://doc.babylonjs.com/how_to/multi_materials
  24541. */
  24542. subMeshes: SubMesh[];
  24543. /** @hidden */
  24544. _intersectionsInProgress: AbstractMesh[];
  24545. /** @hidden */
  24546. _unIndexed: boolean;
  24547. /** @hidden */
  24548. _lightSources: Light[];
  24549. /** Gets the list of lights affecting that mesh */
  24550. readonly lightSources: Light[];
  24551. /** @hidden */
  24552. readonly _positions: Nullable<Vector3[]>;
  24553. /** @hidden */
  24554. _waitingData: {
  24555. lods: Nullable<any>;
  24556. actions: Nullable<any>;
  24557. freezeWorldMatrix: Nullable<boolean>;
  24558. };
  24559. /** @hidden */
  24560. _bonesTransformMatrices: Nullable<Float32Array>;
  24561. /**
  24562. * Gets or sets a skeleton to apply skining transformations
  24563. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24564. */
  24565. skeleton: Nullable<Skeleton>;
  24566. /**
  24567. * An event triggered when the mesh is rebuilt.
  24568. */
  24569. onRebuildObservable: Observable<AbstractMesh>;
  24570. /**
  24571. * Creates a new AbstractMesh
  24572. * @param name defines the name of the mesh
  24573. * @param scene defines the hosting scene
  24574. */
  24575. constructor(name: string, scene?: Nullable<Scene>);
  24576. /**
  24577. * Returns the string "AbstractMesh"
  24578. * @returns "AbstractMesh"
  24579. */
  24580. getClassName(): string;
  24581. /**
  24582. * Gets a string representation of the current mesh
  24583. * @param fullDetails defines a boolean indicating if full details must be included
  24584. * @returns a string representation of the current mesh
  24585. */
  24586. toString(fullDetails?: boolean): string;
  24587. /**
  24588. * @hidden
  24589. */
  24590. protected _getEffectiveParent(): Nullable<Node>;
  24591. /** @hidden */
  24592. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24593. /** @hidden */
  24594. _rebuild(): void;
  24595. /** @hidden */
  24596. _resyncLightSources(): void;
  24597. /** @hidden */
  24598. _resyncLighSource(light: Light): void;
  24599. /** @hidden */
  24600. _unBindEffect(): void;
  24601. /** @hidden */
  24602. _removeLightSource(light: Light): void;
  24603. private _markSubMeshesAsDirty;
  24604. /** @hidden */
  24605. _markSubMeshesAsLightDirty(): void;
  24606. /** @hidden */
  24607. _markSubMeshesAsAttributesDirty(): void;
  24608. /** @hidden */
  24609. _markSubMeshesAsMiscDirty(): void;
  24610. /**
  24611. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24612. */
  24613. scaling: Vector3;
  24614. /**
  24615. * Returns true if the mesh is blocked. Implemented by child classes
  24616. */
  24617. readonly isBlocked: boolean;
  24618. /**
  24619. * Returns the mesh itself by default. Implemented by child classes
  24620. * @param camera defines the camera to use to pick the right LOD level
  24621. * @returns the currentAbstractMesh
  24622. */
  24623. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24624. /**
  24625. * Returns 0 by default. Implemented by child classes
  24626. * @returns an integer
  24627. */
  24628. getTotalVertices(): number;
  24629. /**
  24630. * Returns a positive integer : the total number of indices in this mesh geometry.
  24631. * @returns the numner of indices or zero if the mesh has no geometry.
  24632. */
  24633. getTotalIndices(): number;
  24634. /**
  24635. * Returns null by default. Implemented by child classes
  24636. * @returns null
  24637. */
  24638. getIndices(): Nullable<IndicesArray>;
  24639. /**
  24640. * Returns the array of the requested vertex data kind. Implemented by child classes
  24641. * @param kind defines the vertex data kind to use
  24642. * @returns null
  24643. */
  24644. getVerticesData(kind: string): Nullable<FloatArray>;
  24645. /**
  24646. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24647. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24648. * Note that a new underlying VertexBuffer object is created each call.
  24649. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24650. * @param kind defines vertex data kind:
  24651. * * VertexBuffer.PositionKind
  24652. * * VertexBuffer.UVKind
  24653. * * VertexBuffer.UV2Kind
  24654. * * VertexBuffer.UV3Kind
  24655. * * VertexBuffer.UV4Kind
  24656. * * VertexBuffer.UV5Kind
  24657. * * VertexBuffer.UV6Kind
  24658. * * VertexBuffer.ColorKind
  24659. * * VertexBuffer.MatricesIndicesKind
  24660. * * VertexBuffer.MatricesIndicesExtraKind
  24661. * * VertexBuffer.MatricesWeightsKind
  24662. * * VertexBuffer.MatricesWeightsExtraKind
  24663. * @param data defines the data source
  24664. * @param updatable defines if the data must be flagged as updatable (or static)
  24665. * @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
  24666. * @returns the current mesh
  24667. */
  24668. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24669. /**
  24670. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24671. * If the mesh has no geometry, it is simply returned as it is.
  24672. * @param kind defines vertex data kind:
  24673. * * VertexBuffer.PositionKind
  24674. * * VertexBuffer.UVKind
  24675. * * VertexBuffer.UV2Kind
  24676. * * VertexBuffer.UV3Kind
  24677. * * VertexBuffer.UV4Kind
  24678. * * VertexBuffer.UV5Kind
  24679. * * VertexBuffer.UV6Kind
  24680. * * VertexBuffer.ColorKind
  24681. * * VertexBuffer.MatricesIndicesKind
  24682. * * VertexBuffer.MatricesIndicesExtraKind
  24683. * * VertexBuffer.MatricesWeightsKind
  24684. * * VertexBuffer.MatricesWeightsExtraKind
  24685. * @param data defines the data source
  24686. * @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
  24687. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24688. * @returns the current mesh
  24689. */
  24690. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24691. /**
  24692. * Sets the mesh indices,
  24693. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24694. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24695. * @param totalVertices Defines the total number of vertices
  24696. * @returns the current mesh
  24697. */
  24698. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24699. /**
  24700. * Gets a boolean indicating if specific vertex data is present
  24701. * @param kind defines the vertex data kind to use
  24702. * @returns true is data kind is present
  24703. */
  24704. isVerticesDataPresent(kind: string): boolean;
  24705. /**
  24706. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24707. * @returns a BoundingInfo
  24708. */
  24709. getBoundingInfo(): BoundingInfo;
  24710. /**
  24711. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24712. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24713. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24714. * @returns the current mesh
  24715. */
  24716. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24717. /**
  24718. * Overwrite the current bounding info
  24719. * @param boundingInfo defines the new bounding info
  24720. * @returns the current mesh
  24721. */
  24722. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24723. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24724. readonly useBones: boolean;
  24725. /** @hidden */
  24726. _preActivate(): void;
  24727. /** @hidden */
  24728. _preActivateForIntermediateRendering(renderId: number): void;
  24729. /** @hidden */
  24730. _activate(renderId: number, intermediateRendering: boolean): boolean;
  24731. /** @hidden */
  24732. _postActivate(): void;
  24733. /** @hidden */
  24734. _freeze(): void;
  24735. /** @hidden */
  24736. _unFreeze(): void;
  24737. /**
  24738. * Gets the current world matrix
  24739. * @returns a Matrix
  24740. */
  24741. getWorldMatrix(): Matrix;
  24742. /** @hidden */
  24743. _getWorldMatrixDeterminant(): number;
  24744. /**
  24745. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24746. */
  24747. readonly isAnInstance: boolean;
  24748. /**
  24749. * Perform relative position change from the point of view of behind the front of the mesh.
  24750. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24751. * Supports definition of mesh facing forward or backward
  24752. * @param amountRight defines the distance on the right axis
  24753. * @param amountUp defines the distance on the up axis
  24754. * @param amountForward defines the distance on the forward axis
  24755. * @returns the current mesh
  24756. */
  24757. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24758. /**
  24759. * Calculate relative position change from the point of view of behind the front of the mesh.
  24760. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24761. * Supports definition of mesh facing forward or backward
  24762. * @param amountRight defines the distance on the right axis
  24763. * @param amountUp defines the distance on the up axis
  24764. * @param amountForward defines the distance on the forward axis
  24765. * @returns the new displacement vector
  24766. */
  24767. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24768. /**
  24769. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24770. * Supports definition of mesh facing forward or backward
  24771. * @param flipBack defines the flip
  24772. * @param twirlClockwise defines the twirl
  24773. * @param tiltRight defines the tilt
  24774. * @returns the current mesh
  24775. */
  24776. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24777. /**
  24778. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24779. * Supports definition of mesh facing forward or backward.
  24780. * @param flipBack defines the flip
  24781. * @param twirlClockwise defines the twirl
  24782. * @param tiltRight defines the tilt
  24783. * @returns the new rotation vector
  24784. */
  24785. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24786. /**
  24787. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24788. * This means the mesh underlying bounding box and sphere are recomputed.
  24789. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24790. * @returns the current mesh
  24791. */
  24792. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24793. /** @hidden */
  24794. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24795. /** @hidden */
  24796. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24797. /** @hidden */
  24798. _updateBoundingInfo(): AbstractMesh;
  24799. /** @hidden */
  24800. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24801. /** @hidden */
  24802. protected _afterComputeWorldMatrix(): void;
  24803. /** @hidden */
  24804. readonly _effectiveMesh: AbstractMesh;
  24805. /**
  24806. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24807. * A mesh is in the frustum if its bounding box intersects the frustum
  24808. * @param frustumPlanes defines the frustum to test
  24809. * @returns true if the mesh is in the frustum planes
  24810. */
  24811. isInFrustum(frustumPlanes: Plane[]): boolean;
  24812. /**
  24813. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24814. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24815. * @param frustumPlanes defines the frustum to test
  24816. * @returns true if the mesh is completely in the frustum planes
  24817. */
  24818. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24819. /**
  24820. * True if the mesh intersects another mesh or a SolidParticle object
  24821. * @param mesh defines a target mesh or SolidParticle to test
  24822. * @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)
  24823. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24824. * @returns true if there is an intersection
  24825. */
  24826. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24827. /**
  24828. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24829. * @param point defines the point to test
  24830. * @returns true if there is an intersection
  24831. */
  24832. intersectsPoint(point: Vector3): boolean;
  24833. /**
  24834. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24835. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24836. */
  24837. checkCollisions: boolean;
  24838. /**
  24839. * Gets Collider object used to compute collisions (not physics)
  24840. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24841. */
  24842. readonly collider: Nullable<Collider>;
  24843. /**
  24844. * Move the mesh using collision engine
  24845. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24846. * @param displacement defines the requested displacement vector
  24847. * @returns the current mesh
  24848. */
  24849. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24850. private _onCollisionPositionChange;
  24851. /** @hidden */
  24852. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24853. /** @hidden */
  24854. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24855. /** @hidden */
  24856. _checkCollision(collider: Collider): AbstractMesh;
  24857. /** @hidden */
  24858. _generatePointsArray(): boolean;
  24859. /**
  24860. * Checks if the passed Ray intersects with the mesh
  24861. * @param ray defines the ray to use
  24862. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24863. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24864. * @returns the picking info
  24865. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24866. */
  24867. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24868. /**
  24869. * Clones the current mesh
  24870. * @param name defines the mesh name
  24871. * @param newParent defines the new mesh parent
  24872. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24873. * @returns the new mesh
  24874. */
  24875. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24876. /**
  24877. * Disposes all the submeshes of the current meshnp
  24878. * @returns the current mesh
  24879. */
  24880. releaseSubMeshes(): AbstractMesh;
  24881. /**
  24882. * Releases resources associated with this abstract mesh.
  24883. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24884. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24885. */
  24886. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24887. /**
  24888. * Adds the passed mesh as a child to the current mesh
  24889. * @param mesh defines the child mesh
  24890. * @returns the current mesh
  24891. */
  24892. addChild(mesh: AbstractMesh): AbstractMesh;
  24893. /**
  24894. * Removes the passed mesh from the current mesh children list
  24895. * @param mesh defines the child mesh
  24896. * @returns the current mesh
  24897. */
  24898. removeChild(mesh: AbstractMesh): AbstractMesh;
  24899. /** @hidden */
  24900. private _initFacetData;
  24901. /**
  24902. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24903. * This method can be called within the render loop.
  24904. * 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
  24905. * @returns the current mesh
  24906. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24907. */
  24908. updateFacetData(): AbstractMesh;
  24909. /**
  24910. * Returns the facetLocalNormals array.
  24911. * The normals are expressed in the mesh local spac
  24912. * @returns an array of Vector3
  24913. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24914. */
  24915. getFacetLocalNormals(): Vector3[];
  24916. /**
  24917. * Returns the facetLocalPositions array.
  24918. * The facet positions are expressed in the mesh local space
  24919. * @returns an array of Vector3
  24920. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24921. */
  24922. getFacetLocalPositions(): Vector3[];
  24923. /**
  24924. * Returns the facetLocalPartioning array
  24925. * @returns an array of array of numbers
  24926. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24927. */
  24928. getFacetLocalPartitioning(): number[][];
  24929. /**
  24930. * Returns the i-th facet position in the world system.
  24931. * This method allocates a new Vector3 per call
  24932. * @param i defines the facet index
  24933. * @returns a new Vector3
  24934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24935. */
  24936. getFacetPosition(i: number): Vector3;
  24937. /**
  24938. * Sets the reference Vector3 with the i-th facet position in the world system
  24939. * @param i defines the facet index
  24940. * @param ref defines the target vector
  24941. * @returns the current mesh
  24942. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24943. */
  24944. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24945. /**
  24946. * Returns the i-th facet normal in the world system.
  24947. * This method allocates a new Vector3 per call
  24948. * @param i defines the facet index
  24949. * @returns a new Vector3
  24950. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24951. */
  24952. getFacetNormal(i: number): Vector3;
  24953. /**
  24954. * Sets the reference Vector3 with the i-th facet normal in the world system
  24955. * @param i defines the facet index
  24956. * @param ref defines the target vector
  24957. * @returns the current mesh
  24958. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24959. */
  24960. getFacetNormalToRef(i: number, ref: Vector3): this;
  24961. /**
  24962. * 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)
  24963. * @param x defines x coordinate
  24964. * @param y defines y coordinate
  24965. * @param z defines z coordinate
  24966. * @returns the array of facet indexes
  24967. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24968. */
  24969. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24970. /**
  24971. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24972. * @param projected sets as the (x,y,z) world projection on the facet
  24973. * @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
  24974. * @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
  24975. * @param x defines x coordinate
  24976. * @param y defines y coordinate
  24977. * @param z defines z coordinate
  24978. * @returns the face index if found (or null instead)
  24979. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24980. */
  24981. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24982. /**
  24983. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24984. * @param projected sets as the (x,y,z) local projection on the facet
  24985. * @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
  24986. * @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
  24987. * @param x defines x coordinate
  24988. * @param y defines y coordinate
  24989. * @param z defines z coordinate
  24990. * @returns the face index if found (or null instead)
  24991. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24992. */
  24993. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24994. /**
  24995. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24996. * @returns the parameters
  24997. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24998. */
  24999. getFacetDataParameters(): any;
  25000. /**
  25001. * Disables the feature FacetData and frees the related memory
  25002. * @returns the current mesh
  25003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25004. */
  25005. disableFacetData(): AbstractMesh;
  25006. /**
  25007. * Updates the AbstractMesh indices array
  25008. * @param indices defines the data source
  25009. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25010. * @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)
  25011. * @returns the current mesh
  25012. */
  25013. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25014. /**
  25015. * Creates new normals data for the mesh
  25016. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25017. * @returns the current mesh
  25018. */
  25019. createNormals(updatable: boolean): AbstractMesh;
  25020. /**
  25021. * Align the mesh with a normal
  25022. * @param normal defines the normal to use
  25023. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25024. * @returns the current mesh
  25025. */
  25026. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25027. /** @hidden */
  25028. _checkOcclusionQuery(): boolean;
  25029. /**
  25030. * Disables the mesh edge rendering mode
  25031. * @returns the currentAbstractMesh
  25032. */
  25033. disableEdgesRendering(): AbstractMesh;
  25034. /**
  25035. * Enables the edge rendering mode on the mesh.
  25036. * This mode makes the mesh edges visible
  25037. * @param epsilon defines the maximal distance between two angles to detect a face
  25038. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25039. * @returns the currentAbstractMesh
  25040. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25041. */
  25042. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25043. }
  25044. }
  25045. declare module BABYLON {
  25046. /**
  25047. * Interface used to define ActionEvent
  25048. */
  25049. export interface IActionEvent {
  25050. /** The mesh or sprite that triggered the action */
  25051. source: any;
  25052. /** The X mouse cursor position at the time of the event */
  25053. pointerX: number;
  25054. /** The Y mouse cursor position at the time of the event */
  25055. pointerY: number;
  25056. /** The mesh that is currently pointed at (can be null) */
  25057. meshUnderPointer: Nullable<AbstractMesh>;
  25058. /** the original (browser) event that triggered the ActionEvent */
  25059. sourceEvent?: any;
  25060. /** additional data for the event */
  25061. additionalData?: any;
  25062. }
  25063. /**
  25064. * ActionEvent is the event being sent when an action is triggered.
  25065. */
  25066. export class ActionEvent implements IActionEvent {
  25067. /** The mesh or sprite that triggered the action */
  25068. source: any;
  25069. /** The X mouse cursor position at the time of the event */
  25070. pointerX: number;
  25071. /** The Y mouse cursor position at the time of the event */
  25072. pointerY: number;
  25073. /** The mesh that is currently pointed at (can be null) */
  25074. meshUnderPointer: Nullable<AbstractMesh>;
  25075. /** the original (browser) event that triggered the ActionEvent */
  25076. sourceEvent?: any;
  25077. /** additional data for the event */
  25078. additionalData?: any;
  25079. /**
  25080. * Creates a new ActionEvent
  25081. * @param source The mesh or sprite that triggered the action
  25082. * @param pointerX The X mouse cursor position at the time of the event
  25083. * @param pointerY The Y mouse cursor position at the time of the event
  25084. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25085. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25086. * @param additionalData additional data for the event
  25087. */
  25088. constructor(
  25089. /** The mesh or sprite that triggered the action */
  25090. source: any,
  25091. /** The X mouse cursor position at the time of the event */
  25092. pointerX: number,
  25093. /** The Y mouse cursor position at the time of the event */
  25094. pointerY: number,
  25095. /** The mesh that is currently pointed at (can be null) */
  25096. meshUnderPointer: Nullable<AbstractMesh>,
  25097. /** the original (browser) event that triggered the ActionEvent */
  25098. sourceEvent?: any,
  25099. /** additional data for the event */
  25100. additionalData?: any);
  25101. /**
  25102. * Helper function to auto-create an ActionEvent from a source mesh.
  25103. * @param source The source mesh that triggered the event
  25104. * @param evt The original (browser) event
  25105. * @param additionalData additional data for the event
  25106. * @returns the new ActionEvent
  25107. */
  25108. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25109. /**
  25110. * Helper function to auto-create an ActionEvent from a source sprite
  25111. * @param source The source sprite that triggered the event
  25112. * @param scene Scene associated with the sprite
  25113. * @param evt The original (browser) event
  25114. * @param additionalData additional data for the event
  25115. * @returns the new ActionEvent
  25116. */
  25117. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25118. /**
  25119. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25120. * @param scene the scene where the event occurred
  25121. * @param evt The original (browser) event
  25122. * @returns the new ActionEvent
  25123. */
  25124. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25125. /**
  25126. * Helper function to auto-create an ActionEvent from a primitive
  25127. * @param prim defines the target primitive
  25128. * @param pointerPos defines the pointer position
  25129. * @param evt The original (browser) event
  25130. * @param additionalData additional data for the event
  25131. * @returns the new ActionEvent
  25132. */
  25133. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25134. }
  25135. }
  25136. declare module BABYLON {
  25137. /**
  25138. * Abstract class used to decouple action Manager from scene and meshes.
  25139. * Do not instantiate.
  25140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25141. */
  25142. export abstract class AbstractActionManager implements IDisposable {
  25143. /** Gets the list of active triggers */
  25144. static Triggers: {
  25145. [key: string]: number;
  25146. };
  25147. /** Gets the cursor to use when hovering items */
  25148. hoverCursor: string;
  25149. /** Gets the list of actions */
  25150. actions: IAction[];
  25151. /**
  25152. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25153. */
  25154. isRecursive: boolean;
  25155. /**
  25156. * Releases all associated resources
  25157. */
  25158. abstract dispose(): void;
  25159. /**
  25160. * Does this action manager has pointer triggers
  25161. */
  25162. abstract readonly hasPointerTriggers: boolean;
  25163. /**
  25164. * Does this action manager has pick triggers
  25165. */
  25166. abstract readonly hasPickTriggers: boolean;
  25167. /**
  25168. * Process a specific trigger
  25169. * @param trigger defines the trigger to process
  25170. * @param evt defines the event details to be processed
  25171. */
  25172. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25173. /**
  25174. * Does this action manager handles actions of any of the given triggers
  25175. * @param triggers defines the triggers to be tested
  25176. * @return a boolean indicating whether one (or more) of the triggers is handled
  25177. */
  25178. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25179. /**
  25180. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25181. * speed.
  25182. * @param triggerA defines the trigger to be tested
  25183. * @param triggerB defines the trigger to be tested
  25184. * @return a boolean indicating whether one (or more) of the triggers is handled
  25185. */
  25186. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25187. /**
  25188. * Does this action manager handles actions of a given trigger
  25189. * @param trigger defines the trigger to be tested
  25190. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25191. * @return whether the trigger is handled
  25192. */
  25193. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25194. /**
  25195. * Serialize this manager to a JSON object
  25196. * @param name defines the property name to store this manager
  25197. * @returns a JSON representation of this manager
  25198. */
  25199. abstract serialize(name: string): any;
  25200. /**
  25201. * Registers an action to this action manager
  25202. * @param action defines the action to be registered
  25203. * @return the action amended (prepared) after registration
  25204. */
  25205. abstract registerAction(action: IAction): Nullable<IAction>;
  25206. /**
  25207. * Unregisters an action to this action manager
  25208. * @param action defines the action to be unregistered
  25209. * @return a boolean indicating whether the action has been unregistered
  25210. */
  25211. abstract unregisterAction(action: IAction): Boolean;
  25212. /**
  25213. * Does exist one action manager with at least one trigger
  25214. **/
  25215. static readonly HasTriggers: boolean;
  25216. /**
  25217. * Does exist one action manager with at least one pick trigger
  25218. **/
  25219. static readonly HasPickTriggers: boolean;
  25220. /**
  25221. * Does exist one action manager that handles actions of a given trigger
  25222. * @param trigger defines the trigger to be tested
  25223. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25224. **/
  25225. static HasSpecificTrigger(trigger: number): boolean;
  25226. }
  25227. }
  25228. declare module BABYLON {
  25229. /**
  25230. * Defines how a node can be built from a string name.
  25231. */
  25232. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25233. /**
  25234. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25235. */
  25236. export class Node implements IBehaviorAware<Node> {
  25237. /** @hidden */
  25238. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25239. private static _NodeConstructors;
  25240. /**
  25241. * Add a new node constructor
  25242. * @param type defines the type name of the node to construct
  25243. * @param constructorFunc defines the constructor function
  25244. */
  25245. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25246. /**
  25247. * Returns a node constructor based on type name
  25248. * @param type defines the type name
  25249. * @param name defines the new node name
  25250. * @param scene defines the hosting scene
  25251. * @param options defines optional options to transmit to constructors
  25252. * @returns the new constructor or null
  25253. */
  25254. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25255. /**
  25256. * Gets or sets the name of the node
  25257. */
  25258. name: string;
  25259. /**
  25260. * Gets or sets the id of the node
  25261. */
  25262. id: string;
  25263. /**
  25264. * Gets or sets the unique id of the node
  25265. */
  25266. uniqueId: number;
  25267. /**
  25268. * Gets or sets a string used to store user defined state for the node
  25269. */
  25270. state: string;
  25271. /**
  25272. * Gets or sets an object used to store user defined information for the node
  25273. */
  25274. metadata: any;
  25275. /**
  25276. * For internal use only. Please do not use.
  25277. */
  25278. reservedDataStore: any;
  25279. /**
  25280. * List of inspectable custom properties (used by the Inspector)
  25281. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25282. */
  25283. inspectableCustomProperties: IInspectable[];
  25284. /**
  25285. * Gets or sets a boolean used to define if the node must be serialized
  25286. */
  25287. doNotSerialize: boolean;
  25288. /** @hidden */
  25289. _isDisposed: boolean;
  25290. /**
  25291. * Gets a list of Animations associated with the node
  25292. */
  25293. animations: Animation[];
  25294. protected _ranges: {
  25295. [name: string]: Nullable<AnimationRange>;
  25296. };
  25297. /**
  25298. * Callback raised when the node is ready to be used
  25299. */
  25300. onReady: Nullable<(node: Node) => void>;
  25301. private _isEnabled;
  25302. private _isParentEnabled;
  25303. private _isReady;
  25304. /** @hidden */
  25305. _currentRenderId: number;
  25306. private _parentUpdateId;
  25307. /** @hidden */
  25308. _childUpdateId: number;
  25309. /** @hidden */
  25310. _waitingParentId: Nullable<string>;
  25311. /** @hidden */
  25312. _scene: Scene;
  25313. /** @hidden */
  25314. _cache: any;
  25315. private _parentNode;
  25316. private _children;
  25317. /** @hidden */
  25318. _worldMatrix: Matrix;
  25319. /** @hidden */
  25320. _worldMatrixDeterminant: number;
  25321. /** @hidden */
  25322. _worldMatrixDeterminantIsDirty: boolean;
  25323. /** @hidden */
  25324. private _sceneRootNodesIndex;
  25325. /**
  25326. * Gets a boolean indicating if the node has been disposed
  25327. * @returns true if the node was disposed
  25328. */
  25329. isDisposed(): boolean;
  25330. /**
  25331. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25332. * @see https://doc.babylonjs.com/how_to/parenting
  25333. */
  25334. parent: Nullable<Node>;
  25335. private addToSceneRootNodes;
  25336. private removeFromSceneRootNodes;
  25337. private _animationPropertiesOverride;
  25338. /**
  25339. * Gets or sets the animation properties override
  25340. */
  25341. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25342. /**
  25343. * Gets a string idenfifying the name of the class
  25344. * @returns "Node" string
  25345. */
  25346. getClassName(): string;
  25347. /** @hidden */
  25348. readonly _isNode: boolean;
  25349. /**
  25350. * An event triggered when the mesh is disposed
  25351. */
  25352. onDisposeObservable: Observable<Node>;
  25353. private _onDisposeObserver;
  25354. /**
  25355. * Sets a callback that will be raised when the node will be disposed
  25356. */
  25357. onDispose: () => void;
  25358. /**
  25359. * Creates a new Node
  25360. * @param name the name and id to be given to this node
  25361. * @param scene the scene this node will be added to
  25362. * @param addToRootNodes the node will be added to scene.rootNodes
  25363. */
  25364. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25365. /**
  25366. * Gets the scene of the node
  25367. * @returns a scene
  25368. */
  25369. getScene(): Scene;
  25370. /**
  25371. * Gets the engine of the node
  25372. * @returns a Engine
  25373. */
  25374. getEngine(): Engine;
  25375. private _behaviors;
  25376. /**
  25377. * Attach a behavior to the node
  25378. * @see http://doc.babylonjs.com/features/behaviour
  25379. * @param behavior defines the behavior to attach
  25380. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25381. * @returns the current Node
  25382. */
  25383. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25384. /**
  25385. * Remove an attached behavior
  25386. * @see http://doc.babylonjs.com/features/behaviour
  25387. * @param behavior defines the behavior to attach
  25388. * @returns the current Node
  25389. */
  25390. removeBehavior(behavior: Behavior<Node>): Node;
  25391. /**
  25392. * Gets the list of attached behaviors
  25393. * @see http://doc.babylonjs.com/features/behaviour
  25394. */
  25395. readonly behaviors: Behavior<Node>[];
  25396. /**
  25397. * Gets an attached behavior by name
  25398. * @param name defines the name of the behavior to look for
  25399. * @see http://doc.babylonjs.com/features/behaviour
  25400. * @returns null if behavior was not found else the requested behavior
  25401. */
  25402. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25403. /**
  25404. * Returns the latest update of the World matrix
  25405. * @returns a Matrix
  25406. */
  25407. getWorldMatrix(): Matrix;
  25408. /** @hidden */
  25409. _getWorldMatrixDeterminant(): number;
  25410. /**
  25411. * Returns directly the latest state of the mesh World matrix.
  25412. * A Matrix is returned.
  25413. */
  25414. readonly worldMatrixFromCache: Matrix;
  25415. /** @hidden */
  25416. _initCache(): void;
  25417. /** @hidden */
  25418. updateCache(force?: boolean): void;
  25419. /** @hidden */
  25420. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25421. /** @hidden */
  25422. _updateCache(ignoreParentClass?: boolean): void;
  25423. /** @hidden */
  25424. _isSynchronized(): boolean;
  25425. /** @hidden */
  25426. _markSyncedWithParent(): void;
  25427. /** @hidden */
  25428. isSynchronizedWithParent(): boolean;
  25429. /** @hidden */
  25430. isSynchronized(): boolean;
  25431. /**
  25432. * Is this node ready to be used/rendered
  25433. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25434. * @return true if the node is ready
  25435. */
  25436. isReady(completeCheck?: boolean): boolean;
  25437. /**
  25438. * Is this node enabled?
  25439. * 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
  25440. * @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
  25441. * @return whether this node (and its parent) is enabled
  25442. */
  25443. isEnabled(checkAncestors?: boolean): boolean;
  25444. /** @hidden */
  25445. protected _syncParentEnabledState(): void;
  25446. /**
  25447. * Set the enabled state of this node
  25448. * @param value defines the new enabled state
  25449. */
  25450. setEnabled(value: boolean): void;
  25451. /**
  25452. * Is this node a descendant of the given node?
  25453. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25454. * @param ancestor defines the parent node to inspect
  25455. * @returns a boolean indicating if this node is a descendant of the given node
  25456. */
  25457. isDescendantOf(ancestor: Node): boolean;
  25458. /** @hidden */
  25459. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25460. /**
  25461. * Will return all nodes that have this node as ascendant
  25462. * @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
  25463. * @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
  25464. * @return all children nodes of all types
  25465. */
  25466. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25467. /**
  25468. * Get all child-meshes of this node
  25469. * @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)
  25470. * @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
  25471. * @returns an array of AbstractMesh
  25472. */
  25473. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25474. /**
  25475. * Get all direct children of this node
  25476. * @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
  25477. * @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)
  25478. * @returns an array of Node
  25479. */
  25480. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25481. /** @hidden */
  25482. _setReady(state: boolean): void;
  25483. /**
  25484. * Get an animation by name
  25485. * @param name defines the name of the animation to look for
  25486. * @returns null if not found else the requested animation
  25487. */
  25488. getAnimationByName(name: string): Nullable<Animation>;
  25489. /**
  25490. * Creates an animation range for this node
  25491. * @param name defines the name of the range
  25492. * @param from defines the starting key
  25493. * @param to defines the end key
  25494. */
  25495. createAnimationRange(name: string, from: number, to: number): void;
  25496. /**
  25497. * Delete a specific animation range
  25498. * @param name defines the name of the range to delete
  25499. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25500. */
  25501. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25502. /**
  25503. * Get an animation range by name
  25504. * @param name defines the name of the animation range to look for
  25505. * @returns null if not found else the requested animation range
  25506. */
  25507. getAnimationRange(name: string): Nullable<AnimationRange>;
  25508. /**
  25509. * Gets the list of all animation ranges defined on this node
  25510. * @returns an array
  25511. */
  25512. getAnimationRanges(): Nullable<AnimationRange>[];
  25513. /**
  25514. * Will start the animation sequence
  25515. * @param name defines the range frames for animation sequence
  25516. * @param loop defines if the animation should loop (false by default)
  25517. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25518. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25519. * @returns the object created for this animation. If range does not exist, it will return null
  25520. */
  25521. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25522. /**
  25523. * Serialize animation ranges into a JSON compatible object
  25524. * @returns serialization object
  25525. */
  25526. serializeAnimationRanges(): any;
  25527. /**
  25528. * Computes the world matrix of the node
  25529. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25530. * @returns the world matrix
  25531. */
  25532. computeWorldMatrix(force?: boolean): Matrix;
  25533. /**
  25534. * Releases resources associated with this node.
  25535. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25536. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25537. */
  25538. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25539. /**
  25540. * Parse animation range data from a serialization object and store them into a given node
  25541. * @param node defines where to store the animation ranges
  25542. * @param parsedNode defines the serialization object to read data from
  25543. * @param scene defines the hosting scene
  25544. */
  25545. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25546. /**
  25547. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25548. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25549. * @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
  25550. * @returns the new bounding vectors
  25551. */
  25552. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25553. min: Vector3;
  25554. max: Vector3;
  25555. };
  25556. }
  25557. }
  25558. declare module BABYLON {
  25559. /**
  25560. * @hidden
  25561. */
  25562. export class _IAnimationState {
  25563. key: number;
  25564. repeatCount: number;
  25565. workValue?: any;
  25566. loopMode?: number;
  25567. offsetValue?: any;
  25568. highLimitValue?: any;
  25569. }
  25570. /**
  25571. * Class used to store any kind of animation
  25572. */
  25573. export class Animation {
  25574. /**Name of the animation */
  25575. name: string;
  25576. /**Property to animate */
  25577. targetProperty: string;
  25578. /**The frames per second of the animation */
  25579. framePerSecond: number;
  25580. /**The data type of the animation */
  25581. dataType: number;
  25582. /**The loop mode of the animation */
  25583. loopMode?: number | undefined;
  25584. /**Specifies if blending should be enabled */
  25585. enableBlending?: boolean | undefined;
  25586. /**
  25587. * Use matrix interpolation instead of using direct key value when animating matrices
  25588. */
  25589. static AllowMatricesInterpolation: boolean;
  25590. /**
  25591. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25592. */
  25593. static AllowMatrixDecomposeForInterpolation: boolean;
  25594. /**
  25595. * Stores the key frames of the animation
  25596. */
  25597. private _keys;
  25598. /**
  25599. * Stores the easing function of the animation
  25600. */
  25601. private _easingFunction;
  25602. /**
  25603. * @hidden Internal use only
  25604. */
  25605. _runtimeAnimations: RuntimeAnimation[];
  25606. /**
  25607. * The set of event that will be linked to this animation
  25608. */
  25609. private _events;
  25610. /**
  25611. * Stores an array of target property paths
  25612. */
  25613. targetPropertyPath: string[];
  25614. /**
  25615. * Stores the blending speed of the animation
  25616. */
  25617. blendingSpeed: number;
  25618. /**
  25619. * Stores the animation ranges for the animation
  25620. */
  25621. private _ranges;
  25622. /**
  25623. * @hidden Internal use
  25624. */
  25625. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25626. /**
  25627. * Sets up an animation
  25628. * @param property The property to animate
  25629. * @param animationType The animation type to apply
  25630. * @param framePerSecond The frames per second of the animation
  25631. * @param easingFunction The easing function used in the animation
  25632. * @returns The created animation
  25633. */
  25634. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25635. /**
  25636. * Create and start an animation on a node
  25637. * @param name defines the name of the global animation that will be run on all nodes
  25638. * @param node defines the root node where the animation will take place
  25639. * @param targetProperty defines property to animate
  25640. * @param framePerSecond defines the number of frame per second yo use
  25641. * @param totalFrame defines the number of frames in total
  25642. * @param from defines the initial value
  25643. * @param to defines the final value
  25644. * @param loopMode defines which loop mode you want to use (off by default)
  25645. * @param easingFunction defines the easing function to use (linear by default)
  25646. * @param onAnimationEnd defines the callback to call when animation end
  25647. * @returns the animatable created for this animation
  25648. */
  25649. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25650. /**
  25651. * Create and start an animation on a node and its descendants
  25652. * @param name defines the name of the global animation that will be run on all nodes
  25653. * @param node defines the root node where the animation will take place
  25654. * @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
  25655. * @param targetProperty defines property to animate
  25656. * @param framePerSecond defines the number of frame per second to use
  25657. * @param totalFrame defines the number of frames in total
  25658. * @param from defines the initial value
  25659. * @param to defines the final value
  25660. * @param loopMode defines which loop mode you want to use (off by default)
  25661. * @param easingFunction defines the easing function to use (linear by default)
  25662. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25663. * @returns the list of animatables created for all nodes
  25664. * @example https://www.babylonjs-playground.com/#MH0VLI
  25665. */
  25666. 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[]>;
  25667. /**
  25668. * Creates a new animation, merges it with the existing animations and starts it
  25669. * @param name Name of the animation
  25670. * @param node Node which contains the scene that begins the animations
  25671. * @param targetProperty Specifies which property to animate
  25672. * @param framePerSecond The frames per second of the animation
  25673. * @param totalFrame The total number of frames
  25674. * @param from The frame at the beginning of the animation
  25675. * @param to The frame at the end of the animation
  25676. * @param loopMode Specifies the loop mode of the animation
  25677. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25678. * @param onAnimationEnd Callback to run once the animation is complete
  25679. * @returns Nullable animation
  25680. */
  25681. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25682. /**
  25683. * Transition property of an host to the target Value
  25684. * @param property The property to transition
  25685. * @param targetValue The target Value of the property
  25686. * @param host The object where the property to animate belongs
  25687. * @param scene Scene used to run the animation
  25688. * @param frameRate Framerate (in frame/s) to use
  25689. * @param transition The transition type we want to use
  25690. * @param duration The duration of the animation, in milliseconds
  25691. * @param onAnimationEnd Callback trigger at the end of the animation
  25692. * @returns Nullable animation
  25693. */
  25694. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25695. /**
  25696. * Return the array of runtime animations currently using this animation
  25697. */
  25698. readonly runtimeAnimations: RuntimeAnimation[];
  25699. /**
  25700. * Specifies if any of the runtime animations are currently running
  25701. */
  25702. readonly hasRunningRuntimeAnimations: boolean;
  25703. /**
  25704. * Initializes the animation
  25705. * @param name Name of the animation
  25706. * @param targetProperty Property to animate
  25707. * @param framePerSecond The frames per second of the animation
  25708. * @param dataType The data type of the animation
  25709. * @param loopMode The loop mode of the animation
  25710. * @param enableBlending Specifies if blending should be enabled
  25711. */
  25712. constructor(
  25713. /**Name of the animation */
  25714. name: string,
  25715. /**Property to animate */
  25716. targetProperty: string,
  25717. /**The frames per second of the animation */
  25718. framePerSecond: number,
  25719. /**The data type of the animation */
  25720. dataType: number,
  25721. /**The loop mode of the animation */
  25722. loopMode?: number | undefined,
  25723. /**Specifies if blending should be enabled */
  25724. enableBlending?: boolean | undefined);
  25725. /**
  25726. * Converts the animation to a string
  25727. * @param fullDetails support for multiple levels of logging within scene loading
  25728. * @returns String form of the animation
  25729. */
  25730. toString(fullDetails?: boolean): string;
  25731. /**
  25732. * Add an event to this animation
  25733. * @param event Event to add
  25734. */
  25735. addEvent(event: AnimationEvent): void;
  25736. /**
  25737. * Remove all events found at the given frame
  25738. * @param frame The frame to remove events from
  25739. */
  25740. removeEvents(frame: number): void;
  25741. /**
  25742. * Retrieves all the events from the animation
  25743. * @returns Events from the animation
  25744. */
  25745. getEvents(): AnimationEvent[];
  25746. /**
  25747. * Creates an animation range
  25748. * @param name Name of the animation range
  25749. * @param from Starting frame of the animation range
  25750. * @param to Ending frame of the animation
  25751. */
  25752. createRange(name: string, from: number, to: number): void;
  25753. /**
  25754. * Deletes an animation range by name
  25755. * @param name Name of the animation range to delete
  25756. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25757. */
  25758. deleteRange(name: string, deleteFrames?: boolean): void;
  25759. /**
  25760. * Gets the animation range by name, or null if not defined
  25761. * @param name Name of the animation range
  25762. * @returns Nullable animation range
  25763. */
  25764. getRange(name: string): Nullable<AnimationRange>;
  25765. /**
  25766. * Gets the key frames from the animation
  25767. * @returns The key frames of the animation
  25768. */
  25769. getKeys(): Array<IAnimationKey>;
  25770. /**
  25771. * Gets the highest frame rate of the animation
  25772. * @returns Highest frame rate of the animation
  25773. */
  25774. getHighestFrame(): number;
  25775. /**
  25776. * Gets the easing function of the animation
  25777. * @returns Easing function of the animation
  25778. */
  25779. getEasingFunction(): IEasingFunction;
  25780. /**
  25781. * Sets the easing function of the animation
  25782. * @param easingFunction A custom mathematical formula for animation
  25783. */
  25784. setEasingFunction(easingFunction: EasingFunction): void;
  25785. /**
  25786. * Interpolates a scalar linearly
  25787. * @param startValue Start value of the animation curve
  25788. * @param endValue End value of the animation curve
  25789. * @param gradient Scalar amount to interpolate
  25790. * @returns Interpolated scalar value
  25791. */
  25792. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25793. /**
  25794. * Interpolates a scalar cubically
  25795. * @param startValue Start value of the animation curve
  25796. * @param outTangent End tangent of the animation
  25797. * @param endValue End value of the animation curve
  25798. * @param inTangent Start tangent of the animation curve
  25799. * @param gradient Scalar amount to interpolate
  25800. * @returns Interpolated scalar value
  25801. */
  25802. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25803. /**
  25804. * Interpolates a quaternion using a spherical linear interpolation
  25805. * @param startValue Start value of the animation curve
  25806. * @param endValue End value of the animation curve
  25807. * @param gradient Scalar amount to interpolate
  25808. * @returns Interpolated quaternion value
  25809. */
  25810. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25811. /**
  25812. * Interpolates a quaternion cubically
  25813. * @param startValue Start value of the animation curve
  25814. * @param outTangent End tangent of the animation curve
  25815. * @param endValue End value of the animation curve
  25816. * @param inTangent Start tangent of the animation curve
  25817. * @param gradient Scalar amount to interpolate
  25818. * @returns Interpolated quaternion value
  25819. */
  25820. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25821. /**
  25822. * Interpolates a Vector3 linearl
  25823. * @param startValue Start value of the animation curve
  25824. * @param endValue End value of the animation curve
  25825. * @param gradient Scalar amount to interpolate
  25826. * @returns Interpolated scalar value
  25827. */
  25828. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25829. /**
  25830. * Interpolates a Vector3 cubically
  25831. * @param startValue Start value of the animation curve
  25832. * @param outTangent End tangent of the animation
  25833. * @param endValue End value of the animation curve
  25834. * @param inTangent Start tangent of the animation curve
  25835. * @param gradient Scalar amount to interpolate
  25836. * @returns InterpolatedVector3 value
  25837. */
  25838. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25839. /**
  25840. * Interpolates a Vector2 linearly
  25841. * @param startValue Start value of the animation curve
  25842. * @param endValue End value of the animation curve
  25843. * @param gradient Scalar amount to interpolate
  25844. * @returns Interpolated Vector2 value
  25845. */
  25846. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25847. /**
  25848. * Interpolates a Vector2 cubically
  25849. * @param startValue Start value of the animation curve
  25850. * @param outTangent End tangent of the animation
  25851. * @param endValue End value of the animation curve
  25852. * @param inTangent Start tangent of the animation curve
  25853. * @param gradient Scalar amount to interpolate
  25854. * @returns Interpolated Vector2 value
  25855. */
  25856. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25857. /**
  25858. * Interpolates a size linearly
  25859. * @param startValue Start value of the animation curve
  25860. * @param endValue End value of the animation curve
  25861. * @param gradient Scalar amount to interpolate
  25862. * @returns Interpolated Size value
  25863. */
  25864. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25865. /**
  25866. * Interpolates a Color3 linearly
  25867. * @param startValue Start value of the animation curve
  25868. * @param endValue End value of the animation curve
  25869. * @param gradient Scalar amount to interpolate
  25870. * @returns Interpolated Color3 value
  25871. */
  25872. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25873. /**
  25874. * @hidden Internal use only
  25875. */
  25876. _getKeyValue(value: any): any;
  25877. /**
  25878. * @hidden Internal use only
  25879. */
  25880. _interpolate(currentFrame: number, state: _IAnimationState): any;
  25881. /**
  25882. * Defines the function to use to interpolate matrices
  25883. * @param startValue defines the start matrix
  25884. * @param endValue defines the end matrix
  25885. * @param gradient defines the gradient between both matrices
  25886. * @param result defines an optional target matrix where to store the interpolation
  25887. * @returns the interpolated matrix
  25888. */
  25889. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25890. /**
  25891. * Makes a copy of the animation
  25892. * @returns Cloned animation
  25893. */
  25894. clone(): Animation;
  25895. /**
  25896. * Sets the key frames of the animation
  25897. * @param values The animation key frames to set
  25898. */
  25899. setKeys(values: Array<IAnimationKey>): void;
  25900. /**
  25901. * Serializes the animation to an object
  25902. * @returns Serialized object
  25903. */
  25904. serialize(): any;
  25905. /**
  25906. * Float animation type
  25907. */
  25908. private static _ANIMATIONTYPE_FLOAT;
  25909. /**
  25910. * Vector3 animation type
  25911. */
  25912. private static _ANIMATIONTYPE_VECTOR3;
  25913. /**
  25914. * Quaternion animation type
  25915. */
  25916. private static _ANIMATIONTYPE_QUATERNION;
  25917. /**
  25918. * Matrix animation type
  25919. */
  25920. private static _ANIMATIONTYPE_MATRIX;
  25921. /**
  25922. * Color3 animation type
  25923. */
  25924. private static _ANIMATIONTYPE_COLOR3;
  25925. /**
  25926. * Vector2 animation type
  25927. */
  25928. private static _ANIMATIONTYPE_VECTOR2;
  25929. /**
  25930. * Size animation type
  25931. */
  25932. private static _ANIMATIONTYPE_SIZE;
  25933. /**
  25934. * Relative Loop Mode
  25935. */
  25936. private static _ANIMATIONLOOPMODE_RELATIVE;
  25937. /**
  25938. * Cycle Loop Mode
  25939. */
  25940. private static _ANIMATIONLOOPMODE_CYCLE;
  25941. /**
  25942. * Constant Loop Mode
  25943. */
  25944. private static _ANIMATIONLOOPMODE_CONSTANT;
  25945. /**
  25946. * Get the float animation type
  25947. */
  25948. static readonly ANIMATIONTYPE_FLOAT: number;
  25949. /**
  25950. * Get the Vector3 animation type
  25951. */
  25952. static readonly ANIMATIONTYPE_VECTOR3: number;
  25953. /**
  25954. * Get the Vector2 animation type
  25955. */
  25956. static readonly ANIMATIONTYPE_VECTOR2: number;
  25957. /**
  25958. * Get the Size animation type
  25959. */
  25960. static readonly ANIMATIONTYPE_SIZE: number;
  25961. /**
  25962. * Get the Quaternion animation type
  25963. */
  25964. static readonly ANIMATIONTYPE_QUATERNION: number;
  25965. /**
  25966. * Get the Matrix animation type
  25967. */
  25968. static readonly ANIMATIONTYPE_MATRIX: number;
  25969. /**
  25970. * Get the Color3 animation type
  25971. */
  25972. static readonly ANIMATIONTYPE_COLOR3: number;
  25973. /**
  25974. * Get the Relative Loop Mode
  25975. */
  25976. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25977. /**
  25978. * Get the Cycle Loop Mode
  25979. */
  25980. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25981. /**
  25982. * Get the Constant Loop Mode
  25983. */
  25984. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25985. /** @hidden */
  25986. static _UniversalLerp(left: any, right: any, amount: number): any;
  25987. /**
  25988. * Parses an animation object and creates an animation
  25989. * @param parsedAnimation Parsed animation object
  25990. * @returns Animation object
  25991. */
  25992. static Parse(parsedAnimation: any): Animation;
  25993. /**
  25994. * Appends the serialized animations from the source animations
  25995. * @param source Source containing the animations
  25996. * @param destination Target to store the animations
  25997. */
  25998. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25999. }
  26000. }
  26001. declare module BABYLON {
  26002. /**
  26003. * Base class of all the textures in babylon.
  26004. * It groups all the common properties the materials, post process, lights... might need
  26005. * in order to make a correct use of the texture.
  26006. */
  26007. export class BaseTexture implements IAnimatable {
  26008. /**
  26009. * Default anisotropic filtering level for the application.
  26010. * It is set to 4 as a good tradeoff between perf and quality.
  26011. */
  26012. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26013. /**
  26014. * Gets or sets the unique id of the texture
  26015. */
  26016. uniqueId: number;
  26017. /**
  26018. * Define the name of the texture.
  26019. */
  26020. name: string;
  26021. /**
  26022. * Gets or sets an object used to store user defined information.
  26023. */
  26024. metadata: any;
  26025. /**
  26026. * For internal use only. Please do not use.
  26027. */
  26028. reservedDataStore: any;
  26029. private _hasAlpha;
  26030. /**
  26031. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26032. */
  26033. hasAlpha: boolean;
  26034. /**
  26035. * Defines if the alpha value should be determined via the rgb values.
  26036. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26037. */
  26038. getAlphaFromRGB: boolean;
  26039. /**
  26040. * Intensity or strength of the texture.
  26041. * It is commonly used by materials to fine tune the intensity of the texture
  26042. */
  26043. level: number;
  26044. /**
  26045. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26046. * This is part of the texture as textures usually maps to one uv set.
  26047. */
  26048. coordinatesIndex: number;
  26049. private _coordinatesMode;
  26050. /**
  26051. * How a texture is mapped.
  26052. *
  26053. * | Value | Type | Description |
  26054. * | ----- | ----------------------------------- | ----------- |
  26055. * | 0 | EXPLICIT_MODE | |
  26056. * | 1 | SPHERICAL_MODE | |
  26057. * | 2 | PLANAR_MODE | |
  26058. * | 3 | CUBIC_MODE | |
  26059. * | 4 | PROJECTION_MODE | |
  26060. * | 5 | SKYBOX_MODE | |
  26061. * | 6 | INVCUBIC_MODE | |
  26062. * | 7 | EQUIRECTANGULAR_MODE | |
  26063. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26064. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26065. */
  26066. coordinatesMode: number;
  26067. /**
  26068. * | Value | Type | Description |
  26069. * | ----- | ------------------ | ----------- |
  26070. * | 0 | CLAMP_ADDRESSMODE | |
  26071. * | 1 | WRAP_ADDRESSMODE | |
  26072. * | 2 | MIRROR_ADDRESSMODE | |
  26073. */
  26074. wrapU: number;
  26075. /**
  26076. * | Value | Type | Description |
  26077. * | ----- | ------------------ | ----------- |
  26078. * | 0 | CLAMP_ADDRESSMODE | |
  26079. * | 1 | WRAP_ADDRESSMODE | |
  26080. * | 2 | MIRROR_ADDRESSMODE | |
  26081. */
  26082. wrapV: number;
  26083. /**
  26084. * | Value | Type | Description |
  26085. * | ----- | ------------------ | ----------- |
  26086. * | 0 | CLAMP_ADDRESSMODE | |
  26087. * | 1 | WRAP_ADDRESSMODE | |
  26088. * | 2 | MIRROR_ADDRESSMODE | |
  26089. */
  26090. wrapR: number;
  26091. /**
  26092. * With compliant hardware and browser (supporting anisotropic filtering)
  26093. * this defines the level of anisotropic filtering in the texture.
  26094. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26095. */
  26096. anisotropicFilteringLevel: number;
  26097. /**
  26098. * Define if the texture is a cube texture or if false a 2d texture.
  26099. */
  26100. isCube: boolean;
  26101. /**
  26102. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26103. */
  26104. is3D: boolean;
  26105. /**
  26106. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26107. * HDR texture are usually stored in linear space.
  26108. * This only impacts the PBR and Background materials
  26109. */
  26110. gammaSpace: boolean;
  26111. /**
  26112. * Gets whether or not the texture contains RGBD data.
  26113. */
  26114. readonly isRGBD: boolean;
  26115. /**
  26116. * Is Z inverted in the texture (useful in a cube texture).
  26117. */
  26118. invertZ: boolean;
  26119. /**
  26120. * Are mip maps generated for this texture or not.
  26121. */
  26122. readonly noMipmap: boolean;
  26123. /**
  26124. * @hidden
  26125. */
  26126. lodLevelInAlpha: boolean;
  26127. /**
  26128. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26129. */
  26130. lodGenerationOffset: number;
  26131. /**
  26132. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26133. */
  26134. lodGenerationScale: number;
  26135. /**
  26136. * Define if the texture is a render target.
  26137. */
  26138. isRenderTarget: boolean;
  26139. /**
  26140. * Define the unique id of the texture in the scene.
  26141. */
  26142. readonly uid: string;
  26143. /**
  26144. * Return a string representation of the texture.
  26145. * @returns the texture as a string
  26146. */
  26147. toString(): string;
  26148. /**
  26149. * Get the class name of the texture.
  26150. * @returns "BaseTexture"
  26151. */
  26152. getClassName(): string;
  26153. /**
  26154. * Define the list of animation attached to the texture.
  26155. */
  26156. animations: Animation[];
  26157. /**
  26158. * An event triggered when the texture is disposed.
  26159. */
  26160. onDisposeObservable: Observable<BaseTexture>;
  26161. private _onDisposeObserver;
  26162. /**
  26163. * Callback triggered when the texture has been disposed.
  26164. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26165. */
  26166. onDispose: () => void;
  26167. /**
  26168. * Define the current state of the loading sequence when in delayed load mode.
  26169. */
  26170. delayLoadState: number;
  26171. private _scene;
  26172. /** @hidden */
  26173. _texture: Nullable<InternalTexture>;
  26174. private _uid;
  26175. /**
  26176. * Define if the texture is preventinga material to render or not.
  26177. * If not and the texture is not ready, the engine will use a default black texture instead.
  26178. */
  26179. readonly isBlocking: boolean;
  26180. /**
  26181. * Instantiates a new BaseTexture.
  26182. * Base class of all the textures in babylon.
  26183. * It groups all the common properties the materials, post process, lights... might need
  26184. * in order to make a correct use of the texture.
  26185. * @param scene Define the scene the texture blongs to
  26186. */
  26187. constructor(scene: Nullable<Scene>);
  26188. /**
  26189. * Get the scene the texture belongs to.
  26190. * @returns the scene or null if undefined
  26191. */
  26192. getScene(): Nullable<Scene>;
  26193. /**
  26194. * Get the texture transform matrix used to offset tile the texture for istance.
  26195. * @returns the transformation matrix
  26196. */
  26197. getTextureMatrix(): Matrix;
  26198. /**
  26199. * Get the texture reflection matrix used to rotate/transform the reflection.
  26200. * @returns the reflection matrix
  26201. */
  26202. getReflectionTextureMatrix(): Matrix;
  26203. /**
  26204. * Get the underlying lower level texture from Babylon.
  26205. * @returns the insternal texture
  26206. */
  26207. getInternalTexture(): Nullable<InternalTexture>;
  26208. /**
  26209. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26210. * @returns true if ready or not blocking
  26211. */
  26212. isReadyOrNotBlocking(): boolean;
  26213. /**
  26214. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26215. * @returns true if fully ready
  26216. */
  26217. isReady(): boolean;
  26218. private _cachedSize;
  26219. /**
  26220. * Get the size of the texture.
  26221. * @returns the texture size.
  26222. */
  26223. getSize(): ISize;
  26224. /**
  26225. * Get the base size of the texture.
  26226. * It can be different from the size if the texture has been resized for POT for instance
  26227. * @returns the base size
  26228. */
  26229. getBaseSize(): ISize;
  26230. /**
  26231. * Update the sampling mode of the texture.
  26232. * Default is Trilinear mode.
  26233. *
  26234. * | Value | Type | Description |
  26235. * | ----- | ------------------ | ----------- |
  26236. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26237. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26238. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26239. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26240. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26241. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26242. * | 7 | NEAREST_LINEAR | |
  26243. * | 8 | NEAREST_NEAREST | |
  26244. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26245. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26246. * | 11 | LINEAR_LINEAR | |
  26247. * | 12 | LINEAR_NEAREST | |
  26248. *
  26249. * > _mag_: magnification filter (close to the viewer)
  26250. * > _min_: minification filter (far from the viewer)
  26251. * > _mip_: filter used between mip map levels
  26252. *@param samplingMode Define the new sampling mode of the texture
  26253. */
  26254. updateSamplingMode(samplingMode: number): void;
  26255. /**
  26256. * Scales the texture if is `canRescale()`
  26257. * @param ratio the resize factor we want to use to rescale
  26258. */
  26259. scale(ratio: number): void;
  26260. /**
  26261. * Get if the texture can rescale.
  26262. */
  26263. readonly canRescale: boolean;
  26264. /** @hidden */
  26265. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26266. /** @hidden */
  26267. _rebuild(): void;
  26268. /**
  26269. * Triggers the load sequence in delayed load mode.
  26270. */
  26271. delayLoad(): void;
  26272. /**
  26273. * Clones the texture.
  26274. * @returns the cloned texture
  26275. */
  26276. clone(): Nullable<BaseTexture>;
  26277. /**
  26278. * Get the texture underlying type (INT, FLOAT...)
  26279. */
  26280. readonly textureType: number;
  26281. /**
  26282. * Get the texture underlying format (RGB, RGBA...)
  26283. */
  26284. readonly textureFormat: number;
  26285. /**
  26286. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26287. * This will returns an RGBA array buffer containing either in values (0-255) or
  26288. * float values (0-1) depending of the underlying buffer type.
  26289. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26290. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26291. * @param buffer defines a user defined buffer to fill with data (can be null)
  26292. * @returns The Array buffer containing the pixels data.
  26293. */
  26294. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26295. /**
  26296. * Release and destroy the underlying lower level texture aka internalTexture.
  26297. */
  26298. releaseInternalTexture(): void;
  26299. /**
  26300. * Get the polynomial representation of the texture data.
  26301. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26302. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26303. */
  26304. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26305. /** @hidden */
  26306. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26307. /** @hidden */
  26308. readonly _lodTextureMid: Nullable<BaseTexture>;
  26309. /** @hidden */
  26310. readonly _lodTextureLow: Nullable<BaseTexture>;
  26311. /**
  26312. * Dispose the texture and release its associated resources.
  26313. */
  26314. dispose(): void;
  26315. /**
  26316. * Serialize the texture into a JSON representation that can be parsed later on.
  26317. * @returns the JSON representation of the texture
  26318. */
  26319. serialize(): any;
  26320. /**
  26321. * Helper function to be called back once a list of texture contains only ready textures.
  26322. * @param textures Define the list of textures to wait for
  26323. * @param callback Define the callback triggered once the entire list will be ready
  26324. */
  26325. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26326. }
  26327. }
  26328. declare module BABYLON {
  26329. /**
  26330. * Uniform buffer objects.
  26331. *
  26332. * Handles blocks of uniform on the GPU.
  26333. *
  26334. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26335. *
  26336. * For more information, please refer to :
  26337. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26338. */
  26339. export class UniformBuffer {
  26340. private _engine;
  26341. private _buffer;
  26342. private _data;
  26343. private _bufferData;
  26344. private _dynamic?;
  26345. private _uniformLocations;
  26346. private _uniformSizes;
  26347. private _uniformLocationPointer;
  26348. private _needSync;
  26349. private _noUBO;
  26350. private _currentEffect;
  26351. private static _MAX_UNIFORM_SIZE;
  26352. private static _tempBuffer;
  26353. /**
  26354. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26355. * This is dynamic to allow compat with webgl 1 and 2.
  26356. * You will need to pass the name of the uniform as well as the value.
  26357. */
  26358. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26359. /**
  26360. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26361. * This is dynamic to allow compat with webgl 1 and 2.
  26362. * You will need to pass the name of the uniform as well as the value.
  26363. */
  26364. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26365. /**
  26366. * Lambda to Update a single float in a uniform buffer.
  26367. * This is dynamic to allow compat with webgl 1 and 2.
  26368. * You will need to pass the name of the uniform as well as the value.
  26369. */
  26370. updateFloat: (name: string, x: number) => void;
  26371. /**
  26372. * Lambda to Update a vec2 of float in a uniform buffer.
  26373. * This is dynamic to allow compat with webgl 1 and 2.
  26374. * You will need to pass the name of the uniform as well as the value.
  26375. */
  26376. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26377. /**
  26378. * Lambda to Update a vec3 of float in a uniform buffer.
  26379. * This is dynamic to allow compat with webgl 1 and 2.
  26380. * You will need to pass the name of the uniform as well as the value.
  26381. */
  26382. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26383. /**
  26384. * Lambda to Update a vec4 of float in a uniform buffer.
  26385. * This is dynamic to allow compat with webgl 1 and 2.
  26386. * You will need to pass the name of the uniform as well as the value.
  26387. */
  26388. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26389. /**
  26390. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26391. * This is dynamic to allow compat with webgl 1 and 2.
  26392. * You will need to pass the name of the uniform as well as the value.
  26393. */
  26394. updateMatrix: (name: string, mat: Matrix) => void;
  26395. /**
  26396. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26397. * This is dynamic to allow compat with webgl 1 and 2.
  26398. * You will need to pass the name of the uniform as well as the value.
  26399. */
  26400. updateVector3: (name: string, vector: Vector3) => void;
  26401. /**
  26402. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26403. * This is dynamic to allow compat with webgl 1 and 2.
  26404. * You will need to pass the name of the uniform as well as the value.
  26405. */
  26406. updateVector4: (name: string, vector: Vector4) => void;
  26407. /**
  26408. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26409. * This is dynamic to allow compat with webgl 1 and 2.
  26410. * You will need to pass the name of the uniform as well as the value.
  26411. */
  26412. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26413. /**
  26414. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26415. * This is dynamic to allow compat with webgl 1 and 2.
  26416. * You will need to pass the name of the uniform as well as the value.
  26417. */
  26418. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26419. /**
  26420. * Instantiates a new Uniform buffer objects.
  26421. *
  26422. * Handles blocks of uniform on the GPU.
  26423. *
  26424. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26425. *
  26426. * For more information, please refer to :
  26427. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26428. * @param engine Define the engine the buffer is associated with
  26429. * @param data Define the data contained in the buffer
  26430. * @param dynamic Define if the buffer is updatable
  26431. */
  26432. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26433. /**
  26434. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26435. * or just falling back on setUniformXXX calls.
  26436. */
  26437. readonly useUbo: boolean;
  26438. /**
  26439. * Indicates if the WebGL underlying uniform buffer is in sync
  26440. * with the javascript cache data.
  26441. */
  26442. readonly isSync: boolean;
  26443. /**
  26444. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26445. * Also, a dynamic UniformBuffer will disable cache verification and always
  26446. * update the underlying WebGL uniform buffer to the GPU.
  26447. * @returns if Dynamic, otherwise false
  26448. */
  26449. isDynamic(): boolean;
  26450. /**
  26451. * The data cache on JS side.
  26452. * @returns the underlying data as a float array
  26453. */
  26454. getData(): Float32Array;
  26455. /**
  26456. * The underlying WebGL Uniform buffer.
  26457. * @returns the webgl buffer
  26458. */
  26459. getBuffer(): Nullable<DataBuffer>;
  26460. /**
  26461. * std140 layout specifies how to align data within an UBO structure.
  26462. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26463. * for specs.
  26464. */
  26465. private _fillAlignment;
  26466. /**
  26467. * Adds an uniform in the buffer.
  26468. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26469. * for the layout to be correct !
  26470. * @param name Name of the uniform, as used in the uniform block in the shader.
  26471. * @param size Data size, or data directly.
  26472. */
  26473. addUniform(name: string, size: number | number[]): void;
  26474. /**
  26475. * Adds a Matrix 4x4 to the uniform buffer.
  26476. * @param name Name of the uniform, as used in the uniform block in the shader.
  26477. * @param mat A 4x4 matrix.
  26478. */
  26479. addMatrix(name: string, mat: Matrix): void;
  26480. /**
  26481. * Adds a vec2 to the uniform buffer.
  26482. * @param name Name of the uniform, as used in the uniform block in the shader.
  26483. * @param x Define the x component value of the vec2
  26484. * @param y Define the y component value of the vec2
  26485. */
  26486. addFloat2(name: string, x: number, y: number): void;
  26487. /**
  26488. * Adds a vec3 to the uniform buffer.
  26489. * @param name Name of the uniform, as used in the uniform block in the shader.
  26490. * @param x Define the x component value of the vec3
  26491. * @param y Define the y component value of the vec3
  26492. * @param z Define the z component value of the vec3
  26493. */
  26494. addFloat3(name: string, x: number, y: number, z: number): void;
  26495. /**
  26496. * Adds a vec3 to the uniform buffer.
  26497. * @param name Name of the uniform, as used in the uniform block in the shader.
  26498. * @param color Define the vec3 from a Color
  26499. */
  26500. addColor3(name: string, color: Color3): void;
  26501. /**
  26502. * Adds a vec4 to the uniform buffer.
  26503. * @param name Name of the uniform, as used in the uniform block in the shader.
  26504. * @param color Define the rgb components from a Color
  26505. * @param alpha Define the a component of the vec4
  26506. */
  26507. addColor4(name: string, color: Color3, alpha: number): void;
  26508. /**
  26509. * Adds a vec3 to the uniform buffer.
  26510. * @param name Name of the uniform, as used in the uniform block in the shader.
  26511. * @param vector Define the vec3 components from a Vector
  26512. */
  26513. addVector3(name: string, vector: Vector3): void;
  26514. /**
  26515. * Adds a Matrix 3x3 to the uniform buffer.
  26516. * @param name Name of the uniform, as used in the uniform block in the shader.
  26517. */
  26518. addMatrix3x3(name: string): void;
  26519. /**
  26520. * Adds a Matrix 2x2 to the uniform buffer.
  26521. * @param name Name of the uniform, as used in the uniform block in the shader.
  26522. */
  26523. addMatrix2x2(name: string): void;
  26524. /**
  26525. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26526. */
  26527. create(): void;
  26528. /** @hidden */
  26529. _rebuild(): void;
  26530. /**
  26531. * Updates the WebGL Uniform Buffer on the GPU.
  26532. * If the `dynamic` flag is set to true, no cache comparison is done.
  26533. * Otherwise, the buffer will be updated only if the cache differs.
  26534. */
  26535. update(): void;
  26536. /**
  26537. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26538. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26539. * @param data Define the flattened data
  26540. * @param size Define the size of the data.
  26541. */
  26542. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26543. private _updateMatrix3x3ForUniform;
  26544. private _updateMatrix3x3ForEffect;
  26545. private _updateMatrix2x2ForEffect;
  26546. private _updateMatrix2x2ForUniform;
  26547. private _updateFloatForEffect;
  26548. private _updateFloatForUniform;
  26549. private _updateFloat2ForEffect;
  26550. private _updateFloat2ForUniform;
  26551. private _updateFloat3ForEffect;
  26552. private _updateFloat3ForUniform;
  26553. private _updateFloat4ForEffect;
  26554. private _updateFloat4ForUniform;
  26555. private _updateMatrixForEffect;
  26556. private _updateMatrixForUniform;
  26557. private _updateVector3ForEffect;
  26558. private _updateVector3ForUniform;
  26559. private _updateVector4ForEffect;
  26560. private _updateVector4ForUniform;
  26561. private _updateColor3ForEffect;
  26562. private _updateColor3ForUniform;
  26563. private _updateColor4ForEffect;
  26564. private _updateColor4ForUniform;
  26565. /**
  26566. * Sets a sampler uniform on the effect.
  26567. * @param name Define the name of the sampler.
  26568. * @param texture Define the texture to set in the sampler
  26569. */
  26570. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26571. /**
  26572. * Directly updates the value of the uniform in the cache AND on the GPU.
  26573. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26574. * @param data Define the flattened data
  26575. */
  26576. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26577. /**
  26578. * Binds this uniform buffer to an effect.
  26579. * @param effect Define the effect to bind the buffer to
  26580. * @param name Name of the uniform block in the shader.
  26581. */
  26582. bindToEffect(effect: Effect, name: string): void;
  26583. /**
  26584. * Disposes the uniform buffer.
  26585. */
  26586. dispose(): void;
  26587. }
  26588. }
  26589. declare module BABYLON {
  26590. /**
  26591. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26593. */
  26594. export class Analyser {
  26595. /**
  26596. * Gets or sets the smoothing
  26597. * @ignorenaming
  26598. */
  26599. SMOOTHING: number;
  26600. /**
  26601. * Gets or sets the FFT table size
  26602. * @ignorenaming
  26603. */
  26604. FFT_SIZE: number;
  26605. /**
  26606. * Gets or sets the bar graph amplitude
  26607. * @ignorenaming
  26608. */
  26609. BARGRAPHAMPLITUDE: number;
  26610. /**
  26611. * Gets or sets the position of the debug canvas
  26612. * @ignorenaming
  26613. */
  26614. DEBUGCANVASPOS: {
  26615. x: number;
  26616. y: number;
  26617. };
  26618. /**
  26619. * Gets or sets the debug canvas size
  26620. * @ignorenaming
  26621. */
  26622. DEBUGCANVASSIZE: {
  26623. width: number;
  26624. height: number;
  26625. };
  26626. private _byteFreqs;
  26627. private _byteTime;
  26628. private _floatFreqs;
  26629. private _webAudioAnalyser;
  26630. private _debugCanvas;
  26631. private _debugCanvasContext;
  26632. private _scene;
  26633. private _registerFunc;
  26634. private _audioEngine;
  26635. /**
  26636. * Creates a new analyser
  26637. * @param scene defines hosting scene
  26638. */
  26639. constructor(scene: Scene);
  26640. /**
  26641. * Get the number of data values you will have to play with for the visualization
  26642. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26643. * @returns a number
  26644. */
  26645. getFrequencyBinCount(): number;
  26646. /**
  26647. * Gets the current frequency data as a byte array
  26648. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26649. * @returns a Uint8Array
  26650. */
  26651. getByteFrequencyData(): Uint8Array;
  26652. /**
  26653. * Gets the current waveform as a byte array
  26654. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26655. * @returns a Uint8Array
  26656. */
  26657. getByteTimeDomainData(): Uint8Array;
  26658. /**
  26659. * Gets the current frequency data as a float array
  26660. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26661. * @returns a Float32Array
  26662. */
  26663. getFloatFrequencyData(): Float32Array;
  26664. /**
  26665. * Renders the debug canvas
  26666. */
  26667. drawDebugCanvas(): void;
  26668. /**
  26669. * Stops rendering the debug canvas and removes it
  26670. */
  26671. stopDebugCanvas(): void;
  26672. /**
  26673. * Connects two audio nodes
  26674. * @param inputAudioNode defines first node to connect
  26675. * @param outputAudioNode defines second node to connect
  26676. */
  26677. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26678. /**
  26679. * Releases all associated resources
  26680. */
  26681. dispose(): void;
  26682. }
  26683. }
  26684. declare module BABYLON {
  26685. /**
  26686. * This represents an audio engine and it is responsible
  26687. * to play, synchronize and analyse sounds throughout the application.
  26688. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26689. */
  26690. export interface IAudioEngine extends IDisposable {
  26691. /**
  26692. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26693. */
  26694. readonly canUseWebAudio: boolean;
  26695. /**
  26696. * Gets the current AudioContext if available.
  26697. */
  26698. readonly audioContext: Nullable<AudioContext>;
  26699. /**
  26700. * The master gain node defines the global audio volume of your audio engine.
  26701. */
  26702. readonly masterGain: GainNode;
  26703. /**
  26704. * Gets whether or not mp3 are supported by your browser.
  26705. */
  26706. readonly isMP3supported: boolean;
  26707. /**
  26708. * Gets whether or not ogg are supported by your browser.
  26709. */
  26710. readonly isOGGsupported: boolean;
  26711. /**
  26712. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26713. * @ignoreNaming
  26714. */
  26715. WarnedWebAudioUnsupported: boolean;
  26716. /**
  26717. * Defines if the audio engine relies on a custom unlocked button.
  26718. * In this case, the embedded button will not be displayed.
  26719. */
  26720. useCustomUnlockedButton: boolean;
  26721. /**
  26722. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26723. */
  26724. readonly unlocked: boolean;
  26725. /**
  26726. * Event raised when audio has been unlocked on the browser.
  26727. */
  26728. onAudioUnlockedObservable: Observable<AudioEngine>;
  26729. /**
  26730. * Event raised when audio has been locked on the browser.
  26731. */
  26732. onAudioLockedObservable: Observable<AudioEngine>;
  26733. /**
  26734. * Flags the audio engine in Locked state.
  26735. * This happens due to new browser policies preventing audio to autoplay.
  26736. */
  26737. lock(): void;
  26738. /**
  26739. * Unlocks the audio engine once a user action has been done on the dom.
  26740. * This is helpful to resume play once browser policies have been satisfied.
  26741. */
  26742. unlock(): void;
  26743. }
  26744. /**
  26745. * This represents the default audio engine used in babylon.
  26746. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26748. */
  26749. export class AudioEngine implements IAudioEngine {
  26750. private _audioContext;
  26751. private _audioContextInitialized;
  26752. private _muteButton;
  26753. private _hostElement;
  26754. /**
  26755. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26756. */
  26757. canUseWebAudio: boolean;
  26758. /**
  26759. * The master gain node defines the global audio volume of your audio engine.
  26760. */
  26761. masterGain: GainNode;
  26762. /**
  26763. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26764. * @ignoreNaming
  26765. */
  26766. WarnedWebAudioUnsupported: boolean;
  26767. /**
  26768. * Gets whether or not mp3 are supported by your browser.
  26769. */
  26770. isMP3supported: boolean;
  26771. /**
  26772. * Gets whether or not ogg are supported by your browser.
  26773. */
  26774. isOGGsupported: boolean;
  26775. /**
  26776. * Gets whether audio has been unlocked on the device.
  26777. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26778. * a user interaction has happened.
  26779. */
  26780. unlocked: boolean;
  26781. /**
  26782. * Defines if the audio engine relies on a custom unlocked button.
  26783. * In this case, the embedded button will not be displayed.
  26784. */
  26785. useCustomUnlockedButton: boolean;
  26786. /**
  26787. * Event raised when audio has been unlocked on the browser.
  26788. */
  26789. onAudioUnlockedObservable: Observable<AudioEngine>;
  26790. /**
  26791. * Event raised when audio has been locked on the browser.
  26792. */
  26793. onAudioLockedObservable: Observable<AudioEngine>;
  26794. /**
  26795. * Gets the current AudioContext if available.
  26796. */
  26797. readonly audioContext: Nullable<AudioContext>;
  26798. private _connectedAnalyser;
  26799. /**
  26800. * Instantiates a new audio engine.
  26801. *
  26802. * There should be only one per page as some browsers restrict the number
  26803. * of audio contexts you can create.
  26804. * @param hostElement defines the host element where to display the mute icon if necessary
  26805. */
  26806. constructor(hostElement?: Nullable<HTMLElement>);
  26807. /**
  26808. * Flags the audio engine in Locked state.
  26809. * This happens due to new browser policies preventing audio to autoplay.
  26810. */
  26811. lock(): void;
  26812. /**
  26813. * Unlocks the audio engine once a user action has been done on the dom.
  26814. * This is helpful to resume play once browser policies have been satisfied.
  26815. */
  26816. unlock(): void;
  26817. private _resumeAudioContext;
  26818. private _initializeAudioContext;
  26819. private _tryToRun;
  26820. private _triggerRunningState;
  26821. private _triggerSuspendedState;
  26822. private _displayMuteButton;
  26823. private _moveButtonToTopLeft;
  26824. private _onResize;
  26825. private _hideMuteButton;
  26826. /**
  26827. * Destroy and release the resources associated with the audio ccontext.
  26828. */
  26829. dispose(): void;
  26830. /**
  26831. * Gets the global volume sets on the master gain.
  26832. * @returns the global volume if set or -1 otherwise
  26833. */
  26834. getGlobalVolume(): number;
  26835. /**
  26836. * Sets the global volume of your experience (sets on the master gain).
  26837. * @param newVolume Defines the new global volume of the application
  26838. */
  26839. setGlobalVolume(newVolume: number): void;
  26840. /**
  26841. * Connect the audio engine to an audio analyser allowing some amazing
  26842. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26843. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26844. * @param analyser The analyser to connect to the engine
  26845. */
  26846. connectToAnalyser(analyser: Analyser): void;
  26847. }
  26848. }
  26849. declare module BABYLON {
  26850. /**
  26851. * Interface used to present a loading screen while loading a scene
  26852. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26853. */
  26854. export interface ILoadingScreen {
  26855. /**
  26856. * Function called to display the loading screen
  26857. */
  26858. displayLoadingUI: () => void;
  26859. /**
  26860. * Function called to hide the loading screen
  26861. */
  26862. hideLoadingUI: () => void;
  26863. /**
  26864. * Gets or sets the color to use for the background
  26865. */
  26866. loadingUIBackgroundColor: string;
  26867. /**
  26868. * Gets or sets the text to display while loading
  26869. */
  26870. loadingUIText: string;
  26871. }
  26872. /**
  26873. * Class used for the default loading screen
  26874. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26875. */
  26876. export class DefaultLoadingScreen implements ILoadingScreen {
  26877. private _renderingCanvas;
  26878. private _loadingText;
  26879. private _loadingDivBackgroundColor;
  26880. private _loadingDiv;
  26881. private _loadingTextDiv;
  26882. /** Gets or sets the logo url to use for the default loading screen */
  26883. static DefaultLogoUrl: string;
  26884. /** Gets or sets the spinner url to use for the default loading screen */
  26885. static DefaultSpinnerUrl: string;
  26886. /**
  26887. * Creates a new default loading screen
  26888. * @param _renderingCanvas defines the canvas used to render the scene
  26889. * @param _loadingText defines the default text to display
  26890. * @param _loadingDivBackgroundColor defines the default background color
  26891. */
  26892. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26893. /**
  26894. * Function called to display the loading screen
  26895. */
  26896. displayLoadingUI(): void;
  26897. /**
  26898. * Function called to hide the loading screen
  26899. */
  26900. hideLoadingUI(): void;
  26901. /**
  26902. * Gets or sets the text to display while loading
  26903. */
  26904. loadingUIText: string;
  26905. /**
  26906. * Gets or sets the color to use for the background
  26907. */
  26908. loadingUIBackgroundColor: string;
  26909. private _resizeLoadingUI;
  26910. }
  26911. }
  26912. declare module BABYLON {
  26913. /** @hidden */
  26914. export class WebGLPipelineContext implements IPipelineContext {
  26915. engine: Engine;
  26916. program: Nullable<WebGLProgram>;
  26917. context?: WebGLRenderingContext;
  26918. vertexShader?: WebGLShader;
  26919. fragmentShader?: WebGLShader;
  26920. isParallelCompiled: boolean;
  26921. onCompiled?: () => void;
  26922. transformFeedback?: WebGLTransformFeedback | null;
  26923. readonly isAsync: boolean;
  26924. readonly isReady: boolean;
  26925. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  26926. }
  26927. }
  26928. declare module BABYLON {
  26929. /** @hidden */
  26930. export class WebGLDataBuffer extends DataBuffer {
  26931. private _buffer;
  26932. constructor(resource: WebGLBuffer);
  26933. readonly underlyingResource: any;
  26934. }
  26935. }
  26936. declare module BABYLON {
  26937. /**
  26938. * Settings for finer control over video usage
  26939. */
  26940. export interface VideoTextureSettings {
  26941. /**
  26942. * Applies `autoplay` to video, if specified
  26943. */
  26944. autoPlay?: boolean;
  26945. /**
  26946. * Applies `loop` to video, if specified
  26947. */
  26948. loop?: boolean;
  26949. /**
  26950. * Automatically updates internal texture from video at every frame in the render loop
  26951. */
  26952. autoUpdateTexture: boolean;
  26953. /**
  26954. * Image src displayed during the video loading or until the user interacts with the video.
  26955. */
  26956. poster?: string;
  26957. }
  26958. /**
  26959. * If you want to display a video in your scene, this is the special texture for that.
  26960. * This special texture works similar to other textures, with the exception of a few parameters.
  26961. * @see https://doc.babylonjs.com/how_to/video_texture
  26962. */
  26963. export class VideoTexture extends Texture {
  26964. /**
  26965. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26966. */
  26967. readonly autoUpdateTexture: boolean;
  26968. /**
  26969. * The video instance used by the texture internally
  26970. */
  26971. readonly video: HTMLVideoElement;
  26972. private _onUserActionRequestedObservable;
  26973. /**
  26974. * Event triggerd when a dom action is required by the user to play the video.
  26975. * This happens due to recent changes in browser policies preventing video to auto start.
  26976. */
  26977. readonly onUserActionRequestedObservable: Observable<Texture>;
  26978. private _generateMipMaps;
  26979. private _engine;
  26980. private _stillImageCaptured;
  26981. private _displayingPosterTexture;
  26982. private _settings;
  26983. private _createInternalTextureOnEvent;
  26984. /**
  26985. * Creates a video texture.
  26986. * If you want to display a video in your scene, this is the special texture for that.
  26987. * This special texture works similar to other textures, with the exception of a few parameters.
  26988. * @see https://doc.babylonjs.com/how_to/video_texture
  26989. * @param name optional name, will detect from video source, if not defined
  26990. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26991. * @param scene is obviously the current scene.
  26992. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26993. * @param invertY is false by default but can be used to invert video on Y axis
  26994. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26995. * @param settings allows finer control over video usage
  26996. */
  26997. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26998. private _getName;
  26999. private _getVideo;
  27000. private _createInternalTexture;
  27001. private reset;
  27002. /**
  27003. * @hidden Internal method to initiate `update`.
  27004. */
  27005. _rebuild(): void;
  27006. /**
  27007. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27008. */
  27009. update(): void;
  27010. /**
  27011. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27012. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27013. */
  27014. updateTexture(isVisible: boolean): void;
  27015. protected _updateInternalTexture: () => void;
  27016. /**
  27017. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27018. * @param url New url.
  27019. */
  27020. updateURL(url: string): void;
  27021. /**
  27022. * Dispose the texture and release its associated resources.
  27023. */
  27024. dispose(): void;
  27025. /**
  27026. * Creates a video texture straight from a stream.
  27027. * @param scene Define the scene the texture should be created in
  27028. * @param stream Define the stream the texture should be created from
  27029. * @returns The created video texture as a promise
  27030. */
  27031. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27032. /**
  27033. * Creates a video texture straight from your WebCam video feed.
  27034. * @param scene Define the scene the texture should be created in
  27035. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27036. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27037. * @returns The created video texture as a promise
  27038. */
  27039. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27040. minWidth: number;
  27041. maxWidth: number;
  27042. minHeight: number;
  27043. maxHeight: number;
  27044. deviceId: string;
  27045. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27046. /**
  27047. * Creates a video texture straight from your WebCam video feed.
  27048. * @param scene Define the scene the texture should be created in
  27049. * @param onReady Define a callback to triggered once the texture will be ready
  27050. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27051. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27052. */
  27053. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27054. minWidth: number;
  27055. maxWidth: number;
  27056. minHeight: number;
  27057. maxHeight: number;
  27058. deviceId: string;
  27059. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27060. }
  27061. }
  27062. declare module BABYLON {
  27063. /**
  27064. * Interface for attribute information associated with buffer instanciation
  27065. */
  27066. export class InstancingAttributeInfo {
  27067. /**
  27068. * Index/offset of the attribute in the vertex shader
  27069. */
  27070. index: number;
  27071. /**
  27072. * size of the attribute, 1, 2, 3 or 4
  27073. */
  27074. attributeSize: number;
  27075. /**
  27076. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27077. * default is FLOAT
  27078. */
  27079. attribyteType: number;
  27080. /**
  27081. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27082. */
  27083. normalized: boolean;
  27084. /**
  27085. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27086. */
  27087. offset: number;
  27088. /**
  27089. * Name of the GLSL attribute, for debugging purpose only
  27090. */
  27091. attributeName: string;
  27092. }
  27093. /**
  27094. * Define options used to create a depth texture
  27095. */
  27096. export class DepthTextureCreationOptions {
  27097. /** Specifies whether or not a stencil should be allocated in the texture */
  27098. generateStencil?: boolean;
  27099. /** Specifies whether or not bilinear filtering is enable on the texture */
  27100. bilinearFiltering?: boolean;
  27101. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27102. comparisonFunction?: number;
  27103. /** Specifies if the created texture is a cube texture */
  27104. isCube?: boolean;
  27105. }
  27106. /**
  27107. * Class used to describe the capabilities of the engine relatively to the current browser
  27108. */
  27109. export class EngineCapabilities {
  27110. /** Maximum textures units per fragment shader */
  27111. maxTexturesImageUnits: number;
  27112. /** Maximum texture units per vertex shader */
  27113. maxVertexTextureImageUnits: number;
  27114. /** Maximum textures units in the entire pipeline */
  27115. maxCombinedTexturesImageUnits: number;
  27116. /** Maximum texture size */
  27117. maxTextureSize: number;
  27118. /** Maximum cube texture size */
  27119. maxCubemapTextureSize: number;
  27120. /** Maximum render texture size */
  27121. maxRenderTextureSize: number;
  27122. /** Maximum number of vertex attributes */
  27123. maxVertexAttribs: number;
  27124. /** Maximum number of varyings */
  27125. maxVaryingVectors: number;
  27126. /** Maximum number of uniforms per vertex shader */
  27127. maxVertexUniformVectors: number;
  27128. /** Maximum number of uniforms per fragment shader */
  27129. maxFragmentUniformVectors: number;
  27130. /** Defines if standard derivates (dx/dy) are supported */
  27131. standardDerivatives: boolean;
  27132. /** Defines if s3tc texture compression is supported */
  27133. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27134. /** Defines if pvrtc texture compression is supported */
  27135. pvrtc: any;
  27136. /** Defines if etc1 texture compression is supported */
  27137. etc1: any;
  27138. /** Defines if etc2 texture compression is supported */
  27139. etc2: any;
  27140. /** Defines if astc texture compression is supported */
  27141. astc: any;
  27142. /** Defines if float textures are supported */
  27143. textureFloat: boolean;
  27144. /** Defines if vertex array objects are supported */
  27145. vertexArrayObject: boolean;
  27146. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27147. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27148. /** Gets the maximum level of anisotropy supported */
  27149. maxAnisotropy: number;
  27150. /** Defines if instancing is supported */
  27151. instancedArrays: boolean;
  27152. /** Defines if 32 bits indices are supported */
  27153. uintIndices: boolean;
  27154. /** Defines if high precision shaders are supported */
  27155. highPrecisionShaderSupported: boolean;
  27156. /** Defines if depth reading in the fragment shader is supported */
  27157. fragmentDepthSupported: boolean;
  27158. /** Defines if float texture linear filtering is supported*/
  27159. textureFloatLinearFiltering: boolean;
  27160. /** Defines if rendering to float textures is supported */
  27161. textureFloatRender: boolean;
  27162. /** Defines if half float textures are supported*/
  27163. textureHalfFloat: boolean;
  27164. /** Defines if half float texture linear filtering is supported*/
  27165. textureHalfFloatLinearFiltering: boolean;
  27166. /** Defines if rendering to half float textures is supported */
  27167. textureHalfFloatRender: boolean;
  27168. /** Defines if textureLOD shader command is supported */
  27169. textureLOD: boolean;
  27170. /** Defines if draw buffers extension is supported */
  27171. drawBuffersExtension: boolean;
  27172. /** Defines if depth textures are supported */
  27173. depthTextureExtension: boolean;
  27174. /** Defines if float color buffer are supported */
  27175. colorBufferFloat: boolean;
  27176. /** Gets disjoint timer query extension (null if not supported) */
  27177. timerQuery: EXT_disjoint_timer_query;
  27178. /** Defines if timestamp can be used with timer query */
  27179. canUseTimestampForTimerQuery: boolean;
  27180. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27181. multiview: any;
  27182. /** Function used to let the system compiles shaders in background */
  27183. parallelShaderCompile: {
  27184. COMPLETION_STATUS_KHR: number;
  27185. };
  27186. }
  27187. /** Interface defining initialization parameters for Engine class */
  27188. export interface EngineOptions extends WebGLContextAttributes {
  27189. /**
  27190. * Defines if the engine should no exceed a specified device ratio
  27191. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27192. */
  27193. limitDeviceRatio?: number;
  27194. /**
  27195. * Defines if webvr should be enabled automatically
  27196. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27197. */
  27198. autoEnableWebVR?: boolean;
  27199. /**
  27200. * Defines if webgl2 should be turned off even if supported
  27201. * @see http://doc.babylonjs.com/features/webgl2
  27202. */
  27203. disableWebGL2Support?: boolean;
  27204. /**
  27205. * Defines if webaudio should be initialized as well
  27206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27207. */
  27208. audioEngine?: boolean;
  27209. /**
  27210. * Defines if animations should run using a deterministic lock step
  27211. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27212. */
  27213. deterministicLockstep?: boolean;
  27214. /** Defines the maximum steps to use with deterministic lock step mode */
  27215. lockstepMaxSteps?: number;
  27216. /**
  27217. * Defines that engine should ignore context lost events
  27218. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27219. */
  27220. doNotHandleContextLost?: boolean;
  27221. /**
  27222. * Defines that engine should ignore modifying touch action attribute and style
  27223. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27224. */
  27225. doNotHandleTouchAction?: boolean;
  27226. /**
  27227. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27228. */
  27229. useHighPrecisionFloats?: boolean;
  27230. }
  27231. /**
  27232. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27233. */
  27234. export class Engine {
  27235. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27236. static ExceptionList: ({
  27237. key: string;
  27238. capture: string;
  27239. captureConstraint: number;
  27240. targets: string[];
  27241. } | {
  27242. key: string;
  27243. capture: null;
  27244. captureConstraint: null;
  27245. targets: string[];
  27246. })[];
  27247. /** Gets the list of created engines */
  27248. static readonly Instances: Engine[];
  27249. /**
  27250. * Gets the latest created engine
  27251. */
  27252. static readonly LastCreatedEngine: Nullable<Engine>;
  27253. /**
  27254. * Gets the latest created scene
  27255. */
  27256. static readonly LastCreatedScene: Nullable<Scene>;
  27257. /**
  27258. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27259. * @param flag defines which part of the materials must be marked as dirty
  27260. * @param predicate defines a predicate used to filter which materials should be affected
  27261. */
  27262. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27263. /**
  27264. * Hidden
  27265. */
  27266. static _TextureLoaders: IInternalTextureLoader[];
  27267. /** Defines that alpha blending is disabled */
  27268. static readonly ALPHA_DISABLE: number;
  27269. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27270. static readonly ALPHA_ADD: number;
  27271. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27272. static readonly ALPHA_COMBINE: number;
  27273. /** Defines that alpha blending to DEST - SRC * DEST */
  27274. static readonly ALPHA_SUBTRACT: number;
  27275. /** Defines that alpha blending to SRC * DEST */
  27276. static readonly ALPHA_MULTIPLY: number;
  27277. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27278. static readonly ALPHA_MAXIMIZED: number;
  27279. /** Defines that alpha blending to SRC + DEST */
  27280. static readonly ALPHA_ONEONE: number;
  27281. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27282. static readonly ALPHA_PREMULTIPLIED: number;
  27283. /**
  27284. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27285. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27286. */
  27287. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27288. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27289. static readonly ALPHA_INTERPOLATE: number;
  27290. /**
  27291. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27292. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27293. */
  27294. static readonly ALPHA_SCREENMODE: number;
  27295. /** Defines that the ressource is not delayed*/
  27296. static readonly DELAYLOADSTATE_NONE: number;
  27297. /** Defines that the ressource was successfully delay loaded */
  27298. static readonly DELAYLOADSTATE_LOADED: number;
  27299. /** Defines that the ressource is currently delay loading */
  27300. static readonly DELAYLOADSTATE_LOADING: number;
  27301. /** Defines that the ressource is delayed and has not started loading */
  27302. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27303. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27304. static readonly NEVER: number;
  27305. /** 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 */
  27306. static readonly ALWAYS: number;
  27307. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27308. static readonly LESS: number;
  27309. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27310. static readonly EQUAL: number;
  27311. /** 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 */
  27312. static readonly LEQUAL: number;
  27313. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27314. static readonly GREATER: number;
  27315. /** 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 */
  27316. static readonly GEQUAL: number;
  27317. /** 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 */
  27318. static readonly NOTEQUAL: number;
  27319. /** Passed to stencilOperation to specify that stencil value must be kept */
  27320. static readonly KEEP: number;
  27321. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27322. static readonly REPLACE: number;
  27323. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27324. static readonly INCR: number;
  27325. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27326. static readonly DECR: number;
  27327. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27328. static readonly INVERT: number;
  27329. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27330. static readonly INCR_WRAP: number;
  27331. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27332. static readonly DECR_WRAP: number;
  27333. /** Texture is not repeating outside of 0..1 UVs */
  27334. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27335. /** Texture is repeating outside of 0..1 UVs */
  27336. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27337. /** Texture is repeating and mirrored */
  27338. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27339. /** ALPHA */
  27340. static readonly TEXTUREFORMAT_ALPHA: number;
  27341. /** LUMINANCE */
  27342. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27343. /** LUMINANCE_ALPHA */
  27344. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27345. /** RGB */
  27346. static readonly TEXTUREFORMAT_RGB: number;
  27347. /** RGBA */
  27348. static readonly TEXTUREFORMAT_RGBA: number;
  27349. /** RED */
  27350. static readonly TEXTUREFORMAT_RED: number;
  27351. /** RED (2nd reference) */
  27352. static readonly TEXTUREFORMAT_R: number;
  27353. /** RG */
  27354. static readonly TEXTUREFORMAT_RG: number;
  27355. /** RED_INTEGER */
  27356. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27357. /** RED_INTEGER (2nd reference) */
  27358. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27359. /** RG_INTEGER */
  27360. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27361. /** RGB_INTEGER */
  27362. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27363. /** RGBA_INTEGER */
  27364. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27365. /** UNSIGNED_BYTE */
  27366. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27367. /** UNSIGNED_BYTE (2nd reference) */
  27368. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27369. /** FLOAT */
  27370. static readonly TEXTURETYPE_FLOAT: number;
  27371. /** HALF_FLOAT */
  27372. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27373. /** BYTE */
  27374. static readonly TEXTURETYPE_BYTE: number;
  27375. /** SHORT */
  27376. static readonly TEXTURETYPE_SHORT: number;
  27377. /** UNSIGNED_SHORT */
  27378. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27379. /** INT */
  27380. static readonly TEXTURETYPE_INT: number;
  27381. /** UNSIGNED_INT */
  27382. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27383. /** UNSIGNED_SHORT_4_4_4_4 */
  27384. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27385. /** UNSIGNED_SHORT_5_5_5_1 */
  27386. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27387. /** UNSIGNED_SHORT_5_6_5 */
  27388. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27389. /** UNSIGNED_INT_2_10_10_10_REV */
  27390. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27391. /** UNSIGNED_INT_24_8 */
  27392. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27393. /** UNSIGNED_INT_10F_11F_11F_REV */
  27394. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27395. /** UNSIGNED_INT_5_9_9_9_REV */
  27396. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27397. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27398. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27399. /** nearest is mag = nearest and min = nearest and mip = linear */
  27400. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27401. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27402. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27403. /** Trilinear is mag = linear and min = linear and mip = linear */
  27404. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27405. /** nearest is mag = nearest and min = nearest and mip = linear */
  27406. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27407. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27408. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27409. /** Trilinear is mag = linear and min = linear and mip = linear */
  27410. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27411. /** mag = nearest and min = nearest and mip = nearest */
  27412. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27413. /** mag = nearest and min = linear and mip = nearest */
  27414. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27415. /** mag = nearest and min = linear and mip = linear */
  27416. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27417. /** mag = nearest and min = linear and mip = none */
  27418. static readonly TEXTURE_NEAREST_LINEAR: number;
  27419. /** mag = nearest and min = nearest and mip = none */
  27420. static readonly TEXTURE_NEAREST_NEAREST: number;
  27421. /** mag = linear and min = nearest and mip = nearest */
  27422. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27423. /** mag = linear and min = nearest and mip = linear */
  27424. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27425. /** mag = linear and min = linear and mip = none */
  27426. static readonly TEXTURE_LINEAR_LINEAR: number;
  27427. /** mag = linear and min = nearest and mip = none */
  27428. static readonly TEXTURE_LINEAR_NEAREST: number;
  27429. /** Explicit coordinates mode */
  27430. static readonly TEXTURE_EXPLICIT_MODE: number;
  27431. /** Spherical coordinates mode */
  27432. static readonly TEXTURE_SPHERICAL_MODE: number;
  27433. /** Planar coordinates mode */
  27434. static readonly TEXTURE_PLANAR_MODE: number;
  27435. /** Cubic coordinates mode */
  27436. static readonly TEXTURE_CUBIC_MODE: number;
  27437. /** Projection coordinates mode */
  27438. static readonly TEXTURE_PROJECTION_MODE: number;
  27439. /** Skybox coordinates mode */
  27440. static readonly TEXTURE_SKYBOX_MODE: number;
  27441. /** Inverse Cubic coordinates mode */
  27442. static readonly TEXTURE_INVCUBIC_MODE: number;
  27443. /** Equirectangular coordinates mode */
  27444. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27445. /** Equirectangular Fixed coordinates mode */
  27446. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27447. /** Equirectangular Fixed Mirrored coordinates mode */
  27448. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27449. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27450. static readonly SCALEMODE_FLOOR: number;
  27451. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27452. static readonly SCALEMODE_NEAREST: number;
  27453. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27454. static readonly SCALEMODE_CEILING: number;
  27455. /**
  27456. * Returns the current npm package of the sdk
  27457. */
  27458. static readonly NpmPackage: string;
  27459. /**
  27460. * Returns the current version of the framework
  27461. */
  27462. static readonly Version: string;
  27463. /**
  27464. * Returns a string describing the current engine
  27465. */
  27466. readonly description: string;
  27467. /**
  27468. * Gets or sets the epsilon value used by collision engine
  27469. */
  27470. static CollisionsEpsilon: number;
  27471. /**
  27472. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27473. */
  27474. static ShadersRepository: string;
  27475. /**
  27476. * Method called to create the default loading screen.
  27477. * This can be overriden in your own app.
  27478. * @param canvas The rendering canvas element
  27479. * @returns The loading screen
  27480. */
  27481. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27482. /**
  27483. * Method called to create the default rescale post process on each engine.
  27484. */
  27485. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27486. /**
  27487. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27488. */
  27489. forcePOTTextures: boolean;
  27490. /**
  27491. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27492. */
  27493. isFullscreen: boolean;
  27494. /**
  27495. * Gets a boolean indicating if the pointer is currently locked
  27496. */
  27497. isPointerLock: boolean;
  27498. /**
  27499. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27500. */
  27501. cullBackFaces: boolean;
  27502. /**
  27503. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27504. */
  27505. renderEvenInBackground: boolean;
  27506. /**
  27507. * Gets or sets a boolean indicating that cache can be kept between frames
  27508. */
  27509. preventCacheWipeBetweenFrames: boolean;
  27510. /**
  27511. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27512. **/
  27513. enableOfflineSupport: boolean;
  27514. /**
  27515. * 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)
  27516. **/
  27517. disableManifestCheck: boolean;
  27518. /**
  27519. * Gets the list of created scenes
  27520. */
  27521. scenes: Scene[];
  27522. /**
  27523. * Event raised when a new scene is created
  27524. */
  27525. onNewSceneAddedObservable: Observable<Scene>;
  27526. /**
  27527. * Gets the list of created postprocesses
  27528. */
  27529. postProcesses: PostProcess[];
  27530. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27531. validateShaderPrograms: boolean;
  27532. /**
  27533. * Observable event triggered each time the rendering canvas is resized
  27534. */
  27535. onResizeObservable: Observable<Engine>;
  27536. /**
  27537. * Observable event triggered each time the canvas loses focus
  27538. */
  27539. onCanvasBlurObservable: Observable<Engine>;
  27540. /**
  27541. * Observable event triggered each time the canvas gains focus
  27542. */
  27543. onCanvasFocusObservable: Observable<Engine>;
  27544. /**
  27545. * Observable event triggered each time the canvas receives pointerout event
  27546. */
  27547. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27548. /**
  27549. * Observable event triggered before each texture is initialized
  27550. */
  27551. onBeforeTextureInitObservable: Observable<Texture>;
  27552. /**
  27553. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27554. */
  27555. disableUniformBuffers: boolean;
  27556. /** @hidden */
  27557. _uniformBuffers: UniformBuffer[];
  27558. /**
  27559. * Gets a boolean indicating that the engine supports uniform buffers
  27560. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27561. */
  27562. readonly supportsUniformBuffers: boolean;
  27563. /**
  27564. * Observable raised when the engine begins a new frame
  27565. */
  27566. onBeginFrameObservable: Observable<Engine>;
  27567. /**
  27568. * If set, will be used to request the next animation frame for the render loop
  27569. */
  27570. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27571. /**
  27572. * Observable raised when the engine ends the current frame
  27573. */
  27574. onEndFrameObservable: Observable<Engine>;
  27575. /**
  27576. * Observable raised when the engine is about to compile a shader
  27577. */
  27578. onBeforeShaderCompilationObservable: Observable<Engine>;
  27579. /**
  27580. * Observable raised when the engine has jsut compiled a shader
  27581. */
  27582. onAfterShaderCompilationObservable: Observable<Engine>;
  27583. /** @hidden */
  27584. _gl: WebGLRenderingContext;
  27585. private _renderingCanvas;
  27586. private _windowIsBackground;
  27587. private _webGLVersion;
  27588. protected _highPrecisionShadersAllowed: boolean;
  27589. /** @hidden */
  27590. readonly _shouldUseHighPrecisionShader: boolean;
  27591. /**
  27592. * Gets a boolean indicating that only power of 2 textures are supported
  27593. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27594. */
  27595. readonly needPOTTextures: boolean;
  27596. /** @hidden */
  27597. _badOS: boolean;
  27598. /** @hidden */
  27599. _badDesktopOS: boolean;
  27600. /**
  27601. * Gets the audio engine
  27602. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27603. * @ignorenaming
  27604. */
  27605. static audioEngine: IAudioEngine;
  27606. /**
  27607. * Default AudioEngine factory responsible of creating the Audio Engine.
  27608. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27609. */
  27610. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27611. /**
  27612. * Default offline support factory responsible of creating a tool used to store data locally.
  27613. * By default, this will create a Database object if the workload has been embedded.
  27614. */
  27615. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27616. private _onFocus;
  27617. private _onBlur;
  27618. private _onCanvasPointerOut;
  27619. private _onCanvasBlur;
  27620. private _onCanvasFocus;
  27621. private _onFullscreenChange;
  27622. private _onPointerLockChange;
  27623. private _hardwareScalingLevel;
  27624. /** @hidden */
  27625. _caps: EngineCapabilities;
  27626. private _pointerLockRequested;
  27627. private _isStencilEnable;
  27628. private _colorWrite;
  27629. private _loadingScreen;
  27630. /** @hidden */
  27631. _drawCalls: PerfCounter;
  27632. private _glVersion;
  27633. private _glRenderer;
  27634. private _glVendor;
  27635. private _videoTextureSupported;
  27636. private _renderingQueueLaunched;
  27637. private _activeRenderLoops;
  27638. private _deterministicLockstep;
  27639. private _lockstepMaxSteps;
  27640. /**
  27641. * Observable signaled when a context lost event is raised
  27642. */
  27643. onContextLostObservable: Observable<Engine>;
  27644. /**
  27645. * Observable signaled when a context restored event is raised
  27646. */
  27647. onContextRestoredObservable: Observable<Engine>;
  27648. private _onContextLost;
  27649. private _onContextRestored;
  27650. private _contextWasLost;
  27651. /** @hidden */
  27652. _doNotHandleContextLost: boolean;
  27653. /**
  27654. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27655. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27656. */
  27657. doNotHandleContextLost: boolean;
  27658. private _performanceMonitor;
  27659. private _fps;
  27660. private _deltaTime;
  27661. /**
  27662. * Turn this value on if you want to pause FPS computation when in background
  27663. */
  27664. disablePerformanceMonitorInBackground: boolean;
  27665. /**
  27666. * Gets the performance monitor attached to this engine
  27667. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27668. */
  27669. readonly performanceMonitor: PerformanceMonitor;
  27670. /**
  27671. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27672. */
  27673. disableVertexArrayObjects: boolean;
  27674. /** @hidden */
  27675. protected _depthCullingState: _DepthCullingState;
  27676. /** @hidden */
  27677. protected _stencilState: _StencilState;
  27678. /** @hidden */
  27679. protected _alphaState: _AlphaState;
  27680. /** @hidden */
  27681. protected _alphaMode: number;
  27682. /** @hidden */
  27683. _internalTexturesCache: InternalTexture[];
  27684. /** @hidden */
  27685. protected _activeChannel: number;
  27686. private _currentTextureChannel;
  27687. /** @hidden */
  27688. protected _boundTexturesCache: {
  27689. [key: string]: Nullable<InternalTexture>;
  27690. };
  27691. /** @hidden */
  27692. protected _currentEffect: Nullable<Effect>;
  27693. /** @hidden */
  27694. protected _currentProgram: Nullable<WebGLProgram>;
  27695. private _compiledEffects;
  27696. private _vertexAttribArraysEnabled;
  27697. /** @hidden */
  27698. protected _cachedViewport: Nullable<Viewport>;
  27699. private _cachedVertexArrayObject;
  27700. /** @hidden */
  27701. protected _cachedVertexBuffers: any;
  27702. /** @hidden */
  27703. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27704. /** @hidden */
  27705. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27706. /** @hidden */
  27707. _currentRenderTarget: Nullable<InternalTexture>;
  27708. private _uintIndicesCurrentlySet;
  27709. private _currentBoundBuffer;
  27710. /** @hidden */
  27711. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27712. private _currentBufferPointers;
  27713. private _currentInstanceLocations;
  27714. private _currentInstanceBuffers;
  27715. private _textureUnits;
  27716. /** @hidden */
  27717. _workingCanvas: Nullable<HTMLCanvasElement>;
  27718. /** @hidden */
  27719. _workingContext: Nullable<CanvasRenderingContext2D>;
  27720. private _rescalePostProcess;
  27721. private _dummyFramebuffer;
  27722. private _externalData;
  27723. /** @hidden */
  27724. _bindedRenderFunction: any;
  27725. private _vaoRecordInProgress;
  27726. private _mustWipeVertexAttributes;
  27727. private _emptyTexture;
  27728. private _emptyCubeTexture;
  27729. private _emptyTexture3D;
  27730. /** @hidden */
  27731. _frameHandler: number;
  27732. private _nextFreeTextureSlots;
  27733. private _maxSimultaneousTextures;
  27734. private _activeRequests;
  27735. private _texturesSupported;
  27736. /** @hidden */
  27737. _textureFormatInUse: Nullable<string>;
  27738. /**
  27739. * Gets the list of texture formats supported
  27740. */
  27741. readonly texturesSupported: Array<string>;
  27742. /**
  27743. * Gets the list of texture formats in use
  27744. */
  27745. readonly textureFormatInUse: Nullable<string>;
  27746. /**
  27747. * Gets the current viewport
  27748. */
  27749. readonly currentViewport: Nullable<Viewport>;
  27750. /**
  27751. * Gets the default empty texture
  27752. */
  27753. readonly emptyTexture: InternalTexture;
  27754. /**
  27755. * Gets the default empty 3D texture
  27756. */
  27757. readonly emptyTexture3D: InternalTexture;
  27758. /**
  27759. * Gets the default empty cube texture
  27760. */
  27761. readonly emptyCubeTexture: InternalTexture;
  27762. /**
  27763. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27764. */
  27765. readonly premultipliedAlpha: boolean;
  27766. /**
  27767. * Creates a new engine
  27768. * @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
  27769. * @param antialias defines enable antialiasing (default: false)
  27770. * @param options defines further options to be sent to the getContext() function
  27771. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27772. */
  27773. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27774. /**
  27775. * Initializes a webVR display and starts listening to display change events
  27776. * The onVRDisplayChangedObservable will be notified upon these changes
  27777. * @returns The onVRDisplayChangedObservable
  27778. */
  27779. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27780. /** @hidden */
  27781. _prepareVRComponent(): void;
  27782. /** @hidden */
  27783. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27784. /** @hidden */
  27785. _submitVRFrame(): void;
  27786. /**
  27787. * Call this function to leave webVR mode
  27788. * Will do nothing if webVR is not supported or if there is no webVR device
  27789. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27790. */
  27791. disableVR(): void;
  27792. /**
  27793. * Gets a boolean indicating that the system is in VR mode and is presenting
  27794. * @returns true if VR mode is engaged
  27795. */
  27796. isVRPresenting(): boolean;
  27797. /** @hidden */
  27798. _requestVRFrame(): void;
  27799. private _disableTouchAction;
  27800. private _rebuildInternalTextures;
  27801. private _rebuildEffects;
  27802. /**
  27803. * Gets a boolean indicating if all created effects are ready
  27804. * @returns true if all effects are ready
  27805. */
  27806. areAllEffectsReady(): boolean;
  27807. private _rebuildBuffers;
  27808. private _initGLContext;
  27809. /**
  27810. * Gets version of the current webGL context
  27811. */
  27812. readonly webGLVersion: number;
  27813. /**
  27814. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27815. */
  27816. readonly isStencilEnable: boolean;
  27817. /** @hidden */
  27818. _prepareWorkingCanvas(): void;
  27819. /**
  27820. * Reset the texture cache to empty state
  27821. */
  27822. resetTextureCache(): void;
  27823. /**
  27824. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27825. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27826. * @returns true if engine is in deterministic lock step mode
  27827. */
  27828. isDeterministicLockStep(): boolean;
  27829. /**
  27830. * Gets the max steps when engine is running in deterministic lock step
  27831. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27832. * @returns the max steps
  27833. */
  27834. getLockstepMaxSteps(): number;
  27835. /**
  27836. * Gets an object containing information about the current webGL context
  27837. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27838. */
  27839. getGlInfo(): {
  27840. vendor: string;
  27841. renderer: string;
  27842. version: string;
  27843. };
  27844. /**
  27845. * Gets current aspect ratio
  27846. * @param camera defines the camera to use to get the aspect ratio
  27847. * @param useScreen defines if screen size must be used (or the current render target if any)
  27848. * @returns a number defining the aspect ratio
  27849. */
  27850. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27851. /**
  27852. * Gets current screen aspect ratio
  27853. * @returns a number defining the aspect ratio
  27854. */
  27855. getScreenAspectRatio(): number;
  27856. /**
  27857. * Gets the current render width
  27858. * @param useScreen defines if screen size must be used (or the current render target if any)
  27859. * @returns a number defining the current render width
  27860. */
  27861. getRenderWidth(useScreen?: boolean): number;
  27862. /**
  27863. * Gets the current render height
  27864. * @param useScreen defines if screen size must be used (or the current render target if any)
  27865. * @returns a number defining the current render height
  27866. */
  27867. getRenderHeight(useScreen?: boolean): number;
  27868. /**
  27869. * Gets the HTML canvas attached with the current webGL context
  27870. * @returns a HTML canvas
  27871. */
  27872. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27873. /**
  27874. * Gets the client rect of the HTML canvas attached with the current webGL context
  27875. * @returns a client rectanglee
  27876. */
  27877. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27878. /**
  27879. * Defines the hardware scaling level.
  27880. * By default the hardware scaling level is computed from the window device ratio.
  27881. * 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.
  27882. * @param level defines the level to use
  27883. */
  27884. setHardwareScalingLevel(level: number): void;
  27885. /**
  27886. * Gets the current hardware scaling level.
  27887. * By default the hardware scaling level is computed from the window device ratio.
  27888. * 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.
  27889. * @returns a number indicating the current hardware scaling level
  27890. */
  27891. getHardwareScalingLevel(): number;
  27892. /**
  27893. * Gets the list of loaded textures
  27894. * @returns an array containing all loaded textures
  27895. */
  27896. getLoadedTexturesCache(): InternalTexture[];
  27897. /**
  27898. * Gets the object containing all engine capabilities
  27899. * @returns the EngineCapabilities object
  27900. */
  27901. getCaps(): EngineCapabilities;
  27902. /**
  27903. * Gets the current depth function
  27904. * @returns a number defining the depth function
  27905. */
  27906. getDepthFunction(): Nullable<number>;
  27907. /**
  27908. * Sets the current depth function
  27909. * @param depthFunc defines the function to use
  27910. */
  27911. setDepthFunction(depthFunc: number): void;
  27912. /**
  27913. * Sets the current depth function to GREATER
  27914. */
  27915. setDepthFunctionToGreater(): void;
  27916. /**
  27917. * Sets the current depth function to GEQUAL
  27918. */
  27919. setDepthFunctionToGreaterOrEqual(): void;
  27920. /**
  27921. * Sets the current depth function to LESS
  27922. */
  27923. setDepthFunctionToLess(): void;
  27924. private _cachedStencilBuffer;
  27925. private _cachedStencilFunction;
  27926. private _cachedStencilMask;
  27927. private _cachedStencilOperationPass;
  27928. private _cachedStencilOperationFail;
  27929. private _cachedStencilOperationDepthFail;
  27930. private _cachedStencilReference;
  27931. /**
  27932. * Caches the the state of the stencil buffer
  27933. */
  27934. cacheStencilState(): void;
  27935. /**
  27936. * Restores the state of the stencil buffer
  27937. */
  27938. restoreStencilState(): void;
  27939. /**
  27940. * Sets the current depth function to LEQUAL
  27941. */
  27942. setDepthFunctionToLessOrEqual(): void;
  27943. /**
  27944. * Gets a boolean indicating if stencil buffer is enabled
  27945. * @returns the current stencil buffer state
  27946. */
  27947. getStencilBuffer(): boolean;
  27948. /**
  27949. * Enable or disable the stencil buffer
  27950. * @param enable defines if the stencil buffer must be enabled or disabled
  27951. */
  27952. setStencilBuffer(enable: boolean): void;
  27953. /**
  27954. * Gets the current stencil mask
  27955. * @returns a number defining the new stencil mask to use
  27956. */
  27957. getStencilMask(): number;
  27958. /**
  27959. * Sets the current stencil mask
  27960. * @param mask defines the new stencil mask to use
  27961. */
  27962. setStencilMask(mask: number): void;
  27963. /**
  27964. * Gets the current stencil function
  27965. * @returns a number defining the stencil function to use
  27966. */
  27967. getStencilFunction(): number;
  27968. /**
  27969. * Gets the current stencil reference value
  27970. * @returns a number defining the stencil reference value to use
  27971. */
  27972. getStencilFunctionReference(): number;
  27973. /**
  27974. * Gets the current stencil mask
  27975. * @returns a number defining the stencil mask to use
  27976. */
  27977. getStencilFunctionMask(): number;
  27978. /**
  27979. * Sets the current stencil function
  27980. * @param stencilFunc defines the new stencil function to use
  27981. */
  27982. setStencilFunction(stencilFunc: number): void;
  27983. /**
  27984. * Sets the current stencil reference
  27985. * @param reference defines the new stencil reference to use
  27986. */
  27987. setStencilFunctionReference(reference: number): void;
  27988. /**
  27989. * Sets the current stencil mask
  27990. * @param mask defines the new stencil mask to use
  27991. */
  27992. setStencilFunctionMask(mask: number): void;
  27993. /**
  27994. * Gets the current stencil operation when stencil fails
  27995. * @returns a number defining stencil operation to use when stencil fails
  27996. */
  27997. getStencilOperationFail(): number;
  27998. /**
  27999. * Gets the current stencil operation when depth fails
  28000. * @returns a number defining stencil operation to use when depth fails
  28001. */
  28002. getStencilOperationDepthFail(): number;
  28003. /**
  28004. * Gets the current stencil operation when stencil passes
  28005. * @returns a number defining stencil operation to use when stencil passes
  28006. */
  28007. getStencilOperationPass(): number;
  28008. /**
  28009. * Sets the stencil operation to use when stencil fails
  28010. * @param operation defines the stencil operation to use when stencil fails
  28011. */
  28012. setStencilOperationFail(operation: number): void;
  28013. /**
  28014. * Sets the stencil operation to use when depth fails
  28015. * @param operation defines the stencil operation to use when depth fails
  28016. */
  28017. setStencilOperationDepthFail(operation: number): void;
  28018. /**
  28019. * Sets the stencil operation to use when stencil passes
  28020. * @param operation defines the stencil operation to use when stencil passes
  28021. */
  28022. setStencilOperationPass(operation: number): void;
  28023. /**
  28024. * Sets a boolean indicating if the dithering state is enabled or disabled
  28025. * @param value defines the dithering state
  28026. */
  28027. setDitheringState(value: boolean): void;
  28028. /**
  28029. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28030. * @param value defines the rasterizer state
  28031. */
  28032. setRasterizerState(value: boolean): void;
  28033. /**
  28034. * stop executing a render loop function and remove it from the execution array
  28035. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28036. */
  28037. stopRenderLoop(renderFunction?: () => void): void;
  28038. /** @hidden */
  28039. _renderLoop(): void;
  28040. /**
  28041. * Register and execute a render loop. The engine can have more than one render function
  28042. * @param renderFunction defines the function to continuously execute
  28043. */
  28044. runRenderLoop(renderFunction: () => void): void;
  28045. /**
  28046. * Toggle full screen mode
  28047. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28048. */
  28049. switchFullscreen(requestPointerLock: boolean): void;
  28050. /**
  28051. * Enters full screen mode
  28052. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28053. */
  28054. enterFullscreen(requestPointerLock: boolean): void;
  28055. /**
  28056. * Exits full screen mode
  28057. */
  28058. exitFullscreen(): void;
  28059. /**
  28060. * Clear the current render buffer or the current render target (if any is set up)
  28061. * @param color defines the color to use
  28062. * @param backBuffer defines if the back buffer must be cleared
  28063. * @param depth defines if the depth buffer must be cleared
  28064. * @param stencil defines if the stencil buffer must be cleared
  28065. */
  28066. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28067. /**
  28068. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28069. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28070. * @param y defines the y-coordinate of the corner of the clear rectangle
  28071. * @param width defines the width of the clear rectangle
  28072. * @param height defines the height of the clear rectangle
  28073. * @param clearColor defines the clear color
  28074. */
  28075. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28076. /**
  28077. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28078. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28079. * @param y defines the y-coordinate of the corner of the clear rectangle
  28080. * @param width defines the width of the clear rectangle
  28081. * @param height defines the height of the clear rectangle
  28082. */
  28083. enableScissor(x: number, y: number, width: number, height: number): void;
  28084. /**
  28085. * Disable previously set scissor test rectangle
  28086. */
  28087. disableScissor(): void;
  28088. private _viewportCached;
  28089. /** @hidden */
  28090. _viewport(x: number, y: number, width: number, height: number): void;
  28091. /**
  28092. * Set the WebGL's viewport
  28093. * @param viewport defines the viewport element to be used
  28094. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28095. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28096. */
  28097. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28098. /**
  28099. * Directly set the WebGL Viewport
  28100. * @param x defines the x coordinate of the viewport (in screen space)
  28101. * @param y defines the y coordinate of the viewport (in screen space)
  28102. * @param width defines the width of the viewport (in screen space)
  28103. * @param height defines the height of the viewport (in screen space)
  28104. * @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
  28105. */
  28106. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28107. /**
  28108. * Begin a new frame
  28109. */
  28110. beginFrame(): void;
  28111. /**
  28112. * Enf the current frame
  28113. */
  28114. endFrame(): void;
  28115. /**
  28116. * Resize the view according to the canvas' size
  28117. */
  28118. resize(): void;
  28119. /**
  28120. * Force a specific size of the canvas
  28121. * @param width defines the new canvas' width
  28122. * @param height defines the new canvas' height
  28123. */
  28124. setSize(width: number, height: number): void;
  28125. /**
  28126. * Binds the frame buffer to the specified texture.
  28127. * @param texture The texture to render to or null for the default canvas
  28128. * @param faceIndex The face of the texture to render to in case of cube texture
  28129. * @param requiredWidth The width of the target to render to
  28130. * @param requiredHeight The height of the target to render to
  28131. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28132. * @param depthStencilTexture The depth stencil texture to use to render
  28133. * @param lodLevel defines le lod level to bind to the frame buffer
  28134. */
  28135. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28136. /** @hidden */
  28137. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28138. /**
  28139. * Unbind the current render target texture from the webGL context
  28140. * @param texture defines the render target texture to unbind
  28141. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28142. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28143. */
  28144. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28145. /**
  28146. * Force the mipmap generation for the given render target texture
  28147. * @param texture defines the render target texture to use
  28148. */
  28149. generateMipMapsForCubemap(texture: InternalTexture): void;
  28150. /**
  28151. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28152. */
  28153. flushFramebuffer(): void;
  28154. /**
  28155. * Unbind the current render target and bind the default framebuffer
  28156. */
  28157. restoreDefaultFramebuffer(): void;
  28158. /**
  28159. * Create an uniform buffer
  28160. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28161. * @param elements defines the content of the uniform buffer
  28162. * @returns the webGL uniform buffer
  28163. */
  28164. createUniformBuffer(elements: FloatArray): DataBuffer;
  28165. /**
  28166. * Create a dynamic uniform buffer
  28167. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28168. * @param elements defines the content of the uniform buffer
  28169. * @returns the webGL uniform buffer
  28170. */
  28171. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28172. /**
  28173. * Update an existing uniform buffer
  28174. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28175. * @param uniformBuffer defines the target uniform buffer
  28176. * @param elements defines the content to update
  28177. * @param offset defines the offset in the uniform buffer where update should start
  28178. * @param count defines the size of the data to update
  28179. */
  28180. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28181. private _resetVertexBufferBinding;
  28182. /**
  28183. * Creates a vertex buffer
  28184. * @param data the data for the vertex buffer
  28185. * @returns the new WebGL static buffer
  28186. */
  28187. createVertexBuffer(data: DataArray): DataBuffer;
  28188. /**
  28189. * Creates a dynamic vertex buffer
  28190. * @param data the data for the dynamic vertex buffer
  28191. * @returns the new WebGL dynamic buffer
  28192. */
  28193. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28194. /**
  28195. * Update a dynamic index buffer
  28196. * @param indexBuffer defines the target index buffer
  28197. * @param indices defines the data to update
  28198. * @param offset defines the offset in the target index buffer where update should start
  28199. */
  28200. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28201. /**
  28202. * Updates a dynamic vertex buffer.
  28203. * @param vertexBuffer the vertex buffer to update
  28204. * @param data the data used to update the vertex buffer
  28205. * @param byteOffset the byte offset of the data
  28206. * @param byteLength the byte length of the data
  28207. */
  28208. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28209. private _resetIndexBufferBinding;
  28210. /**
  28211. * Creates a new index buffer
  28212. * @param indices defines the content of the index buffer
  28213. * @param updatable defines if the index buffer must be updatable
  28214. * @returns a new webGL buffer
  28215. */
  28216. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28217. /**
  28218. * Bind a webGL buffer to the webGL context
  28219. * @param buffer defines the buffer to bind
  28220. */
  28221. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28222. /**
  28223. * Bind an uniform buffer to the current webGL context
  28224. * @param buffer defines the buffer to bind
  28225. */
  28226. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28227. /**
  28228. * Bind a buffer to the current webGL context at a given location
  28229. * @param buffer defines the buffer to bind
  28230. * @param location defines the index where to bind the buffer
  28231. */
  28232. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28233. /**
  28234. * Bind a specific block at a given index in a specific shader program
  28235. * @param pipelineContext defines the pipeline context to use
  28236. * @param blockName defines the block name
  28237. * @param index defines the index where to bind the block
  28238. */
  28239. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28240. private bindIndexBuffer;
  28241. private bindBuffer;
  28242. /**
  28243. * update the bound buffer with the given data
  28244. * @param data defines the data to update
  28245. */
  28246. updateArrayBuffer(data: Float32Array): void;
  28247. private _vertexAttribPointer;
  28248. private _bindIndexBufferWithCache;
  28249. private _bindVertexBuffersAttributes;
  28250. /**
  28251. * Records a vertex array object
  28252. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28253. * @param vertexBuffers defines the list of vertex buffers to store
  28254. * @param indexBuffer defines the index buffer to store
  28255. * @param effect defines the effect to store
  28256. * @returns the new vertex array object
  28257. */
  28258. recordVertexArrayObject(vertexBuffers: {
  28259. [key: string]: VertexBuffer;
  28260. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28261. /**
  28262. * Bind a specific vertex array object
  28263. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28264. * @param vertexArrayObject defines the vertex array object to bind
  28265. * @param indexBuffer defines the index buffer to bind
  28266. */
  28267. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28268. /**
  28269. * Bind webGl buffers directly to the webGL context
  28270. * @param vertexBuffer defines the vertex buffer to bind
  28271. * @param indexBuffer defines the index buffer to bind
  28272. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28273. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28274. * @param effect defines the effect associated with the vertex buffer
  28275. */
  28276. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28277. private _unbindVertexArrayObject;
  28278. /**
  28279. * Bind a list of vertex buffers to the webGL context
  28280. * @param vertexBuffers defines the list of vertex buffers to bind
  28281. * @param indexBuffer defines the index buffer to bind
  28282. * @param effect defines the effect associated with the vertex buffers
  28283. */
  28284. bindBuffers(vertexBuffers: {
  28285. [key: string]: Nullable<VertexBuffer>;
  28286. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28287. /**
  28288. * Unbind all instance attributes
  28289. */
  28290. unbindInstanceAttributes(): void;
  28291. /**
  28292. * Release and free the memory of a vertex array object
  28293. * @param vao defines the vertex array object to delete
  28294. */
  28295. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28296. /** @hidden */
  28297. _releaseBuffer(buffer: DataBuffer): boolean;
  28298. /**
  28299. * Creates a webGL buffer to use with instanciation
  28300. * @param capacity defines the size of the buffer
  28301. * @returns the webGL buffer
  28302. */
  28303. createInstancesBuffer(capacity: number): DataBuffer;
  28304. /**
  28305. * Delete a webGL buffer used with instanciation
  28306. * @param buffer defines the webGL buffer to delete
  28307. */
  28308. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28309. /**
  28310. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28311. * @param instancesBuffer defines the webGL buffer to update and bind
  28312. * @param data defines the data to store in the buffer
  28313. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28314. */
  28315. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28316. /**
  28317. * Apply all cached states (depth, culling, stencil and alpha)
  28318. */
  28319. applyStates(): void;
  28320. /**
  28321. * Send a draw order
  28322. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28323. * @param indexStart defines the starting index
  28324. * @param indexCount defines the number of index to draw
  28325. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28326. */
  28327. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28328. /**
  28329. * Draw a list of points
  28330. * @param verticesStart defines the index of first vertex to draw
  28331. * @param verticesCount defines the count of vertices to draw
  28332. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28333. */
  28334. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28335. /**
  28336. * Draw a list of unindexed primitives
  28337. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28338. * @param verticesStart defines the index of first vertex to draw
  28339. * @param verticesCount defines the count of vertices to draw
  28340. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28341. */
  28342. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28343. /**
  28344. * Draw a list of indexed primitives
  28345. * @param fillMode defines the primitive to use
  28346. * @param indexStart defines the starting index
  28347. * @param indexCount defines the number of index to draw
  28348. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28349. */
  28350. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28351. /**
  28352. * Draw a list of unindexed primitives
  28353. * @param fillMode defines the primitive to use
  28354. * @param verticesStart defines the index of first vertex to draw
  28355. * @param verticesCount defines the count of vertices to draw
  28356. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28357. */
  28358. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28359. private _drawMode;
  28360. /** @hidden */
  28361. _releaseEffect(effect: Effect): void;
  28362. /** @hidden */
  28363. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28364. /**
  28365. * Create a new effect (used to store vertex/fragment shaders)
  28366. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28367. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28368. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28369. * @param samplers defines an array of string used to represent textures
  28370. * @param defines defines the string containing the defines to use to compile the shaders
  28371. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28372. * @param onCompiled defines a function to call when the effect creation is successful
  28373. * @param onError defines a function to call when the effect creation has failed
  28374. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28375. * @returns the new Effect
  28376. */
  28377. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  28378. private _compileShader;
  28379. private _compileRawShader;
  28380. /**
  28381. * Directly creates a webGL program
  28382. * @param pipelineContext defines the pipeline context to attach to
  28383. * @param vertexCode defines the vertex shader code to use
  28384. * @param fragmentCode defines the fragment shader code to use
  28385. * @param context defines the webGL context to use (if not set, the current one will be used)
  28386. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28387. * @returns the new webGL program
  28388. */
  28389. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28390. /**
  28391. * Creates a webGL program
  28392. * @param pipelineContext defines the pipeline context to attach to
  28393. * @param vertexCode defines the vertex shader code to use
  28394. * @param fragmentCode defines the fragment shader code to use
  28395. * @param defines defines the string containing the defines to use to compile the shaders
  28396. * @param context defines the webGL context to use (if not set, the current one will be used)
  28397. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28398. * @returns the new webGL program
  28399. */
  28400. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28401. /**
  28402. * Creates a new pipeline context
  28403. * @returns the new pipeline
  28404. */
  28405. createPipelineContext(): WebGLPipelineContext;
  28406. private _createShaderProgram;
  28407. private _finalizePipelineContext;
  28408. /** @hidden */
  28409. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28410. /** @hidden */
  28411. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28412. /** @hidden */
  28413. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28414. /**
  28415. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28416. * @param pipelineContext defines the pipeline context to use
  28417. * @param uniformsNames defines the list of uniform names
  28418. * @returns an array of webGL uniform locations
  28419. */
  28420. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28421. /**
  28422. * Gets the lsit of active attributes for a given webGL program
  28423. * @param pipelineContext defines the pipeline context to use
  28424. * @param attributesNames defines the list of attribute names to get
  28425. * @returns an array of indices indicating the offset of each attribute
  28426. */
  28427. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28428. /**
  28429. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28430. * @param effect defines the effect to activate
  28431. */
  28432. enableEffect(effect: Nullable<Effect>): void;
  28433. /**
  28434. * Set the value of an uniform to an array of int32
  28435. * @param uniform defines the webGL uniform location where to store the value
  28436. * @param array defines the array of int32 to store
  28437. */
  28438. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28439. /**
  28440. * Set the value of an uniform to an array of int32 (stored as vec2)
  28441. * @param uniform defines the webGL uniform location where to store the value
  28442. * @param array defines the array of int32 to store
  28443. */
  28444. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28445. /**
  28446. * Set the value of an uniform to an array of int32 (stored as vec3)
  28447. * @param uniform defines the webGL uniform location where to store the value
  28448. * @param array defines the array of int32 to store
  28449. */
  28450. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28451. /**
  28452. * Set the value of an uniform to an array of int32 (stored as vec4)
  28453. * @param uniform defines the webGL uniform location where to store the value
  28454. * @param array defines the array of int32 to store
  28455. */
  28456. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28457. /**
  28458. * Set the value of an uniform to an array of float32
  28459. * @param uniform defines the webGL uniform location where to store the value
  28460. * @param array defines the array of float32 to store
  28461. */
  28462. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28463. /**
  28464. * Set the value of an uniform to an array of float32 (stored as vec2)
  28465. * @param uniform defines the webGL uniform location where to store the value
  28466. * @param array defines the array of float32 to store
  28467. */
  28468. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28469. /**
  28470. * Set the value of an uniform to an array of float32 (stored as vec3)
  28471. * @param uniform defines the webGL uniform location where to store the value
  28472. * @param array defines the array of float32 to store
  28473. */
  28474. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28475. /**
  28476. * Set the value of an uniform to an array of float32 (stored as vec4)
  28477. * @param uniform defines the webGL uniform location where to store the value
  28478. * @param array defines the array of float32 to store
  28479. */
  28480. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28481. /**
  28482. * Set the value of an uniform to an array of number
  28483. * @param uniform defines the webGL uniform location where to store the value
  28484. * @param array defines the array of number to store
  28485. */
  28486. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28487. /**
  28488. * Set the value of an uniform to an array of number (stored as vec2)
  28489. * @param uniform defines the webGL uniform location where to store the value
  28490. * @param array defines the array of number to store
  28491. */
  28492. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28493. /**
  28494. * Set the value of an uniform to an array of number (stored as vec3)
  28495. * @param uniform defines the webGL uniform location where to store the value
  28496. * @param array defines the array of number to store
  28497. */
  28498. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28499. /**
  28500. * Set the value of an uniform to an array of number (stored as vec4)
  28501. * @param uniform defines the webGL uniform location where to store the value
  28502. * @param array defines the array of number to store
  28503. */
  28504. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28505. /**
  28506. * Set the value of an uniform to an array of float32 (stored as matrices)
  28507. * @param uniform defines the webGL uniform location where to store the value
  28508. * @param matrices defines the array of float32 to store
  28509. */
  28510. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28511. /**
  28512. * Set the value of an uniform to a matrix
  28513. * @param uniform defines the webGL uniform location where to store the value
  28514. * @param matrix defines the matrix to store
  28515. */
  28516. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28517. /**
  28518. * Set the value of an uniform to a matrix (3x3)
  28519. * @param uniform defines the webGL uniform location where to store the value
  28520. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28521. */
  28522. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28523. /**
  28524. * Set the value of an uniform to a matrix (2x2)
  28525. * @param uniform defines the webGL uniform location where to store the value
  28526. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28527. */
  28528. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28529. /**
  28530. * Set the value of an uniform to a number (int)
  28531. * @param uniform defines the webGL uniform location where to store the value
  28532. * @param value defines the int number to store
  28533. */
  28534. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28535. /**
  28536. * Set the value of an uniform to a number (float)
  28537. * @param uniform defines the webGL uniform location where to store the value
  28538. * @param value defines the float number to store
  28539. */
  28540. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28541. /**
  28542. * Set the value of an uniform to a vec2
  28543. * @param uniform defines the webGL uniform location where to store the value
  28544. * @param x defines the 1st component of the value
  28545. * @param y defines the 2nd component of the value
  28546. */
  28547. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28548. /**
  28549. * Set the value of an uniform to a vec3
  28550. * @param uniform defines the webGL uniform location where to store the value
  28551. * @param x defines the 1st component of the value
  28552. * @param y defines the 2nd component of the value
  28553. * @param z defines the 3rd component of the value
  28554. */
  28555. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28556. /**
  28557. * Set the value of an uniform to a boolean
  28558. * @param uniform defines the webGL uniform location where to store the value
  28559. * @param bool defines the boolean to store
  28560. */
  28561. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28562. /**
  28563. * Set the value of an uniform to a vec4
  28564. * @param uniform defines the webGL uniform location where to store the value
  28565. * @param x defines the 1st component of the value
  28566. * @param y defines the 2nd component of the value
  28567. * @param z defines the 3rd component of the value
  28568. * @param w defines the 4th component of the value
  28569. */
  28570. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28571. /**
  28572. * Set the value of an uniform to a Color3
  28573. * @param uniform defines the webGL uniform location where to store the value
  28574. * @param color3 defines the color to store
  28575. */
  28576. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28577. /**
  28578. * Set the value of an uniform to a Color3 and an alpha value
  28579. * @param uniform defines the webGL uniform location where to store the value
  28580. * @param color3 defines the color to store
  28581. * @param alpha defines the alpha component to store
  28582. */
  28583. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28584. /**
  28585. * Sets a Color4 on a uniform variable
  28586. * @param uniform defines the uniform location
  28587. * @param color4 defines the value to be set
  28588. */
  28589. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28590. /**
  28591. * Set various states to the webGL context
  28592. * @param culling defines backface culling state
  28593. * @param zOffset defines the value to apply to zOffset (0 by default)
  28594. * @param force defines if states must be applied even if cache is up to date
  28595. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28596. */
  28597. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28598. /**
  28599. * Set the z offset to apply to current rendering
  28600. * @param value defines the offset to apply
  28601. */
  28602. setZOffset(value: number): void;
  28603. /**
  28604. * Gets the current value of the zOffset
  28605. * @returns the current zOffset state
  28606. */
  28607. getZOffset(): number;
  28608. /**
  28609. * Enable or disable depth buffering
  28610. * @param enable defines the state to set
  28611. */
  28612. setDepthBuffer(enable: boolean): void;
  28613. /**
  28614. * Gets a boolean indicating if depth writing is enabled
  28615. * @returns the current depth writing state
  28616. */
  28617. getDepthWrite(): boolean;
  28618. /**
  28619. * Enable or disable depth writing
  28620. * @param enable defines the state to set
  28621. */
  28622. setDepthWrite(enable: boolean): void;
  28623. /**
  28624. * Enable or disable color writing
  28625. * @param enable defines the state to set
  28626. */
  28627. setColorWrite(enable: boolean): void;
  28628. /**
  28629. * Gets a boolean indicating if color writing is enabled
  28630. * @returns the current color writing state
  28631. */
  28632. getColorWrite(): boolean;
  28633. /**
  28634. * Sets alpha constants used by some alpha blending modes
  28635. * @param r defines the red component
  28636. * @param g defines the green component
  28637. * @param b defines the blue component
  28638. * @param a defines the alpha component
  28639. */
  28640. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28641. /**
  28642. * Sets the current alpha mode
  28643. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28644. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28645. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28646. */
  28647. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28648. /**
  28649. * Gets the current alpha mode
  28650. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28651. * @returns the current alpha mode
  28652. */
  28653. getAlphaMode(): number;
  28654. /**
  28655. * Clears the list of texture accessible through engine.
  28656. * This can help preventing texture load conflict due to name collision.
  28657. */
  28658. clearInternalTexturesCache(): void;
  28659. /**
  28660. * Force the entire cache to be cleared
  28661. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28662. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28663. */
  28664. wipeCaches(bruteForce?: boolean): void;
  28665. /**
  28666. * Set the compressed texture format to use, based on the formats you have, and the formats
  28667. * supported by the hardware / browser.
  28668. *
  28669. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28670. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28671. * to API arguments needed to compressed textures. This puts the burden on the container
  28672. * generator to house the arcane code for determining these for current & future formats.
  28673. *
  28674. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28675. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28676. *
  28677. * Note: The result of this call is not taken into account when a texture is base64.
  28678. *
  28679. * @param formatsAvailable defines the list of those format families you have created
  28680. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28681. *
  28682. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28683. * @returns The extension selected.
  28684. */
  28685. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28686. /** @hidden */
  28687. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28688. min: number;
  28689. mag: number;
  28690. };
  28691. /** @hidden */
  28692. _createTexture(): WebGLTexture;
  28693. /**
  28694. * Usually called from Texture.ts.
  28695. * Passed information to create a WebGLTexture
  28696. * @param urlArg defines a value which contains one of the following:
  28697. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28698. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28699. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28700. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28701. * @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)
  28702. * @param scene needed for loading to the correct scene
  28703. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28704. * @param onLoad optional callback to be called upon successful completion
  28705. * @param onError optional callback to be called upon failure
  28706. * @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
  28707. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28708. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28709. * @param forcedExtension defines the extension to use to pick the right loader
  28710. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28711. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28712. */
  28713. 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;
  28714. private _rescaleTexture;
  28715. private _unpackFlipYCached;
  28716. /**
  28717. * In case you are sharing the context with other applications, it might
  28718. * be interested to not cache the unpack flip y state to ensure a consistent
  28719. * value would be set.
  28720. */
  28721. enableUnpackFlipYCached: boolean;
  28722. /** @hidden */
  28723. _unpackFlipY(value: boolean): void;
  28724. /** @hidden */
  28725. _getUnpackAlignement(): number;
  28726. /**
  28727. * Creates a dynamic texture
  28728. * @param width defines the width of the texture
  28729. * @param height defines the height of the texture
  28730. * @param generateMipMaps defines if the engine should generate the mip levels
  28731. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28732. * @returns the dynamic texture inside an InternalTexture
  28733. */
  28734. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28735. /**
  28736. * Update the sampling mode of a given texture
  28737. * @param samplingMode defines the required sampling mode
  28738. * @param texture defines the texture to update
  28739. */
  28740. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28741. /**
  28742. * Update the content of a dynamic texture
  28743. * @param texture defines the texture to update
  28744. * @param canvas defines the canvas containing the source
  28745. * @param invertY defines if data must be stored with Y axis inverted
  28746. * @param premulAlpha defines if alpha is stored as premultiplied
  28747. * @param format defines the format of the data
  28748. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28749. */
  28750. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28751. /**
  28752. * Update a video texture
  28753. * @param texture defines the texture to update
  28754. * @param video defines the video element to use
  28755. * @param invertY defines if data must be stored with Y axis inverted
  28756. */
  28757. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28758. /**
  28759. * Updates a depth texture Comparison Mode and Function.
  28760. * If the comparison Function is equal to 0, the mode will be set to none.
  28761. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28762. * @param texture The texture to set the comparison function for
  28763. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28764. */
  28765. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28766. /** @hidden */
  28767. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28768. width: number;
  28769. height: number;
  28770. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28771. /**
  28772. * Creates a depth stencil texture.
  28773. * This is only available in WebGL 2 or with the depth texture extension available.
  28774. * @param size The size of face edge in the texture.
  28775. * @param options The options defining the texture.
  28776. * @returns The texture
  28777. */
  28778. createDepthStencilTexture(size: number | {
  28779. width: number;
  28780. height: number;
  28781. }, options: DepthTextureCreationOptions): InternalTexture;
  28782. /**
  28783. * Creates a depth stencil texture.
  28784. * This is only available in WebGL 2 or with the depth texture extension available.
  28785. * @param size The size of face edge in the texture.
  28786. * @param options The options defining the texture.
  28787. * @returns The texture
  28788. */
  28789. private _createDepthStencilTexture;
  28790. /**
  28791. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28792. * @param renderTarget The render target to set the frame buffer for
  28793. */
  28794. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28795. /**
  28796. * Creates a new render target texture
  28797. * @param size defines the size of the texture
  28798. * @param options defines the options used to create the texture
  28799. * @returns a new render target texture stored in an InternalTexture
  28800. */
  28801. createRenderTargetTexture(size: number | {
  28802. width: number;
  28803. height: number;
  28804. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28805. /** @hidden */
  28806. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28807. /**
  28808. * Updates the sample count of a render target texture
  28809. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28810. * @param texture defines the texture to update
  28811. * @param samples defines the sample count to set
  28812. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28813. */
  28814. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28815. /** @hidden */
  28816. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28817. /** @hidden */
  28818. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28819. /** @hidden */
  28820. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28821. /** @hidden */
  28822. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28823. /**
  28824. * @hidden
  28825. */
  28826. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28827. private _prepareWebGLTextureContinuation;
  28828. private _prepareWebGLTexture;
  28829. /** @hidden */
  28830. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28831. /** @hidden */
  28832. _releaseFramebufferObjects(texture: InternalTexture): void;
  28833. /** @hidden */
  28834. _releaseTexture(texture: InternalTexture): void;
  28835. private setProgram;
  28836. private _boundUniforms;
  28837. /**
  28838. * Binds an effect to the webGL context
  28839. * @param effect defines the effect to bind
  28840. */
  28841. bindSamplers(effect: Effect): void;
  28842. private _activateCurrentTexture;
  28843. /** @hidden */
  28844. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28845. /** @hidden */
  28846. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28847. /**
  28848. * Sets a texture to the webGL context from a postprocess
  28849. * @param channel defines the channel to use
  28850. * @param postProcess defines the source postprocess
  28851. */
  28852. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28853. /**
  28854. * Binds the output of the passed in post process to the texture channel specified
  28855. * @param channel The channel the texture should be bound to
  28856. * @param postProcess The post process which's output should be bound
  28857. */
  28858. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28859. /**
  28860. * Unbind all textures from the webGL context
  28861. */
  28862. unbindAllTextures(): void;
  28863. /**
  28864. * Sets a texture to the according uniform.
  28865. * @param channel The texture channel
  28866. * @param uniform The uniform to set
  28867. * @param texture The texture to apply
  28868. */
  28869. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28870. /**
  28871. * Sets a depth stencil texture from a render target to the according uniform.
  28872. * @param channel The texture channel
  28873. * @param uniform The uniform to set
  28874. * @param texture The render target texture containing the depth stencil texture to apply
  28875. */
  28876. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28877. private _bindSamplerUniformToChannel;
  28878. private _getTextureWrapMode;
  28879. private _setTexture;
  28880. /**
  28881. * Sets an array of texture to the webGL context
  28882. * @param channel defines the channel where the texture array must be set
  28883. * @param uniform defines the associated uniform location
  28884. * @param textures defines the array of textures to bind
  28885. */
  28886. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28887. /** @hidden */
  28888. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28889. private _setTextureParameterFloat;
  28890. private _setTextureParameterInteger;
  28891. /**
  28892. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28893. * @param x defines the x coordinate of the rectangle where pixels must be read
  28894. * @param y defines the y coordinate of the rectangle where pixels must be read
  28895. * @param width defines the width of the rectangle where pixels must be read
  28896. * @param height defines the height of the rectangle where pixels must be read
  28897. * @returns a Uint8Array containing RGBA colors
  28898. */
  28899. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28900. /**
  28901. * Add an externaly attached data from its key.
  28902. * This method call will fail and return false, if such key already exists.
  28903. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28904. * @param key the unique key that identifies the data
  28905. * @param data the data object to associate to the key for this Engine instance
  28906. * @return true if no such key were already present and the data was added successfully, false otherwise
  28907. */
  28908. addExternalData<T>(key: string, data: T): boolean;
  28909. /**
  28910. * Get an externaly attached data from its key
  28911. * @param key the unique key that identifies the data
  28912. * @return the associated data, if present (can be null), or undefined if not present
  28913. */
  28914. getExternalData<T>(key: string): T;
  28915. /**
  28916. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28917. * @param key the unique key that identifies the data
  28918. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28919. * @return the associated data, can be null if the factory returned null.
  28920. */
  28921. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28922. /**
  28923. * Remove an externaly attached data from the Engine instance
  28924. * @param key the unique key that identifies the data
  28925. * @return true if the data was successfully removed, false if it doesn't exist
  28926. */
  28927. removeExternalData(key: string): boolean;
  28928. /**
  28929. * Unbind all vertex attributes from the webGL context
  28930. */
  28931. unbindAllAttributes(): void;
  28932. /**
  28933. * 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
  28934. */
  28935. releaseEffects(): void;
  28936. /**
  28937. * Dispose and release all associated resources
  28938. */
  28939. dispose(): void;
  28940. /**
  28941. * Display the loading screen
  28942. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28943. */
  28944. displayLoadingUI(): void;
  28945. /**
  28946. * Hide the loading screen
  28947. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28948. */
  28949. hideLoadingUI(): void;
  28950. /**
  28951. * Gets the current loading screen object
  28952. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28953. */
  28954. /**
  28955. * Sets the current loading screen object
  28956. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28957. */
  28958. loadingScreen: ILoadingScreen;
  28959. /**
  28960. * Sets the current loading screen text
  28961. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28962. */
  28963. loadingUIText: string;
  28964. /**
  28965. * Sets the current loading screen background color
  28966. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28967. */
  28968. loadingUIBackgroundColor: string;
  28969. /**
  28970. * Attach a new callback raised when context lost event is fired
  28971. * @param callback defines the callback to call
  28972. */
  28973. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28974. /**
  28975. * Attach a new callback raised when context restored event is fired
  28976. * @param callback defines the callback to call
  28977. */
  28978. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28979. /**
  28980. * Gets the source code of the vertex shader associated with a specific webGL program
  28981. * @param program defines the program to use
  28982. * @returns a string containing the source code of the vertex shader associated with the program
  28983. */
  28984. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28985. /**
  28986. * Gets the source code of the fragment shader associated with a specific webGL program
  28987. * @param program defines the program to use
  28988. * @returns a string containing the source code of the fragment shader associated with the program
  28989. */
  28990. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28991. /**
  28992. * Get the current error code of the webGL context
  28993. * @returns the error code
  28994. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28995. */
  28996. getError(): number;
  28997. /**
  28998. * Gets the current framerate
  28999. * @returns a number representing the framerate
  29000. */
  29001. getFps(): number;
  29002. /**
  29003. * Gets the time spent between current and previous frame
  29004. * @returns a number representing the delta time in ms
  29005. */
  29006. getDeltaTime(): number;
  29007. private _measureFps;
  29008. /** @hidden */
  29009. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29010. private _canRenderToFloatFramebuffer;
  29011. private _canRenderToHalfFloatFramebuffer;
  29012. private _canRenderToFramebuffer;
  29013. /** @hidden */
  29014. _getWebGLTextureType(type: number): number;
  29015. /** @hidden */
  29016. _getInternalFormat(format: number): number;
  29017. /** @hidden */
  29018. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29019. /** @hidden */
  29020. _getRGBAMultiSampleBufferFormat(type: number): number;
  29021. /** @hidden */
  29022. _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;
  29023. /** @hidden */
  29024. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29025. /**
  29026. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29027. * @returns true if the engine can be created
  29028. * @ignorenaming
  29029. */
  29030. static isSupported(): boolean;
  29031. }
  29032. }
  29033. declare module BABYLON {
  29034. /**
  29035. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29036. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29037. */
  29038. export class EffectFallbacks {
  29039. private _defines;
  29040. private _currentRank;
  29041. private _maxRank;
  29042. private _mesh;
  29043. /**
  29044. * Removes the fallback from the bound mesh.
  29045. */
  29046. unBindMesh(): void;
  29047. /**
  29048. * Adds a fallback on the specified property.
  29049. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29050. * @param define The name of the define in the shader
  29051. */
  29052. addFallback(rank: number, define: string): void;
  29053. /**
  29054. * Sets the mesh to use CPU skinning when needing to fallback.
  29055. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29056. * @param mesh The mesh to use the fallbacks.
  29057. */
  29058. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29059. /**
  29060. * Checks to see if more fallbacks are still availible.
  29061. */
  29062. readonly isMoreFallbacks: boolean;
  29063. /**
  29064. * Removes the defines that shoould be removed when falling back.
  29065. * @param currentDefines defines the current define statements for the shader.
  29066. * @param effect defines the current effect we try to compile
  29067. * @returns The resulting defines with defines of the current rank removed.
  29068. */
  29069. reduce(currentDefines: string, effect: Effect): string;
  29070. }
  29071. /**
  29072. * Options to be used when creating an effect.
  29073. */
  29074. export class EffectCreationOptions {
  29075. /**
  29076. * Atrributes that will be used in the shader.
  29077. */
  29078. attributes: string[];
  29079. /**
  29080. * Uniform varible names that will be set in the shader.
  29081. */
  29082. uniformsNames: string[];
  29083. /**
  29084. * Uniform buffer varible names that will be set in the shader.
  29085. */
  29086. uniformBuffersNames: string[];
  29087. /**
  29088. * Sampler texture variable names that will be set in the shader.
  29089. */
  29090. samplers: string[];
  29091. /**
  29092. * Define statements that will be set in the shader.
  29093. */
  29094. defines: any;
  29095. /**
  29096. * Possible fallbacks for this effect to improve performance when needed.
  29097. */
  29098. fallbacks: Nullable<EffectFallbacks>;
  29099. /**
  29100. * Callback that will be called when the shader is compiled.
  29101. */
  29102. onCompiled: Nullable<(effect: Effect) => void>;
  29103. /**
  29104. * Callback that will be called if an error occurs during shader compilation.
  29105. */
  29106. onError: Nullable<(effect: Effect, errors: string) => void>;
  29107. /**
  29108. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29109. */
  29110. indexParameters: any;
  29111. /**
  29112. * Max number of lights that can be used in the shader.
  29113. */
  29114. maxSimultaneousLights: number;
  29115. /**
  29116. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29117. */
  29118. transformFeedbackVaryings: Nullable<string[]>;
  29119. }
  29120. /**
  29121. * Effect containing vertex and fragment shader that can be executed on an object.
  29122. */
  29123. export class Effect implements IDisposable {
  29124. /**
  29125. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29126. */
  29127. static ShadersRepository: string;
  29128. /**
  29129. * Name of the effect.
  29130. */
  29131. name: any;
  29132. /**
  29133. * String container all the define statements that should be set on the shader.
  29134. */
  29135. defines: string;
  29136. /**
  29137. * Callback that will be called when the shader is compiled.
  29138. */
  29139. onCompiled: Nullable<(effect: Effect) => void>;
  29140. /**
  29141. * Callback that will be called if an error occurs during shader compilation.
  29142. */
  29143. onError: Nullable<(effect: Effect, errors: string) => void>;
  29144. /**
  29145. * Callback that will be called when effect is bound.
  29146. */
  29147. onBind: Nullable<(effect: Effect) => void>;
  29148. /**
  29149. * Unique ID of the effect.
  29150. */
  29151. uniqueId: number;
  29152. /**
  29153. * Observable that will be called when the shader is compiled.
  29154. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29155. */
  29156. onCompileObservable: Observable<Effect>;
  29157. /**
  29158. * Observable that will be called if an error occurs during shader compilation.
  29159. */
  29160. onErrorObservable: Observable<Effect>;
  29161. /** @hidden */
  29162. _onBindObservable: Nullable<Observable<Effect>>;
  29163. /**
  29164. * Observable that will be called when effect is bound.
  29165. */
  29166. readonly onBindObservable: Observable<Effect>;
  29167. /** @hidden */
  29168. _bonesComputationForcedToCPU: boolean;
  29169. private static _uniqueIdSeed;
  29170. private _engine;
  29171. private _uniformBuffersNames;
  29172. private _uniformsNames;
  29173. private _samplerList;
  29174. private _samplers;
  29175. private _isReady;
  29176. private _compilationError;
  29177. private _attributesNames;
  29178. private _attributes;
  29179. private _uniforms;
  29180. /**
  29181. * Key for the effect.
  29182. * @hidden
  29183. */
  29184. _key: string;
  29185. private _indexParameters;
  29186. private _fallbacks;
  29187. private _vertexSourceCode;
  29188. private _fragmentSourceCode;
  29189. private _vertexSourceCodeOverride;
  29190. private _fragmentSourceCodeOverride;
  29191. private _transformFeedbackVaryings;
  29192. /**
  29193. * Compiled shader to webGL program.
  29194. * @hidden
  29195. */
  29196. _pipelineContext: Nullable<IPipelineContext>;
  29197. private _valueCache;
  29198. private static _baseCache;
  29199. /**
  29200. * Instantiates an effect.
  29201. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29202. * @param baseName Name of the effect.
  29203. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29204. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29205. * @param samplers List of sampler variables that will be passed to the shader.
  29206. * @param engine Engine to be used to render the effect
  29207. * @param defines Define statements to be added to the shader.
  29208. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29209. * @param onCompiled Callback that will be called when the shader is compiled.
  29210. * @param onError Callback that will be called if an error occurs during shader compilation.
  29211. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29212. */
  29213. 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);
  29214. /**
  29215. * Unique key for this effect
  29216. */
  29217. readonly key: string;
  29218. /**
  29219. * If the effect has been compiled and prepared.
  29220. * @returns if the effect is compiled and prepared.
  29221. */
  29222. isReady(): boolean;
  29223. /**
  29224. * The engine the effect was initialized with.
  29225. * @returns the engine.
  29226. */
  29227. getEngine(): Engine;
  29228. /**
  29229. * The pipeline context for this effect
  29230. * @returns the associated pipeline context
  29231. */
  29232. getPipelineContext(): Nullable<IPipelineContext>;
  29233. /**
  29234. * The set of names of attribute variables for the shader.
  29235. * @returns An array of attribute names.
  29236. */
  29237. getAttributesNames(): string[];
  29238. /**
  29239. * Returns the attribute at the given index.
  29240. * @param index The index of the attribute.
  29241. * @returns The location of the attribute.
  29242. */
  29243. getAttributeLocation(index: number): number;
  29244. /**
  29245. * Returns the attribute based on the name of the variable.
  29246. * @param name of the attribute to look up.
  29247. * @returns the attribute location.
  29248. */
  29249. getAttributeLocationByName(name: string): number;
  29250. /**
  29251. * The number of attributes.
  29252. * @returns the numnber of attributes.
  29253. */
  29254. getAttributesCount(): number;
  29255. /**
  29256. * Gets the index of a uniform variable.
  29257. * @param uniformName of the uniform to look up.
  29258. * @returns the index.
  29259. */
  29260. getUniformIndex(uniformName: string): number;
  29261. /**
  29262. * Returns the attribute based on the name of the variable.
  29263. * @param uniformName of the uniform to look up.
  29264. * @returns the location of the uniform.
  29265. */
  29266. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29267. /**
  29268. * Returns an array of sampler variable names
  29269. * @returns The array of sampler variable neames.
  29270. */
  29271. getSamplers(): string[];
  29272. /**
  29273. * The error from the last compilation.
  29274. * @returns the error string.
  29275. */
  29276. getCompilationError(): string;
  29277. /**
  29278. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29279. * @param func The callback to be used.
  29280. */
  29281. executeWhenCompiled(func: (effect: Effect) => void): void;
  29282. private _checkIsReady;
  29283. /** @hidden */
  29284. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29285. /** @hidden */
  29286. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29287. /** @hidden */
  29288. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29289. private _processShaderConversion;
  29290. private _processIncludes;
  29291. private _processPrecision;
  29292. /**
  29293. * Recompiles the webGL program
  29294. * @param vertexSourceCode The source code for the vertex shader.
  29295. * @param fragmentSourceCode The source code for the fragment shader.
  29296. * @param onCompiled Callback called when completed.
  29297. * @param onError Callback called on error.
  29298. * @hidden
  29299. */
  29300. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29301. /**
  29302. * Prepares the effect
  29303. * @hidden
  29304. */
  29305. _prepareEffect(): void;
  29306. /**
  29307. * Checks if the effect is supported. (Must be called after compilation)
  29308. */
  29309. readonly isSupported: boolean;
  29310. /**
  29311. * Binds a texture to the engine to be used as output of the shader.
  29312. * @param channel Name of the output variable.
  29313. * @param texture Texture to bind.
  29314. * @hidden
  29315. */
  29316. _bindTexture(channel: string, texture: InternalTexture): void;
  29317. /**
  29318. * Sets a texture on the engine to be used in the shader.
  29319. * @param channel Name of the sampler variable.
  29320. * @param texture Texture to set.
  29321. */
  29322. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29323. /**
  29324. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29325. * @param channel Name of the sampler variable.
  29326. * @param texture Texture to set.
  29327. */
  29328. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29329. /**
  29330. * Sets an array of textures on the engine to be used in the shader.
  29331. * @param channel Name of the variable.
  29332. * @param textures Textures to set.
  29333. */
  29334. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29335. /**
  29336. * 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)
  29337. * @param channel Name of the sampler variable.
  29338. * @param postProcess Post process to get the input texture from.
  29339. */
  29340. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29341. /**
  29342. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29343. * 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)
  29344. * @param channel Name of the sampler variable.
  29345. * @param postProcess Post process to get the output texture from.
  29346. */
  29347. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29348. /** @hidden */
  29349. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29350. /** @hidden */
  29351. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29352. /** @hidden */
  29353. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29354. /** @hidden */
  29355. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29356. /**
  29357. * Binds a buffer to a uniform.
  29358. * @param buffer Buffer to bind.
  29359. * @param name Name of the uniform variable to bind to.
  29360. */
  29361. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29362. /**
  29363. * Binds block to a uniform.
  29364. * @param blockName Name of the block to bind.
  29365. * @param index Index to bind.
  29366. */
  29367. bindUniformBlock(blockName: string, index: number): void;
  29368. /**
  29369. * Sets an interger value on a uniform variable.
  29370. * @param uniformName Name of the variable.
  29371. * @param value Value to be set.
  29372. * @returns this effect.
  29373. */
  29374. setInt(uniformName: string, value: number): Effect;
  29375. /**
  29376. * Sets an int array on a uniform variable.
  29377. * @param uniformName Name of the variable.
  29378. * @param array array to be set.
  29379. * @returns this effect.
  29380. */
  29381. setIntArray(uniformName: string, array: Int32Array): Effect;
  29382. /**
  29383. * 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)
  29384. * @param uniformName Name of the variable.
  29385. * @param array array to be set.
  29386. * @returns this effect.
  29387. */
  29388. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29389. /**
  29390. * 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)
  29391. * @param uniformName Name of the variable.
  29392. * @param array array to be set.
  29393. * @returns this effect.
  29394. */
  29395. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29396. /**
  29397. * 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)
  29398. * @param uniformName Name of the variable.
  29399. * @param array array to be set.
  29400. * @returns this effect.
  29401. */
  29402. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29403. /**
  29404. * Sets an float array on a uniform variable.
  29405. * @param uniformName Name of the variable.
  29406. * @param array array to be set.
  29407. * @returns this effect.
  29408. */
  29409. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29410. /**
  29411. * 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)
  29412. * @param uniformName Name of the variable.
  29413. * @param array array to be set.
  29414. * @returns this effect.
  29415. */
  29416. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29417. /**
  29418. * 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)
  29419. * @param uniformName Name of the variable.
  29420. * @param array array to be set.
  29421. * @returns this effect.
  29422. */
  29423. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29424. /**
  29425. * 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)
  29426. * @param uniformName Name of the variable.
  29427. * @param array array to be set.
  29428. * @returns this effect.
  29429. */
  29430. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29431. /**
  29432. * Sets an array on a uniform variable.
  29433. * @param uniformName Name of the variable.
  29434. * @param array array to be set.
  29435. * @returns this effect.
  29436. */
  29437. setArray(uniformName: string, array: number[]): Effect;
  29438. /**
  29439. * 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)
  29440. * @param uniformName Name of the variable.
  29441. * @param array array to be set.
  29442. * @returns this effect.
  29443. */
  29444. setArray2(uniformName: string, array: number[]): Effect;
  29445. /**
  29446. * 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)
  29447. * @param uniformName Name of the variable.
  29448. * @param array array to be set.
  29449. * @returns this effect.
  29450. */
  29451. setArray3(uniformName: string, array: number[]): Effect;
  29452. /**
  29453. * 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)
  29454. * @param uniformName Name of the variable.
  29455. * @param array array to be set.
  29456. * @returns this effect.
  29457. */
  29458. setArray4(uniformName: string, array: number[]): Effect;
  29459. /**
  29460. * Sets matrices on a uniform variable.
  29461. * @param uniformName Name of the variable.
  29462. * @param matrices matrices to be set.
  29463. * @returns this effect.
  29464. */
  29465. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29466. /**
  29467. * Sets matrix on a uniform variable.
  29468. * @param uniformName Name of the variable.
  29469. * @param matrix matrix to be set.
  29470. * @returns this effect.
  29471. */
  29472. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29473. /**
  29474. * 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)
  29475. * @param uniformName Name of the variable.
  29476. * @param matrix matrix to be set.
  29477. * @returns this effect.
  29478. */
  29479. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29480. /**
  29481. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29482. * @param uniformName Name of the variable.
  29483. * @param matrix matrix to be set.
  29484. * @returns this effect.
  29485. */
  29486. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29487. /**
  29488. * Sets a float on a uniform variable.
  29489. * @param uniformName Name of the variable.
  29490. * @param value value to be set.
  29491. * @returns this effect.
  29492. */
  29493. setFloat(uniformName: string, value: number): Effect;
  29494. /**
  29495. * Sets a boolean on a uniform variable.
  29496. * @param uniformName Name of the variable.
  29497. * @param bool value to be set.
  29498. * @returns this effect.
  29499. */
  29500. setBool(uniformName: string, bool: boolean): Effect;
  29501. /**
  29502. * Sets a Vector2 on a uniform variable.
  29503. * @param uniformName Name of the variable.
  29504. * @param vector2 vector2 to be set.
  29505. * @returns this effect.
  29506. */
  29507. setVector2(uniformName: string, vector2: Vector2): Effect;
  29508. /**
  29509. * Sets a float2 on a uniform variable.
  29510. * @param uniformName Name of the variable.
  29511. * @param x First float in float2.
  29512. * @param y Second float in float2.
  29513. * @returns this effect.
  29514. */
  29515. setFloat2(uniformName: string, x: number, y: number): Effect;
  29516. /**
  29517. * Sets a Vector3 on a uniform variable.
  29518. * @param uniformName Name of the variable.
  29519. * @param vector3 Value to be set.
  29520. * @returns this effect.
  29521. */
  29522. setVector3(uniformName: string, vector3: Vector3): Effect;
  29523. /**
  29524. * Sets a float3 on a uniform variable.
  29525. * @param uniformName Name of the variable.
  29526. * @param x First float in float3.
  29527. * @param y Second float in float3.
  29528. * @param z Third float in float3.
  29529. * @returns this effect.
  29530. */
  29531. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29532. /**
  29533. * Sets a Vector4 on a uniform variable.
  29534. * @param uniformName Name of the variable.
  29535. * @param vector4 Value to be set.
  29536. * @returns this effect.
  29537. */
  29538. setVector4(uniformName: string, vector4: Vector4): Effect;
  29539. /**
  29540. * Sets a float4 on a uniform variable.
  29541. * @param uniformName Name of the variable.
  29542. * @param x First float in float4.
  29543. * @param y Second float in float4.
  29544. * @param z Third float in float4.
  29545. * @param w Fourth float in float4.
  29546. * @returns this effect.
  29547. */
  29548. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29549. /**
  29550. * Sets a Color3 on a uniform variable.
  29551. * @param uniformName Name of the variable.
  29552. * @param color3 Value to be set.
  29553. * @returns this effect.
  29554. */
  29555. setColor3(uniformName: string, color3: Color3): Effect;
  29556. /**
  29557. * Sets a Color4 on a uniform variable.
  29558. * @param uniformName Name of the variable.
  29559. * @param color3 Value to be set.
  29560. * @param alpha Alpha value to be set.
  29561. * @returns this effect.
  29562. */
  29563. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29564. /**
  29565. * Sets a Color4 on a uniform variable
  29566. * @param uniformName defines the name of the variable
  29567. * @param color4 defines the value to be set
  29568. * @returns this effect.
  29569. */
  29570. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29571. /** Release all associated resources */
  29572. dispose(): void;
  29573. /**
  29574. * This function will add a new shader to the shader store
  29575. * @param name the name of the shader
  29576. * @param pixelShader optional pixel shader content
  29577. * @param vertexShader optional vertex shader content
  29578. */
  29579. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29580. /**
  29581. * Store of each shader (The can be looked up using effect.key)
  29582. */
  29583. static ShadersStore: {
  29584. [key: string]: string;
  29585. };
  29586. /**
  29587. * Store of each included file for a shader (The can be looked up using effect.key)
  29588. */
  29589. static IncludesShadersStore: {
  29590. [key: string]: string;
  29591. };
  29592. /**
  29593. * Resets the cache of effects.
  29594. */
  29595. static ResetCache(): void;
  29596. }
  29597. }
  29598. declare module BABYLON {
  29599. /**
  29600. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29601. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29602. * 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;
  29603. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29604. */
  29605. export class ColorCurves {
  29606. private _dirty;
  29607. private _tempColor;
  29608. private _globalCurve;
  29609. private _highlightsCurve;
  29610. private _midtonesCurve;
  29611. private _shadowsCurve;
  29612. private _positiveCurve;
  29613. private _negativeCurve;
  29614. private _globalHue;
  29615. private _globalDensity;
  29616. private _globalSaturation;
  29617. private _globalExposure;
  29618. /**
  29619. * Gets the global Hue value.
  29620. * 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).
  29621. */
  29622. /**
  29623. * Sets the global Hue value.
  29624. * 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).
  29625. */
  29626. globalHue: number;
  29627. /**
  29628. * Gets the global Density value.
  29629. * 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.
  29630. * Values less than zero provide a filter of opposite hue.
  29631. */
  29632. /**
  29633. * Sets the global Density value.
  29634. * 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.
  29635. * Values less than zero provide a filter of opposite hue.
  29636. */
  29637. globalDensity: number;
  29638. /**
  29639. * Gets the global Saturation value.
  29640. * 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.
  29641. */
  29642. /**
  29643. * Sets the global Saturation value.
  29644. * 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.
  29645. */
  29646. globalSaturation: number;
  29647. /**
  29648. * Gets the global Exposure value.
  29649. * 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.
  29650. */
  29651. /**
  29652. * Sets the global Exposure value.
  29653. * 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.
  29654. */
  29655. globalExposure: number;
  29656. private _highlightsHue;
  29657. private _highlightsDensity;
  29658. private _highlightsSaturation;
  29659. private _highlightsExposure;
  29660. /**
  29661. * Gets the highlights Hue value.
  29662. * 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).
  29663. */
  29664. /**
  29665. * Sets the highlights Hue value.
  29666. * 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).
  29667. */
  29668. highlightsHue: number;
  29669. /**
  29670. * Gets the highlights Density value.
  29671. * 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.
  29672. * Values less than zero provide a filter of opposite hue.
  29673. */
  29674. /**
  29675. * Sets the highlights Density value.
  29676. * 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.
  29677. * Values less than zero provide a filter of opposite hue.
  29678. */
  29679. highlightsDensity: number;
  29680. /**
  29681. * Gets the highlights Saturation value.
  29682. * 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.
  29683. */
  29684. /**
  29685. * Sets the highlights Saturation value.
  29686. * 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.
  29687. */
  29688. highlightsSaturation: number;
  29689. /**
  29690. * Gets the highlights Exposure value.
  29691. * 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.
  29692. */
  29693. /**
  29694. * Sets the highlights Exposure value.
  29695. * 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.
  29696. */
  29697. highlightsExposure: number;
  29698. private _midtonesHue;
  29699. private _midtonesDensity;
  29700. private _midtonesSaturation;
  29701. private _midtonesExposure;
  29702. /**
  29703. * Gets the midtones Hue value.
  29704. * 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).
  29705. */
  29706. /**
  29707. * Sets the midtones Hue value.
  29708. * 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).
  29709. */
  29710. midtonesHue: number;
  29711. /**
  29712. * Gets the midtones Density value.
  29713. * 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.
  29714. * Values less than zero provide a filter of opposite hue.
  29715. */
  29716. /**
  29717. * Sets the midtones Density value.
  29718. * 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.
  29719. * Values less than zero provide a filter of opposite hue.
  29720. */
  29721. midtonesDensity: number;
  29722. /**
  29723. * Gets the midtones Saturation value.
  29724. * 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.
  29725. */
  29726. /**
  29727. * Sets the midtones Saturation value.
  29728. * 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.
  29729. */
  29730. midtonesSaturation: number;
  29731. /**
  29732. * Gets the midtones Exposure value.
  29733. * 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.
  29734. */
  29735. /**
  29736. * Sets the midtones Exposure value.
  29737. * 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.
  29738. */
  29739. midtonesExposure: number;
  29740. private _shadowsHue;
  29741. private _shadowsDensity;
  29742. private _shadowsSaturation;
  29743. private _shadowsExposure;
  29744. /**
  29745. * Gets the shadows Hue value.
  29746. * 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).
  29747. */
  29748. /**
  29749. * Sets the shadows Hue value.
  29750. * 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).
  29751. */
  29752. shadowsHue: number;
  29753. /**
  29754. * Gets the shadows Density value.
  29755. * 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.
  29756. * Values less than zero provide a filter of opposite hue.
  29757. */
  29758. /**
  29759. * Sets the shadows Density value.
  29760. * 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.
  29761. * Values less than zero provide a filter of opposite hue.
  29762. */
  29763. shadowsDensity: number;
  29764. /**
  29765. * Gets the shadows Saturation value.
  29766. * 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.
  29767. */
  29768. /**
  29769. * Sets the shadows Saturation value.
  29770. * 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.
  29771. */
  29772. shadowsSaturation: number;
  29773. /**
  29774. * Gets the shadows Exposure value.
  29775. * 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.
  29776. */
  29777. /**
  29778. * Sets the shadows Exposure value.
  29779. * 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.
  29780. */
  29781. shadowsExposure: number;
  29782. /**
  29783. * Returns the class name
  29784. * @returns The class name
  29785. */
  29786. getClassName(): string;
  29787. /**
  29788. * Binds the color curves to the shader.
  29789. * @param colorCurves The color curve to bind
  29790. * @param effect The effect to bind to
  29791. * @param positiveUniform The positive uniform shader parameter
  29792. * @param neutralUniform The neutral uniform shader parameter
  29793. * @param negativeUniform The negative uniform shader parameter
  29794. */
  29795. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29796. /**
  29797. * Prepare the list of uniforms associated with the ColorCurves effects.
  29798. * @param uniformsList The list of uniforms used in the effect
  29799. */
  29800. static PrepareUniforms(uniformsList: string[]): void;
  29801. /**
  29802. * Returns color grading data based on a hue, density, saturation and exposure value.
  29803. * @param filterHue The hue of the color filter.
  29804. * @param filterDensity The density of the color filter.
  29805. * @param saturation The saturation.
  29806. * @param exposure The exposure.
  29807. * @param result The result data container.
  29808. */
  29809. private getColorGradingDataToRef;
  29810. /**
  29811. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29812. * @param value The input slider value in range [-100,100].
  29813. * @returns Adjusted value.
  29814. */
  29815. private static applyColorGradingSliderNonlinear;
  29816. /**
  29817. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29818. * @param hue The hue (H) input.
  29819. * @param saturation The saturation (S) input.
  29820. * @param brightness The brightness (B) input.
  29821. * @result An RGBA color represented as Vector4.
  29822. */
  29823. private static fromHSBToRef;
  29824. /**
  29825. * Returns a value clamped between min and max
  29826. * @param value The value to clamp
  29827. * @param min The minimum of value
  29828. * @param max The maximum of value
  29829. * @returns The clamped value.
  29830. */
  29831. private static clamp;
  29832. /**
  29833. * Clones the current color curve instance.
  29834. * @return The cloned curves
  29835. */
  29836. clone(): ColorCurves;
  29837. /**
  29838. * Serializes the current color curve instance to a json representation.
  29839. * @return a JSON representation
  29840. */
  29841. serialize(): any;
  29842. /**
  29843. * Parses the color curve from a json representation.
  29844. * @param source the JSON source to parse
  29845. * @return The parsed curves
  29846. */
  29847. static Parse(source: any): ColorCurves;
  29848. }
  29849. }
  29850. declare module BABYLON {
  29851. /**
  29852. * Interface to follow in your material defines to integrate easily the
  29853. * Image proccessing functions.
  29854. * @hidden
  29855. */
  29856. export interface IImageProcessingConfigurationDefines {
  29857. IMAGEPROCESSING: boolean;
  29858. VIGNETTE: boolean;
  29859. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29860. VIGNETTEBLENDMODEOPAQUE: boolean;
  29861. TONEMAPPING: boolean;
  29862. TONEMAPPING_ACES: boolean;
  29863. CONTRAST: boolean;
  29864. EXPOSURE: boolean;
  29865. COLORCURVES: boolean;
  29866. COLORGRADING: boolean;
  29867. COLORGRADING3D: boolean;
  29868. SAMPLER3DGREENDEPTH: boolean;
  29869. SAMPLER3DBGRMAP: boolean;
  29870. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29871. }
  29872. /**
  29873. * @hidden
  29874. */
  29875. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29876. IMAGEPROCESSING: boolean;
  29877. VIGNETTE: boolean;
  29878. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29879. VIGNETTEBLENDMODEOPAQUE: boolean;
  29880. TONEMAPPING: boolean;
  29881. TONEMAPPING_ACES: boolean;
  29882. CONTRAST: boolean;
  29883. COLORCURVES: boolean;
  29884. COLORGRADING: boolean;
  29885. COLORGRADING3D: boolean;
  29886. SAMPLER3DGREENDEPTH: boolean;
  29887. SAMPLER3DBGRMAP: boolean;
  29888. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29889. EXPOSURE: boolean;
  29890. constructor();
  29891. }
  29892. /**
  29893. * This groups together the common properties used for image processing either in direct forward pass
  29894. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29895. * or not.
  29896. */
  29897. export class ImageProcessingConfiguration {
  29898. /**
  29899. * Default tone mapping applied in BabylonJS.
  29900. */
  29901. static readonly TONEMAPPING_STANDARD: number;
  29902. /**
  29903. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29904. * to other engines rendering to increase portability.
  29905. */
  29906. static readonly TONEMAPPING_ACES: number;
  29907. /**
  29908. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29909. */
  29910. colorCurves: Nullable<ColorCurves>;
  29911. private _colorCurvesEnabled;
  29912. /**
  29913. * Gets wether the color curves effect is enabled.
  29914. */
  29915. /**
  29916. * Sets wether the color curves effect is enabled.
  29917. */
  29918. colorCurvesEnabled: boolean;
  29919. private _colorGradingTexture;
  29920. /**
  29921. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29922. */
  29923. /**
  29924. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29925. */
  29926. colorGradingTexture: Nullable<BaseTexture>;
  29927. private _colorGradingEnabled;
  29928. /**
  29929. * Gets wether the color grading effect is enabled.
  29930. */
  29931. /**
  29932. * Sets wether the color grading effect is enabled.
  29933. */
  29934. colorGradingEnabled: boolean;
  29935. private _colorGradingWithGreenDepth;
  29936. /**
  29937. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29938. */
  29939. /**
  29940. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29941. */
  29942. colorGradingWithGreenDepth: boolean;
  29943. private _colorGradingBGR;
  29944. /**
  29945. * Gets wether the color grading texture contains BGR values.
  29946. */
  29947. /**
  29948. * Sets wether the color grading texture contains BGR values.
  29949. */
  29950. colorGradingBGR: boolean;
  29951. /** @hidden */
  29952. _exposure: number;
  29953. /**
  29954. * Gets the Exposure used in the effect.
  29955. */
  29956. /**
  29957. * Sets the Exposure used in the effect.
  29958. */
  29959. exposure: number;
  29960. private _toneMappingEnabled;
  29961. /**
  29962. * Gets wether the tone mapping effect is enabled.
  29963. */
  29964. /**
  29965. * Sets wether the tone mapping effect is enabled.
  29966. */
  29967. toneMappingEnabled: boolean;
  29968. private _toneMappingType;
  29969. /**
  29970. * Gets the type of tone mapping effect.
  29971. */
  29972. /**
  29973. * Sets the type of tone mapping effect used in BabylonJS.
  29974. */
  29975. toneMappingType: number;
  29976. protected _contrast: number;
  29977. /**
  29978. * Gets the contrast used in the effect.
  29979. */
  29980. /**
  29981. * Sets the contrast used in the effect.
  29982. */
  29983. contrast: number;
  29984. /**
  29985. * Vignette stretch size.
  29986. */
  29987. vignetteStretch: number;
  29988. /**
  29989. * Vignette centre X Offset.
  29990. */
  29991. vignetteCentreX: number;
  29992. /**
  29993. * Vignette centre Y Offset.
  29994. */
  29995. vignetteCentreY: number;
  29996. /**
  29997. * Vignette weight or intensity of the vignette effect.
  29998. */
  29999. vignetteWeight: number;
  30000. /**
  30001. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30002. * if vignetteEnabled is set to true.
  30003. */
  30004. vignetteColor: Color4;
  30005. /**
  30006. * Camera field of view used by the Vignette effect.
  30007. */
  30008. vignetteCameraFov: number;
  30009. private _vignetteBlendMode;
  30010. /**
  30011. * Gets the vignette blend mode allowing different kind of effect.
  30012. */
  30013. /**
  30014. * Sets the vignette blend mode allowing different kind of effect.
  30015. */
  30016. vignetteBlendMode: number;
  30017. private _vignetteEnabled;
  30018. /**
  30019. * Gets wether the vignette effect is enabled.
  30020. */
  30021. /**
  30022. * Sets wether the vignette effect is enabled.
  30023. */
  30024. vignetteEnabled: boolean;
  30025. private _applyByPostProcess;
  30026. /**
  30027. * Gets wether the image processing is applied through a post process or not.
  30028. */
  30029. /**
  30030. * Sets wether the image processing is applied through a post process or not.
  30031. */
  30032. applyByPostProcess: boolean;
  30033. private _isEnabled;
  30034. /**
  30035. * Gets wether the image processing is enabled or not.
  30036. */
  30037. /**
  30038. * Sets wether the image processing is enabled or not.
  30039. */
  30040. isEnabled: boolean;
  30041. /**
  30042. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30043. */
  30044. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30045. /**
  30046. * Method called each time the image processing information changes requires to recompile the effect.
  30047. */
  30048. protected _updateParameters(): void;
  30049. /**
  30050. * Gets the current class name.
  30051. * @return "ImageProcessingConfiguration"
  30052. */
  30053. getClassName(): string;
  30054. /**
  30055. * Prepare the list of uniforms associated with the Image Processing effects.
  30056. * @param uniforms The list of uniforms used in the effect
  30057. * @param defines the list of defines currently in use
  30058. */
  30059. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30060. /**
  30061. * Prepare the list of samplers associated with the Image Processing effects.
  30062. * @param samplersList The list of uniforms used in the effect
  30063. * @param defines the list of defines currently in use
  30064. */
  30065. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30066. /**
  30067. * Prepare the list of defines associated to the shader.
  30068. * @param defines the list of defines to complete
  30069. * @param forPostProcess Define if we are currently in post process mode or not
  30070. */
  30071. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30072. /**
  30073. * Returns true if all the image processing information are ready.
  30074. * @returns True if ready, otherwise, false
  30075. */
  30076. isReady(): boolean;
  30077. /**
  30078. * Binds the image processing to the shader.
  30079. * @param effect The effect to bind to
  30080. * @param aspectRatio Define the current aspect ratio of the effect
  30081. */
  30082. bind(effect: Effect, aspectRatio?: number): void;
  30083. /**
  30084. * Clones the current image processing instance.
  30085. * @return The cloned image processing
  30086. */
  30087. clone(): ImageProcessingConfiguration;
  30088. /**
  30089. * Serializes the current image processing instance to a json representation.
  30090. * @return a JSON representation
  30091. */
  30092. serialize(): any;
  30093. /**
  30094. * Parses the image processing from a json representation.
  30095. * @param source the JSON source to parse
  30096. * @return The parsed image processing
  30097. */
  30098. static Parse(source: any): ImageProcessingConfiguration;
  30099. private static _VIGNETTEMODE_MULTIPLY;
  30100. private static _VIGNETTEMODE_OPAQUE;
  30101. /**
  30102. * Used to apply the vignette as a mix with the pixel color.
  30103. */
  30104. static readonly VIGNETTEMODE_MULTIPLY: number;
  30105. /**
  30106. * Used to apply the vignette as a replacement of the pixel color.
  30107. */
  30108. static readonly VIGNETTEMODE_OPAQUE: number;
  30109. }
  30110. }
  30111. declare module BABYLON {
  30112. /**
  30113. * This represents all the required information to add a fresnel effect on a material:
  30114. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30115. */
  30116. export class FresnelParameters {
  30117. private _isEnabled;
  30118. /**
  30119. * Define if the fresnel effect is enable or not.
  30120. */
  30121. isEnabled: boolean;
  30122. /**
  30123. * Define the color used on edges (grazing angle)
  30124. */
  30125. leftColor: Color3;
  30126. /**
  30127. * Define the color used on center
  30128. */
  30129. rightColor: Color3;
  30130. /**
  30131. * Define bias applied to computed fresnel term
  30132. */
  30133. bias: number;
  30134. /**
  30135. * Defined the power exponent applied to fresnel term
  30136. */
  30137. power: number;
  30138. /**
  30139. * Clones the current fresnel and its valuues
  30140. * @returns a clone fresnel configuration
  30141. */
  30142. clone(): FresnelParameters;
  30143. /**
  30144. * Serializes the current fresnel parameters to a JSON representation.
  30145. * @return the JSON serialization
  30146. */
  30147. serialize(): any;
  30148. /**
  30149. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30150. * @param parsedFresnelParameters Define the JSON representation
  30151. * @returns the parsed parameters
  30152. */
  30153. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30154. }
  30155. }
  30156. declare module BABYLON {
  30157. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30158. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30159. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30160. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30161. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30162. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30163. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30164. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30165. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30166. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30167. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30168. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30169. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30170. /**
  30171. * Decorator used to define property that can be serialized as reference to a camera
  30172. * @param sourceName defines the name of the property to decorate
  30173. */
  30174. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30175. /**
  30176. * Class used to help serialization objects
  30177. */
  30178. export class SerializationHelper {
  30179. /** hidden */
  30180. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30181. /** hidden */
  30182. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30183. /** hidden */
  30184. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30185. /** hidden */
  30186. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30187. /**
  30188. * Appends the serialized animations from the source animations
  30189. * @param source Source containing the animations
  30190. * @param destination Target to store the animations
  30191. */
  30192. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30193. /**
  30194. * Static function used to serialized a specific entity
  30195. * @param entity defines the entity to serialize
  30196. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30197. * @returns a JSON compatible object representing the serialization of the entity
  30198. */
  30199. static Serialize<T>(entity: T, serializationObject?: any): any;
  30200. /**
  30201. * Creates a new entity from a serialization data object
  30202. * @param creationFunction defines a function used to instanciated the new entity
  30203. * @param source defines the source serialization data
  30204. * @param scene defines the hosting scene
  30205. * @param rootUrl defines the root url for resources
  30206. * @returns a new entity
  30207. */
  30208. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30209. /**
  30210. * Clones an object
  30211. * @param creationFunction defines the function used to instanciate the new object
  30212. * @param source defines the source object
  30213. * @returns the cloned object
  30214. */
  30215. static Clone<T>(creationFunction: () => T, source: T): T;
  30216. /**
  30217. * Instanciates a new object based on a source one (some data will be shared between both object)
  30218. * @param creationFunction defines the function used to instanciate the new object
  30219. * @param source defines the source object
  30220. * @returns the new object
  30221. */
  30222. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30223. }
  30224. }
  30225. declare module BABYLON {
  30226. /**
  30227. * This is the base class of all the camera used in the application.
  30228. * @see http://doc.babylonjs.com/features/cameras
  30229. */
  30230. export class Camera extends Node {
  30231. /** @hidden */
  30232. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30233. /**
  30234. * This is the default projection mode used by the cameras.
  30235. * It helps recreating a feeling of perspective and better appreciate depth.
  30236. * This is the best way to simulate real life cameras.
  30237. */
  30238. static readonly PERSPECTIVE_CAMERA: number;
  30239. /**
  30240. * This helps creating camera with an orthographic mode.
  30241. * 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.
  30242. */
  30243. static readonly ORTHOGRAPHIC_CAMERA: number;
  30244. /**
  30245. * This is the default FOV mode for perspective cameras.
  30246. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30247. */
  30248. static readonly FOVMODE_VERTICAL_FIXED: number;
  30249. /**
  30250. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30251. */
  30252. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30253. /**
  30254. * This specifies ther is no need for a camera rig.
  30255. * Basically only one eye is rendered corresponding to the camera.
  30256. */
  30257. static readonly RIG_MODE_NONE: number;
  30258. /**
  30259. * Simulates a camera Rig with one blue eye and one red eye.
  30260. * This can be use with 3d blue and red glasses.
  30261. */
  30262. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30263. /**
  30264. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30265. */
  30266. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30267. /**
  30268. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30269. */
  30270. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30271. /**
  30272. * Defines that both eyes of the camera will be rendered over under each other.
  30273. */
  30274. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30275. /**
  30276. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30277. */
  30278. static readonly RIG_MODE_VR: number;
  30279. /**
  30280. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30281. */
  30282. static readonly RIG_MODE_WEBVR: number;
  30283. /**
  30284. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30285. */
  30286. static readonly RIG_MODE_CUSTOM: number;
  30287. /**
  30288. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30289. */
  30290. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30291. /**
  30292. * Define the input manager associated with the camera.
  30293. */
  30294. inputs: CameraInputsManager<Camera>;
  30295. /** @hidden */
  30296. _position: Vector3;
  30297. /**
  30298. * Define the current local position of the camera in the scene
  30299. */
  30300. position: Vector3;
  30301. /**
  30302. * The vector the camera should consider as up.
  30303. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30304. */
  30305. upVector: Vector3;
  30306. /**
  30307. * Define the current limit on the left side for an orthographic camera
  30308. * In scene unit
  30309. */
  30310. orthoLeft: Nullable<number>;
  30311. /**
  30312. * Define the current limit on the right side for an orthographic camera
  30313. * In scene unit
  30314. */
  30315. orthoRight: Nullable<number>;
  30316. /**
  30317. * Define the current limit on the bottom side for an orthographic camera
  30318. * In scene unit
  30319. */
  30320. orthoBottom: Nullable<number>;
  30321. /**
  30322. * Define the current limit on the top side for an orthographic camera
  30323. * In scene unit
  30324. */
  30325. orthoTop: Nullable<number>;
  30326. /**
  30327. * Field Of View is set in Radians. (default is 0.8)
  30328. */
  30329. fov: number;
  30330. /**
  30331. * Define the minimum distance the camera can see from.
  30332. * This is important to note that the depth buffer are not infinite and the closer it starts
  30333. * the more your scene might encounter depth fighting issue.
  30334. */
  30335. minZ: number;
  30336. /**
  30337. * Define the maximum distance the camera can see to.
  30338. * This is important to note that the depth buffer are not infinite and the further it end
  30339. * the more your scene might encounter depth fighting issue.
  30340. */
  30341. maxZ: number;
  30342. /**
  30343. * Define the default inertia of the camera.
  30344. * This helps giving a smooth feeling to the camera movement.
  30345. */
  30346. inertia: number;
  30347. /**
  30348. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30349. */
  30350. mode: number;
  30351. /**
  30352. * Define wether the camera is intermediate.
  30353. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30354. */
  30355. isIntermediate: boolean;
  30356. /**
  30357. * Define the viewport of the camera.
  30358. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30359. */
  30360. viewport: Viewport;
  30361. /**
  30362. * Restricts the camera to viewing objects with the same layerMask.
  30363. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30364. */
  30365. layerMask: number;
  30366. /**
  30367. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30368. */
  30369. fovMode: number;
  30370. /**
  30371. * Rig mode of the camera.
  30372. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30373. * This is normally controlled byt the camera themselves as internal use.
  30374. */
  30375. cameraRigMode: number;
  30376. /**
  30377. * Defines the distance between both "eyes" in case of a RIG
  30378. */
  30379. interaxialDistance: number;
  30380. /**
  30381. * Defines if stereoscopic rendering is done side by side or over under.
  30382. */
  30383. isStereoscopicSideBySide: boolean;
  30384. /**
  30385. * 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
  30386. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30387. * else in the scene.
  30388. */
  30389. customRenderTargets: RenderTargetTexture[];
  30390. /**
  30391. * When set, the camera will render to this render target instead of the default canvas
  30392. */
  30393. outputRenderTarget: Nullable<RenderTargetTexture>;
  30394. /**
  30395. * Observable triggered when the camera view matrix has changed.
  30396. */
  30397. onViewMatrixChangedObservable: Observable<Camera>;
  30398. /**
  30399. * Observable triggered when the camera Projection matrix has changed.
  30400. */
  30401. onProjectionMatrixChangedObservable: Observable<Camera>;
  30402. /**
  30403. * Observable triggered when the inputs have been processed.
  30404. */
  30405. onAfterCheckInputsObservable: Observable<Camera>;
  30406. /**
  30407. * Observable triggered when reset has been called and applied to the camera.
  30408. */
  30409. onRestoreStateObservable: Observable<Camera>;
  30410. /** @hidden */
  30411. _cameraRigParams: any;
  30412. /** @hidden */
  30413. _rigCameras: Camera[];
  30414. /** @hidden */
  30415. _rigPostProcess: Nullable<PostProcess>;
  30416. protected _webvrViewMatrix: Matrix;
  30417. /** @hidden */
  30418. _skipRendering: boolean;
  30419. /** @hidden */
  30420. _projectionMatrix: Matrix;
  30421. /** @hidden */
  30422. _postProcesses: Nullable<PostProcess>[];
  30423. /** @hidden */
  30424. _activeMeshes: SmartArray<AbstractMesh>;
  30425. protected _globalPosition: Vector3;
  30426. /** hidden */
  30427. _computedViewMatrix: Matrix;
  30428. private _doNotComputeProjectionMatrix;
  30429. private _transformMatrix;
  30430. private _frustumPlanes;
  30431. private _refreshFrustumPlanes;
  30432. private _storedFov;
  30433. private _stateStored;
  30434. /**
  30435. * Instantiates a new camera object.
  30436. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30437. * @see http://doc.babylonjs.com/features/cameras
  30438. * @param name Defines the name of the camera in the scene
  30439. * @param position Defines the position of the camera
  30440. * @param scene Defines the scene the camera belongs too
  30441. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30442. */
  30443. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30444. /**
  30445. * Store current camera state (fov, position, etc..)
  30446. * @returns the camera
  30447. */
  30448. storeState(): Camera;
  30449. /**
  30450. * Restores the camera state values if it has been stored. You must call storeState() first
  30451. */
  30452. protected _restoreStateValues(): boolean;
  30453. /**
  30454. * Restored camera state. You must call storeState() first.
  30455. * @returns true if restored and false otherwise
  30456. */
  30457. restoreState(): boolean;
  30458. /**
  30459. * Gets the class name of the camera.
  30460. * @returns the class name
  30461. */
  30462. getClassName(): string;
  30463. /** @hidden */
  30464. readonly _isCamera: boolean;
  30465. /**
  30466. * Gets a string representation of the camera useful for debug purpose.
  30467. * @param fullDetails Defines that a more verboe level of logging is required
  30468. * @returns the string representation
  30469. */
  30470. toString(fullDetails?: boolean): string;
  30471. /**
  30472. * Gets the current world space position of the camera.
  30473. */
  30474. readonly globalPosition: Vector3;
  30475. /**
  30476. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30477. * @returns the active meshe list
  30478. */
  30479. getActiveMeshes(): SmartArray<AbstractMesh>;
  30480. /**
  30481. * Check wether a mesh is part of the current active mesh list of the camera
  30482. * @param mesh Defines the mesh to check
  30483. * @returns true if active, false otherwise
  30484. */
  30485. isActiveMesh(mesh: Mesh): boolean;
  30486. /**
  30487. * Is this camera ready to be used/rendered
  30488. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30489. * @return true if the camera is ready
  30490. */
  30491. isReady(completeCheck?: boolean): boolean;
  30492. /** @hidden */
  30493. _initCache(): void;
  30494. /** @hidden */
  30495. _updateCache(ignoreParentClass?: boolean): void;
  30496. /** @hidden */
  30497. _isSynchronized(): boolean;
  30498. /** @hidden */
  30499. _isSynchronizedViewMatrix(): boolean;
  30500. /** @hidden */
  30501. _isSynchronizedProjectionMatrix(): boolean;
  30502. /**
  30503. * Attach the input controls to a specific dom element to get the input from.
  30504. * @param element Defines the element the controls should be listened from
  30505. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30506. */
  30507. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30508. /**
  30509. * Detach the current controls from the specified dom element.
  30510. * @param element Defines the element to stop listening the inputs from
  30511. */
  30512. detachControl(element: HTMLElement): void;
  30513. /**
  30514. * Update the camera state according to the different inputs gathered during the frame.
  30515. */
  30516. update(): void;
  30517. /** @hidden */
  30518. _checkInputs(): void;
  30519. /** @hidden */
  30520. readonly rigCameras: Camera[];
  30521. /**
  30522. * Gets the post process used by the rig cameras
  30523. */
  30524. readonly rigPostProcess: Nullable<PostProcess>;
  30525. /**
  30526. * Internal, gets the first post proces.
  30527. * @returns the first post process to be run on this camera.
  30528. */
  30529. _getFirstPostProcess(): Nullable<PostProcess>;
  30530. private _cascadePostProcessesToRigCams;
  30531. /**
  30532. * Attach a post process to the camera.
  30533. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30534. * @param postProcess The post process to attach to the camera
  30535. * @param insertAt The position of the post process in case several of them are in use in the scene
  30536. * @returns the position the post process has been inserted at
  30537. */
  30538. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30539. /**
  30540. * Detach a post process to the camera.
  30541. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30542. * @param postProcess The post process to detach from the camera
  30543. */
  30544. detachPostProcess(postProcess: PostProcess): void;
  30545. /**
  30546. * Gets the current world matrix of the camera
  30547. */
  30548. getWorldMatrix(): Matrix;
  30549. /** @hidden */
  30550. _getViewMatrix(): Matrix;
  30551. /**
  30552. * Gets the current view matrix of the camera.
  30553. * @param force forces the camera to recompute the matrix without looking at the cached state
  30554. * @returns the view matrix
  30555. */
  30556. getViewMatrix(force?: boolean): Matrix;
  30557. /**
  30558. * Freeze the projection matrix.
  30559. * It will prevent the cache check of the camera projection compute and can speed up perf
  30560. * if no parameter of the camera are meant to change
  30561. * @param projection Defines manually a projection if necessary
  30562. */
  30563. freezeProjectionMatrix(projection?: Matrix): void;
  30564. /**
  30565. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30566. */
  30567. unfreezeProjectionMatrix(): void;
  30568. /**
  30569. * Gets the current projection matrix of the camera.
  30570. * @param force forces the camera to recompute the matrix without looking at the cached state
  30571. * @returns the projection matrix
  30572. */
  30573. getProjectionMatrix(force?: boolean): Matrix;
  30574. /**
  30575. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30576. * @returns a Matrix
  30577. */
  30578. getTransformationMatrix(): Matrix;
  30579. private _updateFrustumPlanes;
  30580. /**
  30581. * Checks if a cullable object (mesh...) is in the camera frustum
  30582. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30583. * @param target The object to check
  30584. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30585. * @returns true if the object is in frustum otherwise false
  30586. */
  30587. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30588. /**
  30589. * Checks if a cullable object (mesh...) is in the camera frustum
  30590. * Unlike isInFrustum this cheks the full bounding box
  30591. * @param target The object to check
  30592. * @returns true if the object is in frustum otherwise false
  30593. */
  30594. isCompletelyInFrustum(target: ICullable): boolean;
  30595. /**
  30596. * Gets a ray in the forward direction from the camera.
  30597. * @param length Defines the length of the ray to create
  30598. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30599. * @param origin Defines the start point of the ray which defaults to the camera position
  30600. * @returns the forward ray
  30601. */
  30602. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30603. /**
  30604. * Releases resources associated with this node.
  30605. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30606. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30607. */
  30608. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30609. /** @hidden */
  30610. _isLeftCamera: boolean;
  30611. /**
  30612. * Gets the left camera of a rig setup in case of Rigged Camera
  30613. */
  30614. readonly isLeftCamera: boolean;
  30615. /** @hidden */
  30616. _isRightCamera: boolean;
  30617. /**
  30618. * Gets the right camera of a rig setup in case of Rigged Camera
  30619. */
  30620. readonly isRightCamera: boolean;
  30621. /**
  30622. * Gets the left camera of a rig setup in case of Rigged Camera
  30623. */
  30624. readonly leftCamera: Nullable<FreeCamera>;
  30625. /**
  30626. * Gets the right camera of a rig setup in case of Rigged Camera
  30627. */
  30628. readonly rightCamera: Nullable<FreeCamera>;
  30629. /**
  30630. * Gets the left camera target of a rig setup in case of Rigged Camera
  30631. * @returns the target position
  30632. */
  30633. getLeftTarget(): Nullable<Vector3>;
  30634. /**
  30635. * Gets the right camera target of a rig setup in case of Rigged Camera
  30636. * @returns the target position
  30637. */
  30638. getRightTarget(): Nullable<Vector3>;
  30639. /**
  30640. * @hidden
  30641. */
  30642. setCameraRigMode(mode: number, rigParams: any): void;
  30643. /** @hidden */
  30644. static _setStereoscopicRigMode(camera: Camera): void;
  30645. /** @hidden */
  30646. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30647. /** @hidden */
  30648. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30649. /** @hidden */
  30650. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30651. /** @hidden */
  30652. _getVRProjectionMatrix(): Matrix;
  30653. protected _updateCameraRotationMatrix(): void;
  30654. protected _updateWebVRCameraRotationMatrix(): void;
  30655. /**
  30656. * This function MUST be overwritten by the different WebVR cameras available.
  30657. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30658. * @hidden
  30659. */
  30660. _getWebVRProjectionMatrix(): Matrix;
  30661. /**
  30662. * This function MUST be overwritten by the different WebVR cameras available.
  30663. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30664. * @hidden
  30665. */
  30666. _getWebVRViewMatrix(): Matrix;
  30667. /** @hidden */
  30668. setCameraRigParameter(name: string, value: any): void;
  30669. /**
  30670. * needs to be overridden by children so sub has required properties to be copied
  30671. * @hidden
  30672. */
  30673. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30674. /**
  30675. * May need to be overridden by children
  30676. * @hidden
  30677. */
  30678. _updateRigCameras(): void;
  30679. /** @hidden */
  30680. _setupInputs(): void;
  30681. /**
  30682. * Serialiaze the camera setup to a json represention
  30683. * @returns the JSON representation
  30684. */
  30685. serialize(): any;
  30686. /**
  30687. * Clones the current camera.
  30688. * @param name The cloned camera name
  30689. * @returns the cloned camera
  30690. */
  30691. clone(name: string): Camera;
  30692. /**
  30693. * Gets the direction of the camera relative to a given local axis.
  30694. * @param localAxis Defines the reference axis to provide a relative direction.
  30695. * @return the direction
  30696. */
  30697. getDirection(localAxis: Vector3): Vector3;
  30698. /**
  30699. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30700. * @param localAxis Defines the reference axis to provide a relative direction.
  30701. * @param result Defines the vector to store the result in
  30702. */
  30703. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30704. /**
  30705. * Gets a camera constructor for a given camera type
  30706. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30707. * @param name The name of the camera the result will be able to instantiate
  30708. * @param scene The scene the result will construct the camera in
  30709. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30710. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30711. * @returns a factory method to construc the camera
  30712. */
  30713. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30714. /**
  30715. * Compute the world matrix of the camera.
  30716. * @returns the camera workd matrix
  30717. */
  30718. computeWorldMatrix(): Matrix;
  30719. /**
  30720. * Parse a JSON and creates the camera from the parsed information
  30721. * @param parsedCamera The JSON to parse
  30722. * @param scene The scene to instantiate the camera in
  30723. * @returns the newly constructed camera
  30724. */
  30725. static Parse(parsedCamera: any, scene: Scene): Camera;
  30726. }
  30727. }
  30728. declare module BABYLON {
  30729. /**
  30730. * Interface for any object that can request an animation frame
  30731. */
  30732. export interface ICustomAnimationFrameRequester {
  30733. /**
  30734. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30735. */
  30736. renderFunction?: Function;
  30737. /**
  30738. * Called to request the next frame to render to
  30739. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30740. */
  30741. requestAnimationFrame: Function;
  30742. /**
  30743. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30744. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30745. */
  30746. requestID?: number;
  30747. }
  30748. /**
  30749. * Interface containing an array of animations
  30750. */
  30751. export interface IAnimatable {
  30752. /**
  30753. * Array of animations
  30754. */
  30755. animations: Nullable<Array<Animation>>;
  30756. }
  30757. /** Interface used by value gradients (color, factor, ...) */
  30758. export interface IValueGradient {
  30759. /**
  30760. * Gets or sets the gradient value (between 0 and 1)
  30761. */
  30762. gradient: number;
  30763. }
  30764. /** Class used to store color4 gradient */
  30765. export class ColorGradient implements IValueGradient {
  30766. /**
  30767. * Gets or sets the gradient value (between 0 and 1)
  30768. */
  30769. gradient: number;
  30770. /**
  30771. * Gets or sets first associated color
  30772. */
  30773. color1: Color4;
  30774. /**
  30775. * Gets or sets second associated color
  30776. */
  30777. color2?: Color4;
  30778. /**
  30779. * Will get a color picked randomly between color1 and color2.
  30780. * If color2 is undefined then color1 will be used
  30781. * @param result defines the target Color4 to store the result in
  30782. */
  30783. getColorToRef(result: Color4): void;
  30784. }
  30785. /** Class used to store color 3 gradient */
  30786. export class Color3Gradient implements IValueGradient {
  30787. /**
  30788. * Gets or sets the gradient value (between 0 and 1)
  30789. */
  30790. gradient: number;
  30791. /**
  30792. * Gets or sets the associated color
  30793. */
  30794. color: Color3;
  30795. }
  30796. /** Class used to store factor gradient */
  30797. export class FactorGradient implements IValueGradient {
  30798. /**
  30799. * Gets or sets the gradient value (between 0 and 1)
  30800. */
  30801. gradient: number;
  30802. /**
  30803. * Gets or sets first associated factor
  30804. */
  30805. factor1: number;
  30806. /**
  30807. * Gets or sets second associated factor
  30808. */
  30809. factor2?: number;
  30810. /**
  30811. * Will get a number picked randomly between factor1 and factor2.
  30812. * If factor2 is undefined then factor1 will be used
  30813. * @returns the picked number
  30814. */
  30815. getFactor(): number;
  30816. }
  30817. /**
  30818. * @ignore
  30819. * Application error to support additional information when loading a file
  30820. */
  30821. export class LoadFileError extends Error {
  30822. /** defines the optional web request */
  30823. request?: WebRequest | undefined;
  30824. private static _setPrototypeOf;
  30825. /**
  30826. * Creates a new LoadFileError
  30827. * @param message defines the message of the error
  30828. * @param request defines the optional web request
  30829. */
  30830. constructor(message: string,
  30831. /** defines the optional web request */
  30832. request?: WebRequest | undefined);
  30833. }
  30834. /**
  30835. * Class used to define a retry strategy when error happens while loading assets
  30836. */
  30837. export class RetryStrategy {
  30838. /**
  30839. * Function used to defines an exponential back off strategy
  30840. * @param maxRetries defines the maximum number of retries (3 by default)
  30841. * @param baseInterval defines the interval between retries
  30842. * @returns the strategy function to use
  30843. */
  30844. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30845. }
  30846. /**
  30847. * File request interface
  30848. */
  30849. export interface IFileRequest {
  30850. /**
  30851. * Raised when the request is complete (success or error).
  30852. */
  30853. onCompleteObservable: Observable<IFileRequest>;
  30854. /**
  30855. * Aborts the request for a file.
  30856. */
  30857. abort: () => void;
  30858. }
  30859. /**
  30860. * Class containing a set of static utilities functions
  30861. */
  30862. export class Tools {
  30863. /**
  30864. * Gets or sets the base URL to use to load assets
  30865. */
  30866. static BaseUrl: string;
  30867. /**
  30868. * Enable/Disable Custom HTTP Request Headers globally.
  30869. * default = false
  30870. * @see CustomRequestHeaders
  30871. */
  30872. static UseCustomRequestHeaders: boolean;
  30873. /**
  30874. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30875. * i.e. when loading files, where the server/service expects an Authorization header
  30876. */
  30877. static CustomRequestHeaders: {
  30878. [key: string]: string;
  30879. };
  30880. /**
  30881. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30882. */
  30883. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30884. /**
  30885. * Default behaviour for cors in the application.
  30886. * It can be a string if the expected behavior is identical in the entire app.
  30887. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30888. */
  30889. static CorsBehavior: string | ((url: string | string[]) => string);
  30890. /**
  30891. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30892. * @ignorenaming
  30893. */
  30894. static UseFallbackTexture: boolean;
  30895. /**
  30896. * Use this object to register external classes like custom textures or material
  30897. * to allow the laoders to instantiate them
  30898. */
  30899. static RegisteredExternalClasses: {
  30900. [key: string]: Object;
  30901. };
  30902. /**
  30903. * Texture content used if a texture cannot loaded
  30904. * @ignorenaming
  30905. */
  30906. static fallbackTexture: string;
  30907. /**
  30908. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30909. * @param u defines the coordinate on X axis
  30910. * @param v defines the coordinate on Y axis
  30911. * @param width defines the width of the source data
  30912. * @param height defines the height of the source data
  30913. * @param pixels defines the source byte array
  30914. * @param color defines the output color
  30915. */
  30916. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30917. /**
  30918. * Interpolates between a and b via alpha
  30919. * @param a The lower value (returned when alpha = 0)
  30920. * @param b The upper value (returned when alpha = 1)
  30921. * @param alpha The interpolation-factor
  30922. * @return The mixed value
  30923. */
  30924. static Mix(a: number, b: number, alpha: number): number;
  30925. /**
  30926. * Tries to instantiate a new object from a given class name
  30927. * @param className defines the class name to instantiate
  30928. * @returns the new object or null if the system was not able to do the instantiation
  30929. */
  30930. static Instantiate(className: string): any;
  30931. /**
  30932. * Provides a slice function that will work even on IE
  30933. * @param data defines the array to slice
  30934. * @param start defines the start of the data (optional)
  30935. * @param end defines the end of the data (optional)
  30936. * @returns the new sliced array
  30937. */
  30938. static Slice<T>(data: T, start?: number, end?: number): T;
  30939. /**
  30940. * Polyfill for setImmediate
  30941. * @param action defines the action to execute after the current execution block
  30942. */
  30943. static SetImmediate(action: () => void): void;
  30944. /**
  30945. * Function indicating if a number is an exponent of 2
  30946. * @param value defines the value to test
  30947. * @returns true if the value is an exponent of 2
  30948. */
  30949. static IsExponentOfTwo(value: number): boolean;
  30950. private static _tmpFloatArray;
  30951. /**
  30952. * Returns the nearest 32-bit single precision float representation of a Number
  30953. * @param value A Number. If the parameter is of a different type, it will get converted
  30954. * to a number or to NaN if it cannot be converted
  30955. * @returns number
  30956. */
  30957. static FloatRound(value: number): number;
  30958. /**
  30959. * Find the next highest power of two.
  30960. * @param x Number to start search from.
  30961. * @return Next highest power of two.
  30962. */
  30963. static CeilingPOT(x: number): number;
  30964. /**
  30965. * Find the next lowest power of two.
  30966. * @param x Number to start search from.
  30967. * @return Next lowest power of two.
  30968. */
  30969. static FloorPOT(x: number): number;
  30970. /**
  30971. * Find the nearest power of two.
  30972. * @param x Number to start search from.
  30973. * @return Next nearest power of two.
  30974. */
  30975. static NearestPOT(x: number): number;
  30976. /**
  30977. * Get the closest exponent of two
  30978. * @param value defines the value to approximate
  30979. * @param max defines the maximum value to return
  30980. * @param mode defines how to define the closest value
  30981. * @returns closest exponent of two of the given value
  30982. */
  30983. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30984. /**
  30985. * Extracts the filename from a path
  30986. * @param path defines the path to use
  30987. * @returns the filename
  30988. */
  30989. static GetFilename(path: string): string;
  30990. /**
  30991. * Extracts the "folder" part of a path (everything before the filename).
  30992. * @param uri The URI to extract the info from
  30993. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30994. * @returns The "folder" part of the path
  30995. */
  30996. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30997. /**
  30998. * Extracts text content from a DOM element hierarchy
  30999. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31000. */
  31001. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31002. /**
  31003. * Convert an angle in radians to degrees
  31004. * @param angle defines the angle to convert
  31005. * @returns the angle in degrees
  31006. */
  31007. static ToDegrees(angle: number): number;
  31008. /**
  31009. * Convert an angle in degrees to radians
  31010. * @param angle defines the angle to convert
  31011. * @returns the angle in radians
  31012. */
  31013. static ToRadians(angle: number): number;
  31014. /**
  31015. * Encode a buffer to a base64 string
  31016. * @param buffer defines the buffer to encode
  31017. * @returns the encoded string
  31018. */
  31019. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31020. /**
  31021. * Extracts minimum and maximum values from a list of indexed positions
  31022. * @param positions defines the positions to use
  31023. * @param indices defines the indices to the positions
  31024. * @param indexStart defines the start index
  31025. * @param indexCount defines the end index
  31026. * @param bias defines bias value to add to the result
  31027. * @return minimum and maximum values
  31028. */
  31029. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31030. minimum: Vector3;
  31031. maximum: Vector3;
  31032. };
  31033. /**
  31034. * Extracts minimum and maximum values from a list of positions
  31035. * @param positions defines the positions to use
  31036. * @param start defines the start index in the positions array
  31037. * @param count defines the number of positions to handle
  31038. * @param bias defines bias value to add to the result
  31039. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31040. * @return minimum and maximum values
  31041. */
  31042. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31043. minimum: Vector3;
  31044. maximum: Vector3;
  31045. };
  31046. /**
  31047. * Returns an array if obj is not an array
  31048. * @param obj defines the object to evaluate as an array
  31049. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31050. * @returns either obj directly if obj is an array or a new array containing obj
  31051. */
  31052. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31053. /**
  31054. * Gets the pointer prefix to use
  31055. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31056. */
  31057. static GetPointerPrefix(): string;
  31058. /**
  31059. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31060. * @param func - the function to be called
  31061. * @param requester - the object that will request the next frame. Falls back to window.
  31062. * @returns frame number
  31063. */
  31064. static QueueNewFrame(func: () => void, requester?: any): number;
  31065. /**
  31066. * Ask the browser to promote the current element to fullscreen rendering mode
  31067. * @param element defines the DOM element to promote
  31068. */
  31069. static RequestFullscreen(element: HTMLElement): void;
  31070. /**
  31071. * Asks the browser to exit fullscreen mode
  31072. */
  31073. static ExitFullscreen(): void;
  31074. /**
  31075. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31076. * @param url define the url we are trying
  31077. * @param element define the dom element where to configure the cors policy
  31078. */
  31079. static SetCorsBehavior(url: string | string[], element: {
  31080. crossOrigin: string | null;
  31081. }): void;
  31082. /**
  31083. * Removes unwanted characters from an url
  31084. * @param url defines the url to clean
  31085. * @returns the cleaned url
  31086. */
  31087. static CleanUrl(url: string): string;
  31088. /**
  31089. * Gets or sets a function used to pre-process url before using them to load assets
  31090. */
  31091. static PreprocessUrl: (url: string) => string;
  31092. /**
  31093. * Loads an image as an HTMLImageElement.
  31094. * @param input url string, ArrayBuffer, or Blob to load
  31095. * @param onLoad callback called when the image successfully loads
  31096. * @param onError callback called when the image fails to load
  31097. * @param offlineProvider offline provider for caching
  31098. * @returns the HTMLImageElement of the loaded image
  31099. */
  31100. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31101. /**
  31102. * Loads a file
  31103. * @param url url string, ArrayBuffer, or Blob to load
  31104. * @param onSuccess callback called when the file successfully loads
  31105. * @param onProgress callback called while file is loading (if the server supports this mode)
  31106. * @param offlineProvider defines the offline provider for caching
  31107. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31108. * @param onError callback called when the file fails to load
  31109. * @returns a file request object
  31110. */
  31111. 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;
  31112. /**
  31113. * Load a script (identified by an url). When the url returns, the
  31114. * content of this file is added into a new script element, attached to the DOM (body element)
  31115. * @param scriptUrl defines the url of the script to laod
  31116. * @param onSuccess defines the callback called when the script is loaded
  31117. * @param onError defines the callback to call if an error occurs
  31118. * @param scriptId defines the id of the script element
  31119. */
  31120. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31121. /**
  31122. * Load an asynchronous script (identified by an url). When the url returns, the
  31123. * content of this file is added into a new script element, attached to the DOM (body element)
  31124. * @param scriptUrl defines the url of the script to laod
  31125. * @param scriptId defines the id of the script element
  31126. * @returns a promise request object
  31127. */
  31128. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31129. /**
  31130. * Loads a file from a blob
  31131. * @param fileToLoad defines the blob to use
  31132. * @param callback defines the callback to call when data is loaded
  31133. * @param progressCallback defines the callback to call during loading process
  31134. * @returns a file request object
  31135. */
  31136. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31137. /**
  31138. * Loads a file
  31139. * @param fileToLoad defines the file to load
  31140. * @param callback defines the callback to call when data is loaded
  31141. * @param progressCallBack defines the callback to call during loading process
  31142. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31143. * @returns a file request object
  31144. */
  31145. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31146. /**
  31147. * Creates a data url from a given string content
  31148. * @param content defines the content to convert
  31149. * @returns the new data url link
  31150. */
  31151. static FileAsURL(content: string): string;
  31152. /**
  31153. * Format the given number to a specific decimal format
  31154. * @param value defines the number to format
  31155. * @param decimals defines the number of decimals to use
  31156. * @returns the formatted string
  31157. */
  31158. static Format(value: number, decimals?: number): string;
  31159. /**
  31160. * Checks if a given vector is inside a specific range
  31161. * @param v defines the vector to test
  31162. * @param min defines the minimum range
  31163. * @param max defines the maximum range
  31164. */
  31165. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31166. /**
  31167. * Tries to copy an object by duplicating every property
  31168. * @param source defines the source object
  31169. * @param destination defines the target object
  31170. * @param doNotCopyList defines a list of properties to avoid
  31171. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31172. */
  31173. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31174. /**
  31175. * Gets a boolean indicating if the given object has no own property
  31176. * @param obj defines the object to test
  31177. * @returns true if object has no own property
  31178. */
  31179. static IsEmpty(obj: any): boolean;
  31180. /**
  31181. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31182. * @param str Source string
  31183. * @param suffix Suffix to search for in the source string
  31184. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31185. */
  31186. static EndsWith(str: string, suffix: string): boolean;
  31187. /**
  31188. * Function used to register events at window level
  31189. * @param events defines the events to register
  31190. */
  31191. static RegisterTopRootEvents(events: {
  31192. name: string;
  31193. handler: Nullable<(e: FocusEvent) => any>;
  31194. }[]): void;
  31195. /**
  31196. * Function used to unregister events from window level
  31197. * @param events defines the events to unregister
  31198. */
  31199. static UnregisterTopRootEvents(events: {
  31200. name: string;
  31201. handler: Nullable<(e: FocusEvent) => any>;
  31202. }[]): void;
  31203. /**
  31204. * @ignore
  31205. */
  31206. static _ScreenshotCanvas: HTMLCanvasElement;
  31207. /**
  31208. * Dumps the current bound framebuffer
  31209. * @param width defines the rendering width
  31210. * @param height defines the rendering height
  31211. * @param engine defines the hosting engine
  31212. * @param successCallback defines the callback triggered once the data are available
  31213. * @param mimeType defines the mime type of the result
  31214. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31215. */
  31216. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31217. /**
  31218. * Converts the canvas data to blob.
  31219. * This acts as a polyfill for browsers not supporting the to blob function.
  31220. * @param canvas Defines the canvas to extract the data from
  31221. * @param successCallback Defines the callback triggered once the data are available
  31222. * @param mimeType Defines the mime type of the result
  31223. */
  31224. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31225. /**
  31226. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31227. * @param successCallback defines the callback triggered once the data are available
  31228. * @param mimeType defines the mime type of the result
  31229. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31230. */
  31231. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31232. /**
  31233. * Downloads a blob in the browser
  31234. * @param blob defines the blob to download
  31235. * @param fileName defines the name of the downloaded file
  31236. */
  31237. static Download(blob: Blob, fileName: string): void;
  31238. /**
  31239. * Captures a screenshot of the current rendering
  31240. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31241. * @param engine defines the rendering engine
  31242. * @param camera defines the source camera
  31243. * @param size This parameter can be set to a single number or to an object with the
  31244. * following (optional) properties: precision, width, height. If a single number is passed,
  31245. * it will be used for both width and height. If an object is passed, the screenshot size
  31246. * will be derived from the parameters. The precision property is a multiplier allowing
  31247. * rendering at a higher or lower resolution
  31248. * @param successCallback defines the callback receives a single parameter which contains the
  31249. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31250. * src parameter of an <img> to display it
  31251. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31252. * Check your browser for supported MIME types
  31253. */
  31254. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31255. /**
  31256. * Generates an image screenshot from the specified camera.
  31257. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31258. * @param engine The engine to use for rendering
  31259. * @param camera The camera to use for rendering
  31260. * @param size This parameter can be set to a single number or to an object with the
  31261. * following (optional) properties: precision, width, height. If a single number is passed,
  31262. * it will be used for both width and height. If an object is passed, the screenshot size
  31263. * will be derived from the parameters. The precision property is a multiplier allowing
  31264. * rendering at a higher or lower resolution
  31265. * @param successCallback The callback receives a single parameter which contains the
  31266. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31267. * src parameter of an <img> to display it
  31268. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31269. * Check your browser for supported MIME types
  31270. * @param samples Texture samples (default: 1)
  31271. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31272. * @param fileName A name for for the downloaded file.
  31273. */
  31274. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31275. /**
  31276. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31277. * Be aware Math.random() could cause collisions, but:
  31278. * "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"
  31279. * @returns a pseudo random id
  31280. */
  31281. static RandomId(): string;
  31282. /**
  31283. * Test if the given uri is a base64 string
  31284. * @param uri The uri to test
  31285. * @return True if the uri is a base64 string or false otherwise
  31286. */
  31287. static IsBase64(uri: string): boolean;
  31288. /**
  31289. * Decode the given base64 uri.
  31290. * @param uri The uri to decode
  31291. * @return The decoded base64 data.
  31292. */
  31293. static DecodeBase64(uri: string): ArrayBuffer;
  31294. /**
  31295. * Gets the absolute url.
  31296. * @param url the input url
  31297. * @return the absolute url
  31298. */
  31299. static GetAbsoluteUrl(url: string): string;
  31300. /**
  31301. * No log
  31302. */
  31303. static readonly NoneLogLevel: number;
  31304. /**
  31305. * Only message logs
  31306. */
  31307. static readonly MessageLogLevel: number;
  31308. /**
  31309. * Only warning logs
  31310. */
  31311. static readonly WarningLogLevel: number;
  31312. /**
  31313. * Only error logs
  31314. */
  31315. static readonly ErrorLogLevel: number;
  31316. /**
  31317. * All logs
  31318. */
  31319. static readonly AllLogLevel: number;
  31320. /**
  31321. * Gets a value indicating the number of loading errors
  31322. * @ignorenaming
  31323. */
  31324. static readonly errorsCount: number;
  31325. /**
  31326. * Callback called when a new log is added
  31327. */
  31328. static OnNewCacheEntry: (entry: string) => void;
  31329. /**
  31330. * Log a message to the console
  31331. * @param message defines the message to log
  31332. */
  31333. static Log(message: string): void;
  31334. /**
  31335. * Write a warning message to the console
  31336. * @param message defines the message to log
  31337. */
  31338. static Warn(message: string): void;
  31339. /**
  31340. * Write an error message to the console
  31341. * @param message defines the message to log
  31342. */
  31343. static Error(message: string): void;
  31344. /**
  31345. * Gets current log cache (list of logs)
  31346. */
  31347. static readonly LogCache: string;
  31348. /**
  31349. * Clears the log cache
  31350. */
  31351. static ClearLogCache(): void;
  31352. /**
  31353. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31354. */
  31355. static LogLevels: number;
  31356. /**
  31357. * Checks if the loaded document was accessed via `file:`-Protocol.
  31358. * @returns boolean
  31359. */
  31360. static IsFileURL(): boolean;
  31361. /**
  31362. * Checks if the window object exists
  31363. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31364. */
  31365. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31366. /**
  31367. * No performance log
  31368. */
  31369. static readonly PerformanceNoneLogLevel: number;
  31370. /**
  31371. * Use user marks to log performance
  31372. */
  31373. static readonly PerformanceUserMarkLogLevel: number;
  31374. /**
  31375. * Log performance to the console
  31376. */
  31377. static readonly PerformanceConsoleLogLevel: number;
  31378. private static _performance;
  31379. /**
  31380. * Sets the current performance log level
  31381. */
  31382. static PerformanceLogLevel: number;
  31383. private static _StartPerformanceCounterDisabled;
  31384. private static _EndPerformanceCounterDisabled;
  31385. private static _StartUserMark;
  31386. private static _EndUserMark;
  31387. private static _StartPerformanceConsole;
  31388. private static _EndPerformanceConsole;
  31389. /**
  31390. * Starts a performance counter
  31391. */
  31392. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31393. /**
  31394. * Ends a specific performance coutner
  31395. */
  31396. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31397. /**
  31398. * Gets either window.performance.now() if supported or Date.now() else
  31399. */
  31400. static readonly Now: number;
  31401. /**
  31402. * This method will return the name of the class used to create the instance of the given object.
  31403. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31404. * @param object the object to get the class name from
  31405. * @param isType defines if the object is actually a type
  31406. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31407. */
  31408. static GetClassName(object: any, isType?: boolean): string;
  31409. /**
  31410. * Gets the first element of an array satisfying a given predicate
  31411. * @param array defines the array to browse
  31412. * @param predicate defines the predicate to use
  31413. * @returns null if not found or the element
  31414. */
  31415. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31416. /**
  31417. * This method will return the name of the full name of the class, including its owning module (if any).
  31418. * 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).
  31419. * @param object the object to get the class name from
  31420. * @param isType defines if the object is actually a type
  31421. * @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.
  31422. * @ignorenaming
  31423. */
  31424. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31425. /**
  31426. * Returns a promise that resolves after the given amount of time.
  31427. * @param delay Number of milliseconds to delay
  31428. * @returns Promise that resolves after the given amount of time
  31429. */
  31430. static DelayAsync(delay: number): Promise<void>;
  31431. /**
  31432. * Gets the current gradient from an array of IValueGradient
  31433. * @param ratio defines the current ratio to get
  31434. * @param gradients defines the array of IValueGradient
  31435. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31436. */
  31437. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31438. }
  31439. /**
  31440. * This class is used to track a performance counter which is number based.
  31441. * The user has access to many properties which give statistics of different nature.
  31442. *
  31443. * The implementer can track two kinds of Performance Counter: time and count.
  31444. * 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.
  31445. * 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.
  31446. */
  31447. export class PerfCounter {
  31448. /**
  31449. * Gets or sets a global boolean to turn on and off all the counters
  31450. */
  31451. static Enabled: boolean;
  31452. /**
  31453. * Returns the smallest value ever
  31454. */
  31455. readonly min: number;
  31456. /**
  31457. * Returns the biggest value ever
  31458. */
  31459. readonly max: number;
  31460. /**
  31461. * Returns the average value since the performance counter is running
  31462. */
  31463. readonly average: number;
  31464. /**
  31465. * Returns the average value of the last second the counter was monitored
  31466. */
  31467. readonly lastSecAverage: number;
  31468. /**
  31469. * Returns the current value
  31470. */
  31471. readonly current: number;
  31472. /**
  31473. * Gets the accumulated total
  31474. */
  31475. readonly total: number;
  31476. /**
  31477. * Gets the total value count
  31478. */
  31479. readonly count: number;
  31480. /**
  31481. * Creates a new counter
  31482. */
  31483. constructor();
  31484. /**
  31485. * Call this method to start monitoring a new frame.
  31486. * 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.
  31487. */
  31488. fetchNewFrame(): void;
  31489. /**
  31490. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31491. * @param newCount the count value to add to the monitored count
  31492. * @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.
  31493. */
  31494. addCount(newCount: number, fetchResult: boolean): void;
  31495. /**
  31496. * Start monitoring this performance counter
  31497. */
  31498. beginMonitoring(): void;
  31499. /**
  31500. * Compute the time lapsed since the previous beginMonitoring() call.
  31501. * @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
  31502. */
  31503. endMonitoring(newFrame?: boolean): void;
  31504. private _fetchResult;
  31505. private _startMonitoringTime;
  31506. private _min;
  31507. private _max;
  31508. private _average;
  31509. private _current;
  31510. private _totalValueCount;
  31511. private _totalAccumulated;
  31512. private _lastSecAverage;
  31513. private _lastSecAccumulated;
  31514. private _lastSecTime;
  31515. private _lastSecValueCount;
  31516. }
  31517. /**
  31518. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31519. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31520. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31521. * @param name The name of the class, case should be preserved
  31522. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31523. */
  31524. export function className(name: string, module?: string): (target: Object) => void;
  31525. /**
  31526. * An implementation of a loop for asynchronous functions.
  31527. */
  31528. export class AsyncLoop {
  31529. /**
  31530. * Defines the number of iterations for the loop
  31531. */
  31532. iterations: number;
  31533. /**
  31534. * Defines the current index of the loop.
  31535. */
  31536. index: number;
  31537. private _done;
  31538. private _fn;
  31539. private _successCallback;
  31540. /**
  31541. * Constructor.
  31542. * @param iterations the number of iterations.
  31543. * @param func the function to run each iteration
  31544. * @param successCallback the callback that will be called upon succesful execution
  31545. * @param offset starting offset.
  31546. */
  31547. constructor(
  31548. /**
  31549. * Defines the number of iterations for the loop
  31550. */
  31551. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31552. /**
  31553. * Execute the next iteration. Must be called after the last iteration was finished.
  31554. */
  31555. executeNext(): void;
  31556. /**
  31557. * Break the loop and run the success callback.
  31558. */
  31559. breakLoop(): void;
  31560. /**
  31561. * Create and run an async loop.
  31562. * @param iterations the number of iterations.
  31563. * @param fn the function to run each iteration
  31564. * @param successCallback the callback that will be called upon succesful execution
  31565. * @param offset starting offset.
  31566. * @returns the created async loop object
  31567. */
  31568. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31569. /**
  31570. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31571. * @param iterations total number of iterations
  31572. * @param syncedIterations number of synchronous iterations in each async iteration.
  31573. * @param fn the function to call each iteration.
  31574. * @param callback a success call back that will be called when iterating stops.
  31575. * @param breakFunction a break condition (optional)
  31576. * @param timeout timeout settings for the setTimeout function. default - 0.
  31577. * @returns the created async loop object
  31578. */
  31579. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31580. }
  31581. }
  31582. declare module BABYLON {
  31583. /** @hidden */
  31584. export interface ICollisionCoordinator {
  31585. createCollider(): Collider;
  31586. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31587. init(scene: Scene): void;
  31588. }
  31589. /** @hidden */
  31590. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31591. private _scene;
  31592. private _scaledPosition;
  31593. private _scaledVelocity;
  31594. private _finalPosition;
  31595. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31596. createCollider(): Collider;
  31597. init(scene: Scene): void;
  31598. private _collideWithWorld;
  31599. }
  31600. }
  31601. declare module BABYLON {
  31602. /**
  31603. * Class used to manage all inputs for the scene.
  31604. */
  31605. export class InputManager {
  31606. /** The distance in pixel that you have to move to prevent some events */
  31607. static DragMovementThreshold: number;
  31608. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31609. static LongPressDelay: number;
  31610. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31611. static DoubleClickDelay: number;
  31612. /** If you need to check double click without raising a single click at first click, enable this flag */
  31613. static ExclusiveDoubleClickMode: boolean;
  31614. private _wheelEventName;
  31615. private _onPointerMove;
  31616. private _onPointerDown;
  31617. private _onPointerUp;
  31618. private _initClickEvent;
  31619. private _initActionManager;
  31620. private _delayedSimpleClick;
  31621. private _delayedSimpleClickTimeout;
  31622. private _previousDelayedSimpleClickTimeout;
  31623. private _meshPickProceed;
  31624. private _previousButtonPressed;
  31625. private _currentPickResult;
  31626. private _previousPickResult;
  31627. private _totalPointersPressed;
  31628. private _doubleClickOccured;
  31629. private _pointerOverMesh;
  31630. private _pickedDownMesh;
  31631. private _pickedUpMesh;
  31632. private _pointerX;
  31633. private _pointerY;
  31634. private _unTranslatedPointerX;
  31635. private _unTranslatedPointerY;
  31636. private _startingPointerPosition;
  31637. private _previousStartingPointerPosition;
  31638. private _startingPointerTime;
  31639. private _previousStartingPointerTime;
  31640. private _pointerCaptures;
  31641. private _onKeyDown;
  31642. private _onKeyUp;
  31643. private _onCanvasFocusObserver;
  31644. private _onCanvasBlurObserver;
  31645. private _scene;
  31646. /**
  31647. * Creates a new InputManager
  31648. * @param scene defines the hosting scene
  31649. */
  31650. constructor(scene: Scene);
  31651. /**
  31652. * Gets the mesh that is currently under the pointer
  31653. */
  31654. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31655. /**
  31656. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31657. */
  31658. readonly unTranslatedPointer: Vector2;
  31659. /**
  31660. * Gets or sets the current on-screen X position of the pointer
  31661. */
  31662. pointerX: number;
  31663. /**
  31664. * Gets or sets the current on-screen Y position of the pointer
  31665. */
  31666. pointerY: number;
  31667. private _updatePointerPosition;
  31668. private _processPointerMove;
  31669. private _setRayOnPointerInfo;
  31670. private _checkPrePointerObservable;
  31671. /**
  31672. * Use this method to simulate a pointer move on a mesh
  31673. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31674. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31675. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31676. */
  31677. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31678. /**
  31679. * Use this method to simulate a pointer down on a mesh
  31680. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31681. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31682. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31683. */
  31684. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31685. private _processPointerDown;
  31686. /** @hidden */
  31687. _isPointerSwiping(): boolean;
  31688. /**
  31689. * Use this method to simulate a pointer up on a mesh
  31690. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31691. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31692. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31693. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31694. */
  31695. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31696. private _processPointerUp;
  31697. /**
  31698. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31699. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31700. * @returns true if the pointer was captured
  31701. */
  31702. isPointerCaptured(pointerId?: number): boolean;
  31703. /**
  31704. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31705. * @param attachUp defines if you want to attach events to pointerup
  31706. * @param attachDown defines if you want to attach events to pointerdown
  31707. * @param attachMove defines if you want to attach events to pointermove
  31708. */
  31709. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31710. /**
  31711. * Detaches all event handlers
  31712. */
  31713. detachControl(): void;
  31714. /**
  31715. * Force the value of meshUnderPointer
  31716. * @param mesh defines the mesh to use
  31717. */
  31718. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31719. /**
  31720. * Gets the mesh under the pointer
  31721. * @returns a Mesh or null if no mesh is under the pointer
  31722. */
  31723. getPointerOverMesh(): Nullable<AbstractMesh>;
  31724. }
  31725. }
  31726. declare module BABYLON {
  31727. /**
  31728. * This class defines the direct association between an animation and a target
  31729. */
  31730. export class TargetedAnimation {
  31731. /**
  31732. * Animation to perform
  31733. */
  31734. animation: Animation;
  31735. /**
  31736. * Target to animate
  31737. */
  31738. target: any;
  31739. }
  31740. /**
  31741. * Use this class to create coordinated animations on multiple targets
  31742. */
  31743. export class AnimationGroup implements IDisposable {
  31744. /** The name of the animation group */
  31745. name: string;
  31746. private _scene;
  31747. private _targetedAnimations;
  31748. private _animatables;
  31749. private _from;
  31750. private _to;
  31751. private _isStarted;
  31752. private _isPaused;
  31753. private _speedRatio;
  31754. private _loopAnimation;
  31755. /**
  31756. * Gets or sets the unique id of the node
  31757. */
  31758. uniqueId: number;
  31759. /**
  31760. * This observable will notify when one animation have ended
  31761. */
  31762. onAnimationEndObservable: Observable<TargetedAnimation>;
  31763. /**
  31764. * Observer raised when one animation loops
  31765. */
  31766. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31767. /**
  31768. * This observable will notify when all animations have ended.
  31769. */
  31770. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31771. /**
  31772. * This observable will notify when all animations have paused.
  31773. */
  31774. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31775. /**
  31776. * This observable will notify when all animations are playing.
  31777. */
  31778. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31779. /**
  31780. * Gets the first frame
  31781. */
  31782. readonly from: number;
  31783. /**
  31784. * Gets the last frame
  31785. */
  31786. readonly to: number;
  31787. /**
  31788. * Define if the animations are started
  31789. */
  31790. readonly isStarted: boolean;
  31791. /**
  31792. * Gets a value indicating that the current group is playing
  31793. */
  31794. readonly isPlaying: boolean;
  31795. /**
  31796. * Gets or sets the speed ratio to use for all animations
  31797. */
  31798. /**
  31799. * Gets or sets the speed ratio to use for all animations
  31800. */
  31801. speedRatio: number;
  31802. /**
  31803. * Gets or sets if all animations should loop or not
  31804. */
  31805. loopAnimation: boolean;
  31806. /**
  31807. * Gets the targeted animations for this animation group
  31808. */
  31809. readonly targetedAnimations: Array<TargetedAnimation>;
  31810. /**
  31811. * returning the list of animatables controlled by this animation group.
  31812. */
  31813. readonly animatables: Array<Animatable>;
  31814. /**
  31815. * Instantiates a new Animation Group.
  31816. * This helps managing several animations at once.
  31817. * @see http://doc.babylonjs.com/how_to/group
  31818. * @param name Defines the name of the group
  31819. * @param scene Defines the scene the group belongs to
  31820. */
  31821. constructor(
  31822. /** The name of the animation group */
  31823. name: string, scene?: Nullable<Scene>);
  31824. /**
  31825. * Add an animation (with its target) in the group
  31826. * @param animation defines the animation we want to add
  31827. * @param target defines the target of the animation
  31828. * @returns the TargetedAnimation object
  31829. */
  31830. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31831. /**
  31832. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31833. * It can add constant keys at begin or end
  31834. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31835. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31836. * @returns the animation group
  31837. */
  31838. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31839. /**
  31840. * Start all animations on given targets
  31841. * @param loop defines if animations must loop
  31842. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31843. * @param from defines the from key (optional)
  31844. * @param to defines the to key (optional)
  31845. * @returns the current animation group
  31846. */
  31847. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31848. /**
  31849. * Pause all animations
  31850. * @returns the animation group
  31851. */
  31852. pause(): AnimationGroup;
  31853. /**
  31854. * Play all animations to initial state
  31855. * This function will start() the animations if they were not started or will restart() them if they were paused
  31856. * @param loop defines if animations must loop
  31857. * @returns the animation group
  31858. */
  31859. play(loop?: boolean): AnimationGroup;
  31860. /**
  31861. * Reset all animations to initial state
  31862. * @returns the animation group
  31863. */
  31864. reset(): AnimationGroup;
  31865. /**
  31866. * Restart animations from key 0
  31867. * @returns the animation group
  31868. */
  31869. restart(): AnimationGroup;
  31870. /**
  31871. * Stop all animations
  31872. * @returns the animation group
  31873. */
  31874. stop(): AnimationGroup;
  31875. /**
  31876. * Set animation weight for all animatables
  31877. * @param weight defines the weight to use
  31878. * @return the animationGroup
  31879. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31880. */
  31881. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31882. /**
  31883. * Synchronize and normalize all animatables with a source animatable
  31884. * @param root defines the root animatable to synchronize with
  31885. * @return the animationGroup
  31886. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31887. */
  31888. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31889. /**
  31890. * Goes to a specific frame in this animation group
  31891. * @param frame the frame number to go to
  31892. * @return the animationGroup
  31893. */
  31894. goToFrame(frame: number): AnimationGroup;
  31895. /**
  31896. * Dispose all associated resources
  31897. */
  31898. dispose(): void;
  31899. private _checkAnimationGroupEnded;
  31900. /**
  31901. * Clone the current animation group and returns a copy
  31902. * @param newName defines the name of the new group
  31903. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31904. * @returns the new aniamtion group
  31905. */
  31906. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31907. /**
  31908. * Returns a new AnimationGroup object parsed from the source provided.
  31909. * @param parsedAnimationGroup defines the source
  31910. * @param scene defines the scene that will receive the animationGroup
  31911. * @returns a new AnimationGroup
  31912. */
  31913. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31914. /**
  31915. * Returns the string "AnimationGroup"
  31916. * @returns "AnimationGroup"
  31917. */
  31918. getClassName(): string;
  31919. /**
  31920. * Creates a detailled string about the object
  31921. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31922. * @returns a string representing the object
  31923. */
  31924. toString(fullDetails?: boolean): string;
  31925. }
  31926. }
  31927. declare module BABYLON {
  31928. /**
  31929. * Define an interface for all classes that will hold resources
  31930. */
  31931. export interface IDisposable {
  31932. /**
  31933. * Releases all held resources
  31934. */
  31935. dispose(): void;
  31936. }
  31937. /** Interface defining initialization parameters for Scene class */
  31938. export interface SceneOptions {
  31939. /**
  31940. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31941. * It will improve performance when the number of geometries becomes important.
  31942. */
  31943. useGeometryUniqueIdsMap?: boolean;
  31944. /**
  31945. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31946. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31947. */
  31948. useMaterialMeshMap?: boolean;
  31949. /**
  31950. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31951. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31952. */
  31953. useClonedMeshhMap?: boolean;
  31954. }
  31955. /**
  31956. * Represents a scene to be rendered by the engine.
  31957. * @see http://doc.babylonjs.com/features/scene
  31958. */
  31959. export class Scene extends AbstractScene implements IAnimatable {
  31960. private static _uniqueIdCounter;
  31961. /** The fog is deactivated */
  31962. static readonly FOGMODE_NONE: number;
  31963. /** The fog density is following an exponential function */
  31964. static readonly FOGMODE_EXP: number;
  31965. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31966. static readonly FOGMODE_EXP2: number;
  31967. /** The fog density is following a linear function. */
  31968. static readonly FOGMODE_LINEAR: number;
  31969. /**
  31970. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31971. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31972. */
  31973. static MinDeltaTime: number;
  31974. /**
  31975. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31976. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31977. */
  31978. static MaxDeltaTime: number;
  31979. /**
  31980. * Factory used to create the default material.
  31981. * @param name The name of the material to create
  31982. * @param scene The scene to create the material for
  31983. * @returns The default material
  31984. */
  31985. static DefaultMaterialFactory(scene: Scene): Material;
  31986. /**
  31987. * Factory used to create the a collision coordinator.
  31988. * @returns The collision coordinator
  31989. */
  31990. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31991. /** @hidden */
  31992. _inputManager: InputManager;
  31993. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31994. cameraToUseForPointers: Nullable<Camera>;
  31995. /** @hidden */
  31996. readonly _isScene: boolean;
  31997. /**
  31998. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31999. */
  32000. autoClear: boolean;
  32001. /**
  32002. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32003. */
  32004. autoClearDepthAndStencil: boolean;
  32005. /**
  32006. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32007. */
  32008. clearColor: Color4;
  32009. /**
  32010. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32011. */
  32012. ambientColor: Color3;
  32013. /**
  32014. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32015. * It should only be one of the following (if not the default embedded one):
  32016. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32017. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32018. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32019. * The material properties need to be setup according to the type of texture in use.
  32020. */
  32021. environmentBRDFTexture: BaseTexture;
  32022. /** @hidden */
  32023. protected _environmentTexture: Nullable<BaseTexture>;
  32024. /**
  32025. * Texture used in all pbr material as the reflection texture.
  32026. * As in the majority of the scene they are the same (exception for multi room and so on),
  32027. * this is easier to reference from here than from all the materials.
  32028. */
  32029. /**
  32030. * Texture used in all pbr material as the reflection texture.
  32031. * As in the majority of the scene they are the same (exception for multi room and so on),
  32032. * this is easier to set here than in all the materials.
  32033. */
  32034. environmentTexture: Nullable<BaseTexture>;
  32035. /** @hidden */
  32036. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32037. /**
  32038. * Default image processing configuration used either in the rendering
  32039. * Forward main pass or through the imageProcessingPostProcess if present.
  32040. * As in the majority of the scene they are the same (exception for multi camera),
  32041. * this is easier to reference from here than from all the materials and post process.
  32042. *
  32043. * No setter as we it is a shared configuration, you can set the values instead.
  32044. */
  32045. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32046. private _forceWireframe;
  32047. /**
  32048. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32049. */
  32050. forceWireframe: boolean;
  32051. private _forcePointsCloud;
  32052. /**
  32053. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32054. */
  32055. forcePointsCloud: boolean;
  32056. /**
  32057. * Gets or sets the active clipplane 1
  32058. */
  32059. clipPlane: Nullable<Plane>;
  32060. /**
  32061. * Gets or sets the active clipplane 2
  32062. */
  32063. clipPlane2: Nullable<Plane>;
  32064. /**
  32065. * Gets or sets the active clipplane 3
  32066. */
  32067. clipPlane3: Nullable<Plane>;
  32068. /**
  32069. * Gets or sets the active clipplane 4
  32070. */
  32071. clipPlane4: Nullable<Plane>;
  32072. /**
  32073. * Gets or sets a boolean indicating if animations are enabled
  32074. */
  32075. animationsEnabled: boolean;
  32076. private _animationPropertiesOverride;
  32077. /**
  32078. * Gets or sets the animation properties override
  32079. */
  32080. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32081. /**
  32082. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32083. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32084. */
  32085. useConstantAnimationDeltaTime: boolean;
  32086. /**
  32087. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32088. * Please note that it requires to run a ray cast through the scene on every frame
  32089. */
  32090. constantlyUpdateMeshUnderPointer: boolean;
  32091. /**
  32092. * Defines the HTML cursor to use when hovering over interactive elements
  32093. */
  32094. hoverCursor: string;
  32095. /**
  32096. * Defines the HTML default cursor to use (empty by default)
  32097. */
  32098. defaultCursor: string;
  32099. /**
  32100. * This is used to call preventDefault() on pointer down
  32101. * in order to block unwanted artifacts like system double clicks
  32102. */
  32103. preventDefaultOnPointerDown: boolean;
  32104. /**
  32105. * This is used to call preventDefault() on pointer up
  32106. * in order to block unwanted artifacts like system double clicks
  32107. */
  32108. preventDefaultOnPointerUp: boolean;
  32109. /**
  32110. * Gets or sets user defined metadata
  32111. */
  32112. metadata: any;
  32113. /**
  32114. * For internal use only. Please do not use.
  32115. */
  32116. reservedDataStore: any;
  32117. /**
  32118. * Gets the name of the plugin used to load this scene (null by default)
  32119. */
  32120. loadingPluginName: string;
  32121. /**
  32122. * Use this array to add regular expressions used to disable offline support for specific urls
  32123. */
  32124. disableOfflineSupportExceptionRules: RegExp[];
  32125. /**
  32126. * An event triggered when the scene is disposed.
  32127. */
  32128. onDisposeObservable: Observable<Scene>;
  32129. private _onDisposeObserver;
  32130. /** Sets a function to be executed when this scene is disposed. */
  32131. onDispose: () => void;
  32132. /**
  32133. * An event triggered before rendering the scene (right after animations and physics)
  32134. */
  32135. onBeforeRenderObservable: Observable<Scene>;
  32136. private _onBeforeRenderObserver;
  32137. /** Sets a function to be executed before rendering this scene */
  32138. beforeRender: Nullable<() => void>;
  32139. /**
  32140. * An event triggered after rendering the scene
  32141. */
  32142. onAfterRenderObservable: Observable<Scene>;
  32143. private _onAfterRenderObserver;
  32144. /** Sets a function to be executed after rendering this scene */
  32145. afterRender: Nullable<() => void>;
  32146. /**
  32147. * An event triggered before animating the scene
  32148. */
  32149. onBeforeAnimationsObservable: Observable<Scene>;
  32150. /**
  32151. * An event triggered after animations processing
  32152. */
  32153. onAfterAnimationsObservable: Observable<Scene>;
  32154. /**
  32155. * An event triggered before draw calls are ready to be sent
  32156. */
  32157. onBeforeDrawPhaseObservable: Observable<Scene>;
  32158. /**
  32159. * An event triggered after draw calls have been sent
  32160. */
  32161. onAfterDrawPhaseObservable: Observable<Scene>;
  32162. /**
  32163. * An event triggered when the scene is ready
  32164. */
  32165. onReadyObservable: Observable<Scene>;
  32166. /**
  32167. * An event triggered before rendering a camera
  32168. */
  32169. onBeforeCameraRenderObservable: Observable<Camera>;
  32170. private _onBeforeCameraRenderObserver;
  32171. /** Sets a function to be executed before rendering a camera*/
  32172. beforeCameraRender: () => void;
  32173. /**
  32174. * An event triggered after rendering a camera
  32175. */
  32176. onAfterCameraRenderObservable: Observable<Camera>;
  32177. private _onAfterCameraRenderObserver;
  32178. /** Sets a function to be executed after rendering a camera*/
  32179. afterCameraRender: () => void;
  32180. /**
  32181. * An event triggered when active meshes evaluation is about to start
  32182. */
  32183. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32184. /**
  32185. * An event triggered when active meshes evaluation is done
  32186. */
  32187. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32188. /**
  32189. * An event triggered when particles rendering is about to start
  32190. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32191. */
  32192. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32193. /**
  32194. * An event triggered when particles rendering is done
  32195. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32196. */
  32197. onAfterParticlesRenderingObservable: Observable<Scene>;
  32198. /**
  32199. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32200. */
  32201. onDataLoadedObservable: Observable<Scene>;
  32202. /**
  32203. * An event triggered when a camera is created
  32204. */
  32205. onNewCameraAddedObservable: Observable<Camera>;
  32206. /**
  32207. * An event triggered when a camera is removed
  32208. */
  32209. onCameraRemovedObservable: Observable<Camera>;
  32210. /**
  32211. * An event triggered when a light is created
  32212. */
  32213. onNewLightAddedObservable: Observable<Light>;
  32214. /**
  32215. * An event triggered when a light is removed
  32216. */
  32217. onLightRemovedObservable: Observable<Light>;
  32218. /**
  32219. * An event triggered when a geometry is created
  32220. */
  32221. onNewGeometryAddedObservable: Observable<Geometry>;
  32222. /**
  32223. * An event triggered when a geometry is removed
  32224. */
  32225. onGeometryRemovedObservable: Observable<Geometry>;
  32226. /**
  32227. * An event triggered when a transform node is created
  32228. */
  32229. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32230. /**
  32231. * An event triggered when a transform node is removed
  32232. */
  32233. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32234. /**
  32235. * An event triggered when a mesh is created
  32236. */
  32237. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32238. /**
  32239. * An event triggered when a mesh is removed
  32240. */
  32241. onMeshRemovedObservable: Observable<AbstractMesh>;
  32242. /**
  32243. * An event triggered when a skeleton is created
  32244. */
  32245. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32246. /**
  32247. * An event triggered when a skeleton is removed
  32248. */
  32249. onSkeletonRemovedObservable: Observable<Skeleton>;
  32250. /**
  32251. * An event triggered when a material is created
  32252. */
  32253. onNewMaterialAddedObservable: Observable<Material>;
  32254. /**
  32255. * An event triggered when a material is removed
  32256. */
  32257. onMaterialRemovedObservable: Observable<Material>;
  32258. /**
  32259. * An event triggered when a texture is created
  32260. */
  32261. onNewTextureAddedObservable: Observable<BaseTexture>;
  32262. /**
  32263. * An event triggered when a texture is removed
  32264. */
  32265. onTextureRemovedObservable: Observable<BaseTexture>;
  32266. /**
  32267. * An event triggered when render targets are about to be rendered
  32268. * Can happen multiple times per frame.
  32269. */
  32270. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32271. /**
  32272. * An event triggered when render targets were rendered.
  32273. * Can happen multiple times per frame.
  32274. */
  32275. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32276. /**
  32277. * An event triggered before calculating deterministic simulation step
  32278. */
  32279. onBeforeStepObservable: Observable<Scene>;
  32280. /**
  32281. * An event triggered after calculating deterministic simulation step
  32282. */
  32283. onAfterStepObservable: Observable<Scene>;
  32284. /**
  32285. * An event triggered when the activeCamera property is updated
  32286. */
  32287. onActiveCameraChanged: Observable<Scene>;
  32288. /**
  32289. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32290. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32291. * 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)
  32292. */
  32293. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32294. /**
  32295. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32296. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32297. * 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)
  32298. */
  32299. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32300. /**
  32301. * This Observable will when a mesh has been imported into the scene.
  32302. */
  32303. onMeshImportedObservable: Observable<AbstractMesh>;
  32304. /**
  32305. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32306. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32307. */
  32308. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32309. /** @hidden */
  32310. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32311. /**
  32312. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32313. */
  32314. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32315. /**
  32316. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32317. */
  32318. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32319. /**
  32320. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32321. */
  32322. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32323. /** Callback called when a pointer move is detected */
  32324. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32325. /** Callback called when a pointer down is detected */
  32326. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32327. /** Callback called when a pointer up is detected */
  32328. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32329. /** Callback called when a pointer pick is detected */
  32330. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32331. /**
  32332. * 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).
  32333. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32334. */
  32335. onPrePointerObservable: Observable<PointerInfoPre>;
  32336. /**
  32337. * Observable event triggered each time an input event is received from the rendering canvas
  32338. */
  32339. onPointerObservable: Observable<PointerInfo>;
  32340. /**
  32341. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32342. */
  32343. readonly unTranslatedPointer: Vector2;
  32344. /**
  32345. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32346. */
  32347. static DragMovementThreshold: number;
  32348. /**
  32349. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32350. */
  32351. static LongPressDelay: number;
  32352. /**
  32353. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32354. */
  32355. static DoubleClickDelay: number;
  32356. /** If you need to check double click without raising a single click at first click, enable this flag */
  32357. static ExclusiveDoubleClickMode: boolean;
  32358. /** @hidden */
  32359. _mirroredCameraPosition: Nullable<Vector3>;
  32360. /**
  32361. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32362. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32363. */
  32364. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32365. /**
  32366. * Observable event triggered each time an keyboard event is received from the hosting window
  32367. */
  32368. onKeyboardObservable: Observable<KeyboardInfo>;
  32369. private _useRightHandedSystem;
  32370. /**
  32371. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32372. */
  32373. useRightHandedSystem: boolean;
  32374. private _timeAccumulator;
  32375. private _currentStepId;
  32376. private _currentInternalStep;
  32377. /**
  32378. * Sets the step Id used by deterministic lock step
  32379. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32380. * @param newStepId defines the step Id
  32381. */
  32382. setStepId(newStepId: number): void;
  32383. /**
  32384. * Gets the step Id used by deterministic lock step
  32385. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32386. * @returns the step Id
  32387. */
  32388. getStepId(): number;
  32389. /**
  32390. * Gets the internal step used by deterministic lock step
  32391. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32392. * @returns the internal step
  32393. */
  32394. getInternalStep(): number;
  32395. private _fogEnabled;
  32396. /**
  32397. * Gets or sets a boolean indicating if fog is enabled on this scene
  32398. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32399. * (Default is true)
  32400. */
  32401. fogEnabled: boolean;
  32402. private _fogMode;
  32403. /**
  32404. * Gets or sets the fog mode to use
  32405. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32406. * | mode | value |
  32407. * | --- | --- |
  32408. * | FOGMODE_NONE | 0 |
  32409. * | FOGMODE_EXP | 1 |
  32410. * | FOGMODE_EXP2 | 2 |
  32411. * | FOGMODE_LINEAR | 3 |
  32412. */
  32413. fogMode: number;
  32414. /**
  32415. * Gets or sets the fog color to use
  32416. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32417. * (Default is Color3(0.2, 0.2, 0.3))
  32418. */
  32419. fogColor: Color3;
  32420. /**
  32421. * Gets or sets the fog density to use
  32422. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32423. * (Default is 0.1)
  32424. */
  32425. fogDensity: number;
  32426. /**
  32427. * Gets or sets the fog start distance to use
  32428. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32429. * (Default is 0)
  32430. */
  32431. fogStart: number;
  32432. /**
  32433. * Gets or sets the fog end distance to use
  32434. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32435. * (Default is 1000)
  32436. */
  32437. fogEnd: number;
  32438. private _shadowsEnabled;
  32439. /**
  32440. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32441. */
  32442. shadowsEnabled: boolean;
  32443. private _lightsEnabled;
  32444. /**
  32445. * Gets or sets a boolean indicating if lights are enabled on this scene
  32446. */
  32447. lightsEnabled: boolean;
  32448. /** All of the active cameras added to this scene. */
  32449. activeCameras: Camera[];
  32450. /** @hidden */
  32451. _activeCamera: Nullable<Camera>;
  32452. /** Gets or sets the current active camera */
  32453. activeCamera: Nullable<Camera>;
  32454. private _defaultMaterial;
  32455. /** The default material used on meshes when no material is affected */
  32456. /** The default material used on meshes when no material is affected */
  32457. defaultMaterial: Material;
  32458. private _texturesEnabled;
  32459. /**
  32460. * Gets or sets a boolean indicating if textures are enabled on this scene
  32461. */
  32462. texturesEnabled: boolean;
  32463. /**
  32464. * Gets or sets a boolean indicating if particles are enabled on this scene
  32465. */
  32466. particlesEnabled: boolean;
  32467. /**
  32468. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32469. */
  32470. spritesEnabled: boolean;
  32471. private _skeletonsEnabled;
  32472. /**
  32473. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32474. */
  32475. skeletonsEnabled: boolean;
  32476. /**
  32477. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32478. */
  32479. lensFlaresEnabled: boolean;
  32480. /**
  32481. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32482. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32483. */
  32484. collisionsEnabled: boolean;
  32485. private _collisionCoordinator;
  32486. /** @hidden */
  32487. readonly collisionCoordinator: ICollisionCoordinator;
  32488. /**
  32489. * Defines the gravity applied to this scene (used only for collisions)
  32490. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32491. */
  32492. gravity: Vector3;
  32493. /**
  32494. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32495. */
  32496. postProcessesEnabled: boolean;
  32497. /**
  32498. * The list of postprocesses added to the scene
  32499. */
  32500. postProcesses: PostProcess[];
  32501. /**
  32502. * Gets the current postprocess manager
  32503. */
  32504. postProcessManager: PostProcessManager;
  32505. /**
  32506. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32507. */
  32508. renderTargetsEnabled: boolean;
  32509. /**
  32510. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32511. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32512. */
  32513. dumpNextRenderTargets: boolean;
  32514. /**
  32515. * The list of user defined render targets added to the scene
  32516. */
  32517. customRenderTargets: RenderTargetTexture[];
  32518. /**
  32519. * Defines if texture loading must be delayed
  32520. * If true, textures will only be loaded when they need to be rendered
  32521. */
  32522. useDelayedTextureLoading: boolean;
  32523. /**
  32524. * Gets the list of meshes imported to the scene through SceneLoader
  32525. */
  32526. importedMeshesFiles: String[];
  32527. /**
  32528. * Gets or sets a boolean indicating if probes are enabled on this scene
  32529. */
  32530. probesEnabled: boolean;
  32531. /**
  32532. * Gets or sets the current offline provider to use to store scene data
  32533. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32534. */
  32535. offlineProvider: IOfflineProvider;
  32536. /**
  32537. * Gets or sets the action manager associated with the scene
  32538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32539. */
  32540. actionManager: AbstractActionManager;
  32541. private _meshesForIntersections;
  32542. /**
  32543. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32544. */
  32545. proceduralTexturesEnabled: boolean;
  32546. private _engine;
  32547. private _totalVertices;
  32548. /** @hidden */
  32549. _activeIndices: PerfCounter;
  32550. /** @hidden */
  32551. _activeParticles: PerfCounter;
  32552. /** @hidden */
  32553. _activeBones: PerfCounter;
  32554. private _animationRatio;
  32555. /** @hidden */
  32556. _animationTimeLast: number;
  32557. /** @hidden */
  32558. _animationTime: number;
  32559. /**
  32560. * Gets or sets a general scale for animation speed
  32561. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32562. */
  32563. animationTimeScale: number;
  32564. /** @hidden */
  32565. _cachedMaterial: Nullable<Material>;
  32566. /** @hidden */
  32567. _cachedEffect: Nullable<Effect>;
  32568. /** @hidden */
  32569. _cachedVisibility: Nullable<number>;
  32570. private _renderId;
  32571. private _frameId;
  32572. private _executeWhenReadyTimeoutId;
  32573. private _intermediateRendering;
  32574. private _viewUpdateFlag;
  32575. private _projectionUpdateFlag;
  32576. /** @hidden */
  32577. _toBeDisposed: Nullable<IDisposable>[];
  32578. private _activeRequests;
  32579. /** @hidden */
  32580. _pendingData: any[];
  32581. private _isDisposed;
  32582. /**
  32583. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32584. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32585. */
  32586. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32587. private _activeMeshes;
  32588. private _processedMaterials;
  32589. private _renderTargets;
  32590. /** @hidden */
  32591. _activeParticleSystems: SmartArray<IParticleSystem>;
  32592. private _activeSkeletons;
  32593. private _softwareSkinnedMeshes;
  32594. private _renderingManager;
  32595. /** @hidden */
  32596. _activeAnimatables: Animatable[];
  32597. private _transformMatrix;
  32598. private _sceneUbo;
  32599. /** @hidden */
  32600. _viewMatrix: Matrix;
  32601. private _projectionMatrix;
  32602. /** @hidden */
  32603. _forcedViewPosition: Nullable<Vector3>;
  32604. /** @hidden */
  32605. _frustumPlanes: Plane[];
  32606. /**
  32607. * Gets the list of frustum planes (built from the active camera)
  32608. */
  32609. readonly frustumPlanes: Plane[];
  32610. /**
  32611. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32612. * This is useful if there are more lights that the maximum simulteanous authorized
  32613. */
  32614. requireLightSorting: boolean;
  32615. /** @hidden */
  32616. readonly useMaterialMeshMap: boolean;
  32617. /** @hidden */
  32618. readonly useClonedMeshhMap: boolean;
  32619. private _externalData;
  32620. private _uid;
  32621. /**
  32622. * @hidden
  32623. * Backing store of defined scene components.
  32624. */
  32625. _components: ISceneComponent[];
  32626. /**
  32627. * @hidden
  32628. * Backing store of defined scene components.
  32629. */
  32630. _serializableComponents: ISceneSerializableComponent[];
  32631. /**
  32632. * List of components to register on the next registration step.
  32633. */
  32634. private _transientComponents;
  32635. /**
  32636. * Registers the transient components if needed.
  32637. */
  32638. private _registerTransientComponents;
  32639. /**
  32640. * @hidden
  32641. * Add a component to the scene.
  32642. * Note that the ccomponent could be registered on th next frame if this is called after
  32643. * the register component stage.
  32644. * @param component Defines the component to add to the scene
  32645. */
  32646. _addComponent(component: ISceneComponent): void;
  32647. /**
  32648. * @hidden
  32649. * Gets a component from the scene.
  32650. * @param name defines the name of the component to retrieve
  32651. * @returns the component or null if not present
  32652. */
  32653. _getComponent(name: string): Nullable<ISceneComponent>;
  32654. /**
  32655. * @hidden
  32656. * Defines the actions happening before camera updates.
  32657. */
  32658. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32659. /**
  32660. * @hidden
  32661. * Defines the actions happening before clear the canvas.
  32662. */
  32663. _beforeClearStage: Stage<SimpleStageAction>;
  32664. /**
  32665. * @hidden
  32666. * Defines the actions when collecting render targets for the frame.
  32667. */
  32668. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32669. /**
  32670. * @hidden
  32671. * Defines the actions happening for one camera in the frame.
  32672. */
  32673. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32674. /**
  32675. * @hidden
  32676. * Defines the actions happening during the per mesh ready checks.
  32677. */
  32678. _isReadyForMeshStage: Stage<MeshStageAction>;
  32679. /**
  32680. * @hidden
  32681. * Defines the actions happening before evaluate active mesh checks.
  32682. */
  32683. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32684. /**
  32685. * @hidden
  32686. * Defines the actions happening during the evaluate sub mesh checks.
  32687. */
  32688. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32689. /**
  32690. * @hidden
  32691. * Defines the actions happening during the active mesh stage.
  32692. */
  32693. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32694. /**
  32695. * @hidden
  32696. * Defines the actions happening during the per camera render target step.
  32697. */
  32698. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32699. /**
  32700. * @hidden
  32701. * Defines the actions happening just before the active camera is drawing.
  32702. */
  32703. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32704. /**
  32705. * @hidden
  32706. * Defines the actions happening just before a render target is drawing.
  32707. */
  32708. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32709. /**
  32710. * @hidden
  32711. * Defines the actions happening just before a rendering group is drawing.
  32712. */
  32713. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32714. /**
  32715. * @hidden
  32716. * Defines the actions happening just before a mesh is drawing.
  32717. */
  32718. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32719. /**
  32720. * @hidden
  32721. * Defines the actions happening just after a mesh has been drawn.
  32722. */
  32723. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32724. /**
  32725. * @hidden
  32726. * Defines the actions happening just after a rendering group has been drawn.
  32727. */
  32728. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32729. /**
  32730. * @hidden
  32731. * Defines the actions happening just after the active camera has been drawn.
  32732. */
  32733. _afterCameraDrawStage: Stage<CameraStageAction>;
  32734. /**
  32735. * @hidden
  32736. * Defines the actions happening just after a render target has been drawn.
  32737. */
  32738. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32739. /**
  32740. * @hidden
  32741. * Defines the actions happening just after rendering all cameras and computing intersections.
  32742. */
  32743. _afterRenderStage: Stage<SimpleStageAction>;
  32744. /**
  32745. * @hidden
  32746. * Defines the actions happening when a pointer move event happens.
  32747. */
  32748. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32749. /**
  32750. * @hidden
  32751. * Defines the actions happening when a pointer down event happens.
  32752. */
  32753. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32754. /**
  32755. * @hidden
  32756. * Defines the actions happening when a pointer up event happens.
  32757. */
  32758. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32759. /**
  32760. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32761. */
  32762. private geometriesByUniqueId;
  32763. /**
  32764. * Creates a new Scene
  32765. * @param engine defines the engine to use to render this scene
  32766. * @param options defines the scene options
  32767. */
  32768. constructor(engine: Engine, options?: SceneOptions);
  32769. /**
  32770. * Gets a string idenfifying the name of the class
  32771. * @returns "Scene" string
  32772. */
  32773. getClassName(): string;
  32774. private _defaultMeshCandidates;
  32775. /**
  32776. * @hidden
  32777. */
  32778. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32779. private _defaultSubMeshCandidates;
  32780. /**
  32781. * @hidden
  32782. */
  32783. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32784. /**
  32785. * Sets the default candidate providers for the scene.
  32786. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32787. * and getCollidingSubMeshCandidates to their default function
  32788. */
  32789. setDefaultCandidateProviders(): void;
  32790. /**
  32791. * Gets the mesh that is currently under the pointer
  32792. */
  32793. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32794. /**
  32795. * Gets or sets the current on-screen X position of the pointer
  32796. */
  32797. pointerX: number;
  32798. /**
  32799. * Gets or sets the current on-screen Y position of the pointer
  32800. */
  32801. pointerY: number;
  32802. /**
  32803. * Gets the cached material (ie. the latest rendered one)
  32804. * @returns the cached material
  32805. */
  32806. getCachedMaterial(): Nullable<Material>;
  32807. /**
  32808. * Gets the cached effect (ie. the latest rendered one)
  32809. * @returns the cached effect
  32810. */
  32811. getCachedEffect(): Nullable<Effect>;
  32812. /**
  32813. * Gets the cached visibility state (ie. the latest rendered one)
  32814. * @returns the cached visibility state
  32815. */
  32816. getCachedVisibility(): Nullable<number>;
  32817. /**
  32818. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32819. * @param material defines the current material
  32820. * @param effect defines the current effect
  32821. * @param visibility defines the current visibility state
  32822. * @returns true if one parameter is not cached
  32823. */
  32824. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32825. /**
  32826. * Gets the engine associated with the scene
  32827. * @returns an Engine
  32828. */
  32829. getEngine(): Engine;
  32830. /**
  32831. * Gets the total number of vertices rendered per frame
  32832. * @returns the total number of vertices rendered per frame
  32833. */
  32834. getTotalVertices(): number;
  32835. /**
  32836. * Gets the performance counter for total vertices
  32837. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32838. */
  32839. readonly totalVerticesPerfCounter: PerfCounter;
  32840. /**
  32841. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32842. * @returns the total number of active indices rendered per frame
  32843. */
  32844. getActiveIndices(): number;
  32845. /**
  32846. * Gets the performance counter for active indices
  32847. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32848. */
  32849. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32850. /**
  32851. * Gets the total number of active particles rendered per frame
  32852. * @returns the total number of active particles rendered per frame
  32853. */
  32854. getActiveParticles(): number;
  32855. /**
  32856. * Gets the performance counter for active particles
  32857. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32858. */
  32859. readonly activeParticlesPerfCounter: PerfCounter;
  32860. /**
  32861. * Gets the total number of active bones rendered per frame
  32862. * @returns the total number of active bones rendered per frame
  32863. */
  32864. getActiveBones(): number;
  32865. /**
  32866. * Gets the performance counter for active bones
  32867. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32868. */
  32869. readonly activeBonesPerfCounter: PerfCounter;
  32870. /**
  32871. * Gets the array of active meshes
  32872. * @returns an array of AbstractMesh
  32873. */
  32874. getActiveMeshes(): SmartArray<AbstractMesh>;
  32875. /**
  32876. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32877. * @returns a number
  32878. */
  32879. getAnimationRatio(): number;
  32880. /**
  32881. * Gets an unique Id for the current render phase
  32882. * @returns a number
  32883. */
  32884. getRenderId(): number;
  32885. /**
  32886. * Gets an unique Id for the current frame
  32887. * @returns a number
  32888. */
  32889. getFrameId(): number;
  32890. /** Call this function if you want to manually increment the render Id*/
  32891. incrementRenderId(): void;
  32892. private _createUbo;
  32893. /**
  32894. * Use this method to simulate a pointer move on a mesh
  32895. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32896. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32897. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32898. * @returns the current scene
  32899. */
  32900. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32901. /**
  32902. * Use this method to simulate a pointer down on a mesh
  32903. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32904. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32905. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32906. * @returns the current scene
  32907. */
  32908. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32909. /**
  32910. * Use this method to simulate a pointer up on a mesh
  32911. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32912. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32913. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32914. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32915. * @returns the current scene
  32916. */
  32917. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32918. /**
  32919. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32920. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32921. * @returns true if the pointer was captured
  32922. */
  32923. isPointerCaptured(pointerId?: number): boolean;
  32924. /**
  32925. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32926. * @param attachUp defines if you want to attach events to pointerup
  32927. * @param attachDown defines if you want to attach events to pointerdown
  32928. * @param attachMove defines if you want to attach events to pointermove
  32929. */
  32930. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32931. /** Detaches all event handlers*/
  32932. detachControl(): void;
  32933. /**
  32934. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32935. * Delay loaded resources are not taking in account
  32936. * @return true if all required resources are ready
  32937. */
  32938. isReady(): boolean;
  32939. /** Resets all cached information relative to material (including effect and visibility) */
  32940. resetCachedMaterial(): void;
  32941. /**
  32942. * Registers a function to be called before every frame render
  32943. * @param func defines the function to register
  32944. */
  32945. registerBeforeRender(func: () => void): void;
  32946. /**
  32947. * Unregisters a function called before every frame render
  32948. * @param func defines the function to unregister
  32949. */
  32950. unregisterBeforeRender(func: () => void): void;
  32951. /**
  32952. * Registers a function to be called after every frame render
  32953. * @param func defines the function to register
  32954. */
  32955. registerAfterRender(func: () => void): void;
  32956. /**
  32957. * Unregisters a function called after every frame render
  32958. * @param func defines the function to unregister
  32959. */
  32960. unregisterAfterRender(func: () => void): void;
  32961. private _executeOnceBeforeRender;
  32962. /**
  32963. * The provided function will run before render once and will be disposed afterwards.
  32964. * A timeout delay can be provided so that the function will be executed in N ms.
  32965. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32966. * @param func The function to be executed.
  32967. * @param timeout optional delay in ms
  32968. */
  32969. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32970. /** @hidden */
  32971. _addPendingData(data: any): void;
  32972. /** @hidden */
  32973. _removePendingData(data: any): void;
  32974. /**
  32975. * Returns the number of items waiting to be loaded
  32976. * @returns the number of items waiting to be loaded
  32977. */
  32978. getWaitingItemsCount(): number;
  32979. /**
  32980. * Returns a boolean indicating if the scene is still loading data
  32981. */
  32982. readonly isLoading: boolean;
  32983. /**
  32984. * Registers a function to be executed when the scene is ready
  32985. * @param {Function} func - the function to be executed
  32986. */
  32987. executeWhenReady(func: () => void): void;
  32988. /**
  32989. * Returns a promise that resolves when the scene is ready
  32990. * @returns A promise that resolves when the scene is ready
  32991. */
  32992. whenReadyAsync(): Promise<void>;
  32993. /** @hidden */
  32994. _checkIsReady(): void;
  32995. /**
  32996. * Gets all animatable attached to the scene
  32997. */
  32998. readonly animatables: Animatable[];
  32999. /**
  33000. * Resets the last animation time frame.
  33001. * Useful to override when animations start running when loading a scene for the first time.
  33002. */
  33003. resetLastAnimationTimeFrame(): void;
  33004. /**
  33005. * Gets the current view matrix
  33006. * @returns a Matrix
  33007. */
  33008. getViewMatrix(): Matrix;
  33009. /**
  33010. * Gets the current projection matrix
  33011. * @returns a Matrix
  33012. */
  33013. getProjectionMatrix(): Matrix;
  33014. /**
  33015. * Gets the current transform matrix
  33016. * @returns a Matrix made of View * Projection
  33017. */
  33018. getTransformMatrix(): Matrix;
  33019. /**
  33020. * Sets the current transform matrix
  33021. * @param viewL defines the View matrix to use
  33022. * @param projectionL defines the Projection matrix to use
  33023. * @param viewR defines the right View matrix to use (if provided)
  33024. * @param projectionR defines the right Projection matrix to use (if provided)
  33025. */
  33026. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33027. /**
  33028. * Gets the uniform buffer used to store scene data
  33029. * @returns a UniformBuffer
  33030. */
  33031. getSceneUniformBuffer(): UniformBuffer;
  33032. /**
  33033. * Gets an unique (relatively to the current scene) Id
  33034. * @returns an unique number for the scene
  33035. */
  33036. getUniqueId(): number;
  33037. /**
  33038. * Add a mesh to the list of scene's meshes
  33039. * @param newMesh defines the mesh to add
  33040. * @param recursive if all child meshes should also be added to the scene
  33041. */
  33042. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33043. /**
  33044. * Remove a mesh for the list of scene's meshes
  33045. * @param toRemove defines the mesh to remove
  33046. * @param recursive if all child meshes should also be removed from the scene
  33047. * @returns the index where the mesh was in the mesh list
  33048. */
  33049. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33050. /**
  33051. * Add a transform node to the list of scene's transform nodes
  33052. * @param newTransformNode defines the transform node to add
  33053. */
  33054. addTransformNode(newTransformNode: TransformNode): void;
  33055. /**
  33056. * Remove a transform node for the list of scene's transform nodes
  33057. * @param toRemove defines the transform node to remove
  33058. * @returns the index where the transform node was in the transform node list
  33059. */
  33060. removeTransformNode(toRemove: TransformNode): number;
  33061. /**
  33062. * Remove a skeleton for the list of scene's skeletons
  33063. * @param toRemove defines the skeleton to remove
  33064. * @returns the index where the skeleton was in the skeleton list
  33065. */
  33066. removeSkeleton(toRemove: Skeleton): number;
  33067. /**
  33068. * Remove a morph target for the list of scene's morph targets
  33069. * @param toRemove defines the morph target to remove
  33070. * @returns the index where the morph target was in the morph target list
  33071. */
  33072. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33073. /**
  33074. * Remove a light for the list of scene's lights
  33075. * @param toRemove defines the light to remove
  33076. * @returns the index where the light was in the light list
  33077. */
  33078. removeLight(toRemove: Light): number;
  33079. /**
  33080. * Remove a camera for the list of scene's cameras
  33081. * @param toRemove defines the camera to remove
  33082. * @returns the index where the camera was in the camera list
  33083. */
  33084. removeCamera(toRemove: Camera): number;
  33085. /**
  33086. * Remove a particle system for the list of scene's particle systems
  33087. * @param toRemove defines the particle system to remove
  33088. * @returns the index where the particle system was in the particle system list
  33089. */
  33090. removeParticleSystem(toRemove: IParticleSystem): number;
  33091. /**
  33092. * Remove a animation for the list of scene's animations
  33093. * @param toRemove defines the animation to remove
  33094. * @returns the index where the animation was in the animation list
  33095. */
  33096. removeAnimation(toRemove: Animation): number;
  33097. /**
  33098. * Will stop the animation of the given target
  33099. * @param target - the target
  33100. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33101. * @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)
  33102. */
  33103. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33104. /**
  33105. * Removes the given animation group from this scene.
  33106. * @param toRemove The animation group to remove
  33107. * @returns The index of the removed animation group
  33108. */
  33109. removeAnimationGroup(toRemove: AnimationGroup): number;
  33110. /**
  33111. * Removes the given multi-material from this scene.
  33112. * @param toRemove The multi-material to remove
  33113. * @returns The index of the removed multi-material
  33114. */
  33115. removeMultiMaterial(toRemove: MultiMaterial): number;
  33116. /**
  33117. * Removes the given material from this scene.
  33118. * @param toRemove The material to remove
  33119. * @returns The index of the removed material
  33120. */
  33121. removeMaterial(toRemove: Material): number;
  33122. /**
  33123. * Removes the given action manager from this scene.
  33124. * @param toRemove The action manager to remove
  33125. * @returns The index of the removed action manager
  33126. */
  33127. removeActionManager(toRemove: AbstractActionManager): number;
  33128. /**
  33129. * Removes the given texture from this scene.
  33130. * @param toRemove The texture to remove
  33131. * @returns The index of the removed texture
  33132. */
  33133. removeTexture(toRemove: BaseTexture): number;
  33134. /**
  33135. * Adds the given light to this scene
  33136. * @param newLight The light to add
  33137. */
  33138. addLight(newLight: Light): void;
  33139. /**
  33140. * Sorts the list list based on light priorities
  33141. */
  33142. sortLightsByPriority(): void;
  33143. /**
  33144. * Adds the given camera to this scene
  33145. * @param newCamera The camera to add
  33146. */
  33147. addCamera(newCamera: Camera): void;
  33148. /**
  33149. * Adds the given skeleton to this scene
  33150. * @param newSkeleton The skeleton to add
  33151. */
  33152. addSkeleton(newSkeleton: Skeleton): void;
  33153. /**
  33154. * Adds the given particle system to this scene
  33155. * @param newParticleSystem The particle system to add
  33156. */
  33157. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33158. /**
  33159. * Adds the given animation to this scene
  33160. * @param newAnimation The animation to add
  33161. */
  33162. addAnimation(newAnimation: Animation): void;
  33163. /**
  33164. * Adds the given animation group to this scene.
  33165. * @param newAnimationGroup The animation group to add
  33166. */
  33167. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33168. /**
  33169. * Adds the given multi-material to this scene
  33170. * @param newMultiMaterial The multi-material to add
  33171. */
  33172. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33173. /**
  33174. * Adds the given material to this scene
  33175. * @param newMaterial The material to add
  33176. */
  33177. addMaterial(newMaterial: Material): void;
  33178. /**
  33179. * Adds the given morph target to this scene
  33180. * @param newMorphTargetManager The morph target to add
  33181. */
  33182. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33183. /**
  33184. * Adds the given geometry to this scene
  33185. * @param newGeometry The geometry to add
  33186. */
  33187. addGeometry(newGeometry: Geometry): void;
  33188. /**
  33189. * Adds the given action manager to this scene
  33190. * @param newActionManager The action manager to add
  33191. */
  33192. addActionManager(newActionManager: AbstractActionManager): void;
  33193. /**
  33194. * Adds the given texture to this scene.
  33195. * @param newTexture The texture to add
  33196. */
  33197. addTexture(newTexture: BaseTexture): void;
  33198. /**
  33199. * Switch active camera
  33200. * @param newCamera defines the new active camera
  33201. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33202. */
  33203. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33204. /**
  33205. * sets the active camera of the scene using its ID
  33206. * @param id defines the camera's ID
  33207. * @return the new active camera or null if none found.
  33208. */
  33209. setActiveCameraByID(id: string): Nullable<Camera>;
  33210. /**
  33211. * sets the active camera of the scene using its name
  33212. * @param name defines the camera's name
  33213. * @returns the new active camera or null if none found.
  33214. */
  33215. setActiveCameraByName(name: string): Nullable<Camera>;
  33216. /**
  33217. * get an animation group using its name
  33218. * @param name defines the material's name
  33219. * @return the animation group or null if none found.
  33220. */
  33221. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33222. /**
  33223. * Get a material using its unique id
  33224. * @param uniqueId defines the material's unique id
  33225. * @return the material or null if none found.
  33226. */
  33227. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33228. /**
  33229. * get a material using its id
  33230. * @param id defines the material's ID
  33231. * @return the material or null if none found.
  33232. */
  33233. getMaterialByID(id: string): Nullable<Material>;
  33234. /**
  33235. * Gets a material using its name
  33236. * @param name defines the material's name
  33237. * @return the material or null if none found.
  33238. */
  33239. getMaterialByName(name: string): Nullable<Material>;
  33240. /**
  33241. * Gets a camera using its id
  33242. * @param id defines the id to look for
  33243. * @returns the camera or null if not found
  33244. */
  33245. getCameraByID(id: string): Nullable<Camera>;
  33246. /**
  33247. * Gets a camera using its unique id
  33248. * @param uniqueId defines the unique id to look for
  33249. * @returns the camera or null if not found
  33250. */
  33251. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33252. /**
  33253. * Gets a camera using its name
  33254. * @param name defines the camera's name
  33255. * @return the camera or null if none found.
  33256. */
  33257. getCameraByName(name: string): Nullable<Camera>;
  33258. /**
  33259. * Gets a bone using its id
  33260. * @param id defines the bone's id
  33261. * @return the bone or null if not found
  33262. */
  33263. getBoneByID(id: string): Nullable<Bone>;
  33264. /**
  33265. * Gets a bone using its id
  33266. * @param name defines the bone's name
  33267. * @return the bone or null if not found
  33268. */
  33269. getBoneByName(name: string): Nullable<Bone>;
  33270. /**
  33271. * Gets a light node using its name
  33272. * @param name defines the the light's name
  33273. * @return the light or null if none found.
  33274. */
  33275. getLightByName(name: string): Nullable<Light>;
  33276. /**
  33277. * Gets a light node using its id
  33278. * @param id defines the light's id
  33279. * @return the light or null if none found.
  33280. */
  33281. getLightByID(id: string): Nullable<Light>;
  33282. /**
  33283. * Gets a light node using its scene-generated unique ID
  33284. * @param uniqueId defines the light's unique id
  33285. * @return the light or null if none found.
  33286. */
  33287. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33288. /**
  33289. * Gets a particle system by id
  33290. * @param id defines the particle system id
  33291. * @return the corresponding system or null if none found
  33292. */
  33293. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33294. /**
  33295. * Gets a geometry using its ID
  33296. * @param id defines the geometry's id
  33297. * @return the geometry or null if none found.
  33298. */
  33299. getGeometryByID(id: string): Nullable<Geometry>;
  33300. private _getGeometryByUniqueID;
  33301. /**
  33302. * Add a new geometry to this scene
  33303. * @param geometry defines the geometry to be added to the scene.
  33304. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33305. * @return a boolean defining if the geometry was added or not
  33306. */
  33307. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33308. /**
  33309. * Removes an existing geometry
  33310. * @param geometry defines the geometry to be removed from the scene
  33311. * @return a boolean defining if the geometry was removed or not
  33312. */
  33313. removeGeometry(geometry: Geometry): boolean;
  33314. /**
  33315. * Gets the list of geometries attached to the scene
  33316. * @returns an array of Geometry
  33317. */
  33318. getGeometries(): Geometry[];
  33319. /**
  33320. * Gets the first added mesh found of a given ID
  33321. * @param id defines the id to search for
  33322. * @return the mesh found or null if not found at all
  33323. */
  33324. getMeshByID(id: string): Nullable<AbstractMesh>;
  33325. /**
  33326. * Gets a list of meshes using their id
  33327. * @param id defines the id to search for
  33328. * @returns a list of meshes
  33329. */
  33330. getMeshesByID(id: string): Array<AbstractMesh>;
  33331. /**
  33332. * Gets the first added transform node found of a given ID
  33333. * @param id defines the id to search for
  33334. * @return the found transform node or null if not found at all.
  33335. */
  33336. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33337. /**
  33338. * Gets a transform node with its auto-generated unique id
  33339. * @param uniqueId efines the unique id to search for
  33340. * @return the found transform node or null if not found at all.
  33341. */
  33342. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33343. /**
  33344. * Gets a list of transform nodes using their id
  33345. * @param id defines the id to search for
  33346. * @returns a list of transform nodes
  33347. */
  33348. getTransformNodesByID(id: string): Array<TransformNode>;
  33349. /**
  33350. * Gets a mesh with its auto-generated unique id
  33351. * @param uniqueId defines the unique id to search for
  33352. * @return the found mesh or null if not found at all.
  33353. */
  33354. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33355. /**
  33356. * Gets a the last added mesh using a given id
  33357. * @param id defines the id to search for
  33358. * @return the found mesh or null if not found at all.
  33359. */
  33360. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33361. /**
  33362. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33363. * @param id defines the id to search for
  33364. * @return the found node or null if not found at all
  33365. */
  33366. getLastEntryByID(id: string): Nullable<Node>;
  33367. /**
  33368. * Gets a node (Mesh, Camera, Light) using a given id
  33369. * @param id defines the id to search for
  33370. * @return the found node or null if not found at all
  33371. */
  33372. getNodeByID(id: string): Nullable<Node>;
  33373. /**
  33374. * Gets a node (Mesh, Camera, Light) using a given name
  33375. * @param name defines the name to search for
  33376. * @return the found node or null if not found at all.
  33377. */
  33378. getNodeByName(name: string): Nullable<Node>;
  33379. /**
  33380. * Gets a mesh using a given name
  33381. * @param name defines the name to search for
  33382. * @return the found mesh or null if not found at all.
  33383. */
  33384. getMeshByName(name: string): Nullable<AbstractMesh>;
  33385. /**
  33386. * Gets a transform node using a given name
  33387. * @param name defines the name to search for
  33388. * @return the found transform node or null if not found at all.
  33389. */
  33390. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33391. /**
  33392. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33393. * @param id defines the id to search for
  33394. * @return the found skeleton or null if not found at all.
  33395. */
  33396. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33397. /**
  33398. * Gets a skeleton using a given auto generated unique id
  33399. * @param uniqueId defines the unique id to search for
  33400. * @return the found skeleton or null if not found at all.
  33401. */
  33402. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33403. /**
  33404. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33405. * @param id defines the id to search for
  33406. * @return the found skeleton or null if not found at all.
  33407. */
  33408. getSkeletonById(id: string): Nullable<Skeleton>;
  33409. /**
  33410. * Gets a skeleton using a given name
  33411. * @param name defines the name to search for
  33412. * @return the found skeleton or null if not found at all.
  33413. */
  33414. getSkeletonByName(name: string): Nullable<Skeleton>;
  33415. /**
  33416. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33417. * @param id defines the id to search for
  33418. * @return the found morph target manager or null if not found at all.
  33419. */
  33420. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33421. /**
  33422. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33423. * @param id defines the id to search for
  33424. * @return the found morph target or null if not found at all.
  33425. */
  33426. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33427. /**
  33428. * Gets a boolean indicating if the given mesh is active
  33429. * @param mesh defines the mesh to look for
  33430. * @returns true if the mesh is in the active list
  33431. */
  33432. isActiveMesh(mesh: AbstractMesh): boolean;
  33433. /**
  33434. * Return a unique id as a string which can serve as an identifier for the scene
  33435. */
  33436. readonly uid: string;
  33437. /**
  33438. * Add an externaly attached data from its key.
  33439. * This method call will fail and return false, if such key already exists.
  33440. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33441. * @param key the unique key that identifies the data
  33442. * @param data the data object to associate to the key for this Engine instance
  33443. * @return true if no such key were already present and the data was added successfully, false otherwise
  33444. */
  33445. addExternalData<T>(key: string, data: T): boolean;
  33446. /**
  33447. * Get an externaly attached data from its key
  33448. * @param key the unique key that identifies the data
  33449. * @return the associated data, if present (can be null), or undefined if not present
  33450. */
  33451. getExternalData<T>(key: string): Nullable<T>;
  33452. /**
  33453. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33454. * @param key the unique key that identifies the data
  33455. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33456. * @return the associated data, can be null if the factory returned null.
  33457. */
  33458. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33459. /**
  33460. * Remove an externaly attached data from the Engine instance
  33461. * @param key the unique key that identifies the data
  33462. * @return true if the data was successfully removed, false if it doesn't exist
  33463. */
  33464. removeExternalData(key: string): boolean;
  33465. private _evaluateSubMesh;
  33466. /**
  33467. * Clear the processed materials smart array preventing retention point in material dispose.
  33468. */
  33469. freeProcessedMaterials(): void;
  33470. private _preventFreeActiveMeshesAndRenderingGroups;
  33471. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33472. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33473. * when disposing several meshes in a row or a hierarchy of meshes.
  33474. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33475. */
  33476. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33477. /**
  33478. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33479. */
  33480. freeActiveMeshes(): void;
  33481. /**
  33482. * Clear the info related to rendering groups preventing retention points during dispose.
  33483. */
  33484. freeRenderingGroups(): void;
  33485. /** @hidden */
  33486. _isInIntermediateRendering(): boolean;
  33487. /**
  33488. * Lambda returning the list of potentially active meshes.
  33489. */
  33490. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33491. /**
  33492. * Lambda returning the list of potentially active sub meshes.
  33493. */
  33494. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33495. /**
  33496. * Lambda returning the list of potentially intersecting sub meshes.
  33497. */
  33498. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33499. /**
  33500. * Lambda returning the list of potentially colliding sub meshes.
  33501. */
  33502. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33503. private _activeMeshesFrozen;
  33504. /**
  33505. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33506. * @returns the current scene
  33507. */
  33508. freezeActiveMeshes(): Scene;
  33509. /**
  33510. * Use this function to restart evaluating active meshes on every frame
  33511. * @returns the current scene
  33512. */
  33513. unfreezeActiveMeshes(): Scene;
  33514. private _evaluateActiveMeshes;
  33515. private _activeMesh;
  33516. /**
  33517. * Update the transform matrix to update from the current active camera
  33518. * @param force defines a boolean used to force the update even if cache is up to date
  33519. */
  33520. updateTransformMatrix(force?: boolean): void;
  33521. private _bindFrameBuffer;
  33522. /** @hidden */
  33523. _allowPostProcessClearColor: boolean;
  33524. /** @hidden */
  33525. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33526. private _processSubCameras;
  33527. private _checkIntersections;
  33528. /** @hidden */
  33529. _advancePhysicsEngineStep(step: number): void;
  33530. /**
  33531. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33532. */
  33533. getDeterministicFrameTime: () => number;
  33534. /** @hidden */
  33535. _animate(): void;
  33536. /** Execute all animations (for a frame) */
  33537. animate(): void;
  33538. /**
  33539. * Render the scene
  33540. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33541. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33542. */
  33543. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33544. /**
  33545. * Freeze all materials
  33546. * A frozen material will not be updatable but should be faster to render
  33547. */
  33548. freezeMaterials(): void;
  33549. /**
  33550. * Unfreeze all materials
  33551. * A frozen material will not be updatable but should be faster to render
  33552. */
  33553. unfreezeMaterials(): void;
  33554. /**
  33555. * Releases all held ressources
  33556. */
  33557. dispose(): void;
  33558. /**
  33559. * Gets if the scene is already disposed
  33560. */
  33561. readonly isDisposed: boolean;
  33562. /**
  33563. * Call this function to reduce memory footprint of the scene.
  33564. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33565. */
  33566. clearCachedVertexData(): void;
  33567. /**
  33568. * This function will remove the local cached buffer data from texture.
  33569. * It will save memory but will prevent the texture from being rebuilt
  33570. */
  33571. cleanCachedTextureBuffer(): void;
  33572. /**
  33573. * Get the world extend vectors with an optional filter
  33574. *
  33575. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33576. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33577. */
  33578. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33579. min: Vector3;
  33580. max: Vector3;
  33581. };
  33582. /**
  33583. * Creates a ray that can be used to pick in the scene
  33584. * @param x defines the x coordinate of the origin (on-screen)
  33585. * @param y defines the y coordinate of the origin (on-screen)
  33586. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33587. * @param camera defines the camera to use for the picking
  33588. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33589. * @returns a Ray
  33590. */
  33591. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33592. /**
  33593. * Creates a ray that can be used to pick in the scene
  33594. * @param x defines the x coordinate of the origin (on-screen)
  33595. * @param y defines the y coordinate of the origin (on-screen)
  33596. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33597. * @param result defines the ray where to store the picking ray
  33598. * @param camera defines the camera to use for the picking
  33599. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33600. * @returns the current scene
  33601. */
  33602. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33603. /**
  33604. * Creates a ray that can be used to pick in the scene
  33605. * @param x defines the x coordinate of the origin (on-screen)
  33606. * @param y defines the y coordinate of the origin (on-screen)
  33607. * @param camera defines the camera to use for the picking
  33608. * @returns a Ray
  33609. */
  33610. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33611. /**
  33612. * Creates a ray that can be used to pick in the scene
  33613. * @param x defines the x coordinate of the origin (on-screen)
  33614. * @param y defines the y coordinate of the origin (on-screen)
  33615. * @param result defines the ray where to store the picking ray
  33616. * @param camera defines the camera to use for the picking
  33617. * @returns the current scene
  33618. */
  33619. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33620. /** Launch a ray to try to pick a mesh in the scene
  33621. * @param x position on screen
  33622. * @param y position on screen
  33623. * @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
  33624. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33625. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33626. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33627. * @returns a PickingInfo
  33628. */
  33629. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33630. /** Use the given ray to pick a mesh in the scene
  33631. * @param ray The ray to use to pick meshes
  33632. * @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
  33633. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33634. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33635. * @returns a PickingInfo
  33636. */
  33637. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33638. /**
  33639. * Launch a ray to try to pick a mesh in the scene
  33640. * @param x X position on screen
  33641. * @param y Y position on screen
  33642. * @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
  33643. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33644. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33645. * @returns an array of PickingInfo
  33646. */
  33647. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33648. /**
  33649. * Launch a ray to try to pick a mesh in the scene
  33650. * @param ray Ray to use
  33651. * @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
  33652. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33653. * @returns an array of PickingInfo
  33654. */
  33655. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33656. /**
  33657. * Force the value of meshUnderPointer
  33658. * @param mesh defines the mesh to use
  33659. */
  33660. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33661. /**
  33662. * Gets the mesh under the pointer
  33663. * @returns a Mesh or null if no mesh is under the pointer
  33664. */
  33665. getPointerOverMesh(): Nullable<AbstractMesh>;
  33666. /** @hidden */
  33667. _rebuildGeometries(): void;
  33668. /** @hidden */
  33669. _rebuildTextures(): void;
  33670. private _getByTags;
  33671. /**
  33672. * Get a list of meshes by tags
  33673. * @param tagsQuery defines the tags query to use
  33674. * @param forEach defines a predicate used to filter results
  33675. * @returns an array of Mesh
  33676. */
  33677. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33678. /**
  33679. * Get a list of cameras by tags
  33680. * @param tagsQuery defines the tags query to use
  33681. * @param forEach defines a predicate used to filter results
  33682. * @returns an array of Camera
  33683. */
  33684. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33685. /**
  33686. * Get a list of lights by tags
  33687. * @param tagsQuery defines the tags query to use
  33688. * @param forEach defines a predicate used to filter results
  33689. * @returns an array of Light
  33690. */
  33691. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33692. /**
  33693. * Get a list of materials by tags
  33694. * @param tagsQuery defines the tags query to use
  33695. * @param forEach defines a predicate used to filter results
  33696. * @returns an array of Material
  33697. */
  33698. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33699. /**
  33700. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33701. * This allowed control for front to back rendering or reversly depending of the special needs.
  33702. *
  33703. * @param renderingGroupId The rendering group id corresponding to its index
  33704. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33705. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33706. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33707. */
  33708. 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;
  33709. /**
  33710. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33711. *
  33712. * @param renderingGroupId The rendering group id corresponding to its index
  33713. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33714. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33715. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33716. */
  33717. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33718. /**
  33719. * Gets the current auto clear configuration for one rendering group of the rendering
  33720. * manager.
  33721. * @param index the rendering group index to get the information for
  33722. * @returns The auto clear setup for the requested rendering group
  33723. */
  33724. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33725. private _blockMaterialDirtyMechanism;
  33726. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33727. blockMaterialDirtyMechanism: boolean;
  33728. /**
  33729. * Will flag all materials as dirty to trigger new shader compilation
  33730. * @param flag defines the flag used to specify which material part must be marked as dirty
  33731. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33732. */
  33733. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33734. /** @hidden */
  33735. _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;
  33736. /** @hidden */
  33737. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33738. }
  33739. }
  33740. declare module BABYLON {
  33741. /**
  33742. * Set of assets to keep when moving a scene into an asset container.
  33743. */
  33744. export class KeepAssets extends AbstractScene {
  33745. }
  33746. /**
  33747. * Container with a set of assets that can be added or removed from a scene.
  33748. */
  33749. export class AssetContainer extends AbstractScene {
  33750. /**
  33751. * The scene the AssetContainer belongs to.
  33752. */
  33753. scene: Scene;
  33754. /**
  33755. * Instantiates an AssetContainer.
  33756. * @param scene The scene the AssetContainer belongs to.
  33757. */
  33758. constructor(scene: Scene);
  33759. /**
  33760. * Adds all the assets from the container to the scene.
  33761. */
  33762. addAllToScene(): void;
  33763. /**
  33764. * Removes all the assets in the container from the scene
  33765. */
  33766. removeAllFromScene(): void;
  33767. /**
  33768. * Disposes all the assets in the container
  33769. */
  33770. dispose(): void;
  33771. private _moveAssets;
  33772. /**
  33773. * Removes all the assets contained in the scene and adds them to the container.
  33774. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33775. */
  33776. moveAllFromScene(keepAssets?: KeepAssets): void;
  33777. /**
  33778. * 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.
  33779. * @returns the root mesh
  33780. */
  33781. createRootMesh(): Mesh;
  33782. }
  33783. }
  33784. declare module BABYLON {
  33785. /**
  33786. * Defines how the parser contract is defined.
  33787. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33788. */
  33789. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33790. /**
  33791. * Defines how the individual parser contract is defined.
  33792. * These parser can parse an individual asset
  33793. */
  33794. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33795. /**
  33796. * Base class of the scene acting as a container for the different elements composing a scene.
  33797. * This class is dynamically extended by the different components of the scene increasing
  33798. * flexibility and reducing coupling
  33799. */
  33800. export abstract class AbstractScene {
  33801. /**
  33802. * Stores the list of available parsers in the application.
  33803. */
  33804. private static _BabylonFileParsers;
  33805. /**
  33806. * Stores the list of available individual parsers in the application.
  33807. */
  33808. private static _IndividualBabylonFileParsers;
  33809. /**
  33810. * Adds a parser in the list of available ones
  33811. * @param name Defines the name of the parser
  33812. * @param parser Defines the parser to add
  33813. */
  33814. static AddParser(name: string, parser: BabylonFileParser): void;
  33815. /**
  33816. * Gets a general parser from the list of avaialble ones
  33817. * @param name Defines the name of the parser
  33818. * @returns the requested parser or null
  33819. */
  33820. static GetParser(name: string): Nullable<BabylonFileParser>;
  33821. /**
  33822. * Adds n individual parser in the list of available ones
  33823. * @param name Defines the name of the parser
  33824. * @param parser Defines the parser to add
  33825. */
  33826. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33827. /**
  33828. * Gets an individual parser from the list of avaialble ones
  33829. * @param name Defines the name of the parser
  33830. * @returns the requested parser or null
  33831. */
  33832. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33833. /**
  33834. * Parser json data and populate both a scene and its associated container object
  33835. * @param jsonData Defines the data to parse
  33836. * @param scene Defines the scene to parse the data for
  33837. * @param container Defines the container attached to the parsing sequence
  33838. * @param rootUrl Defines the root url of the data
  33839. */
  33840. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33841. /**
  33842. * Gets the list of root nodes (ie. nodes with no parent)
  33843. */
  33844. rootNodes: Node[];
  33845. /** All of the cameras added to this scene
  33846. * @see http://doc.babylonjs.com/babylon101/cameras
  33847. */
  33848. cameras: Camera[];
  33849. /**
  33850. * All of the lights added to this scene
  33851. * @see http://doc.babylonjs.com/babylon101/lights
  33852. */
  33853. lights: Light[];
  33854. /**
  33855. * All of the (abstract) meshes added to this scene
  33856. */
  33857. meshes: AbstractMesh[];
  33858. /**
  33859. * The list of skeletons added to the scene
  33860. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33861. */
  33862. skeletons: Skeleton[];
  33863. /**
  33864. * All of the particle systems added to this scene
  33865. * @see http://doc.babylonjs.com/babylon101/particles
  33866. */
  33867. particleSystems: IParticleSystem[];
  33868. /**
  33869. * Gets a list of Animations associated with the scene
  33870. */
  33871. animations: Animation[];
  33872. /**
  33873. * All of the animation groups added to this scene
  33874. * @see http://doc.babylonjs.com/how_to/group
  33875. */
  33876. animationGroups: AnimationGroup[];
  33877. /**
  33878. * All of the multi-materials added to this scene
  33879. * @see http://doc.babylonjs.com/how_to/multi_materials
  33880. */
  33881. multiMaterials: MultiMaterial[];
  33882. /**
  33883. * All of the materials added to this scene
  33884. * In the context of a Scene, it is not supposed to be modified manually.
  33885. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33886. * Note also that the order of the Material wihin the array is not significant and might change.
  33887. * @see http://doc.babylonjs.com/babylon101/materials
  33888. */
  33889. materials: Material[];
  33890. /**
  33891. * The list of morph target managers added to the scene
  33892. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33893. */
  33894. morphTargetManagers: MorphTargetManager[];
  33895. /**
  33896. * The list of geometries used in the scene.
  33897. */
  33898. geometries: Geometry[];
  33899. /**
  33900. * All of the tranform nodes added to this scene
  33901. * In the context of a Scene, it is not supposed to be modified manually.
  33902. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33903. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33904. * @see http://doc.babylonjs.com/how_to/transformnode
  33905. */
  33906. transformNodes: TransformNode[];
  33907. /**
  33908. * ActionManagers available on the scene.
  33909. */
  33910. actionManagers: AbstractActionManager[];
  33911. /**
  33912. * Textures to keep.
  33913. */
  33914. textures: BaseTexture[];
  33915. /**
  33916. * Environment texture for the scene
  33917. */
  33918. environmentTexture: Nullable<BaseTexture>;
  33919. }
  33920. }
  33921. declare module BABYLON {
  33922. /**
  33923. * Defines a sound that can be played in the application.
  33924. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33926. */
  33927. export class Sound {
  33928. /**
  33929. * The name of the sound in the scene.
  33930. */
  33931. name: string;
  33932. /**
  33933. * Does the sound autoplay once loaded.
  33934. */
  33935. autoplay: boolean;
  33936. /**
  33937. * Does the sound loop after it finishes playing once.
  33938. */
  33939. loop: boolean;
  33940. /**
  33941. * Does the sound use a custom attenuation curve to simulate the falloff
  33942. * happening when the source gets further away from the camera.
  33943. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33944. */
  33945. useCustomAttenuation: boolean;
  33946. /**
  33947. * The sound track id this sound belongs to.
  33948. */
  33949. soundTrackId: number;
  33950. /**
  33951. * Is this sound currently played.
  33952. */
  33953. isPlaying: boolean;
  33954. /**
  33955. * Is this sound currently paused.
  33956. */
  33957. isPaused: boolean;
  33958. /**
  33959. * Does this sound enables spatial sound.
  33960. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33961. */
  33962. spatialSound: boolean;
  33963. /**
  33964. * Define the reference distance the sound should be heard perfectly.
  33965. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33966. */
  33967. refDistance: number;
  33968. /**
  33969. * Define the roll off factor of spatial sounds.
  33970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33971. */
  33972. rolloffFactor: number;
  33973. /**
  33974. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33976. */
  33977. maxDistance: number;
  33978. /**
  33979. * Define the distance attenuation model the sound will follow.
  33980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33981. */
  33982. distanceModel: string;
  33983. /**
  33984. * @hidden
  33985. * Back Compat
  33986. **/
  33987. onended: () => any;
  33988. /**
  33989. * Observable event when the current playing sound finishes.
  33990. */
  33991. onEndedObservable: Observable<Sound>;
  33992. private _panningModel;
  33993. private _playbackRate;
  33994. private _streaming;
  33995. private _startTime;
  33996. private _startOffset;
  33997. private _position;
  33998. /** @hidden */
  33999. _positionInEmitterSpace: boolean;
  34000. private _localDirection;
  34001. private _volume;
  34002. private _isReadyToPlay;
  34003. private _isDirectional;
  34004. private _readyToPlayCallback;
  34005. private _audioBuffer;
  34006. private _soundSource;
  34007. private _streamingSource;
  34008. private _soundPanner;
  34009. private _soundGain;
  34010. private _inputAudioNode;
  34011. private _outputAudioNode;
  34012. private _coneInnerAngle;
  34013. private _coneOuterAngle;
  34014. private _coneOuterGain;
  34015. private _scene;
  34016. private _connectedTransformNode;
  34017. private _customAttenuationFunction;
  34018. private _registerFunc;
  34019. private _isOutputConnected;
  34020. private _htmlAudioElement;
  34021. private _urlType;
  34022. /** @hidden */
  34023. static _SceneComponentInitialization: (scene: Scene) => void;
  34024. /**
  34025. * Create a sound and attach it to a scene
  34026. * @param name Name of your sound
  34027. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34028. * @param scene defines the scene the sound belongs to
  34029. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34030. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34031. */
  34032. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34033. /**
  34034. * Release the sound and its associated resources
  34035. */
  34036. dispose(): void;
  34037. /**
  34038. * Gets if the sounds is ready to be played or not.
  34039. * @returns true if ready, otherwise false
  34040. */
  34041. isReady(): boolean;
  34042. private _soundLoaded;
  34043. /**
  34044. * Sets the data of the sound from an audiobuffer
  34045. * @param audioBuffer The audioBuffer containing the data
  34046. */
  34047. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34048. /**
  34049. * Updates the current sounds options such as maxdistance, loop...
  34050. * @param options A JSON object containing values named as the object properties
  34051. */
  34052. updateOptions(options: any): void;
  34053. private _createSpatialParameters;
  34054. private _updateSpatialParameters;
  34055. /**
  34056. * Switch the panning model to HRTF:
  34057. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34058. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34059. */
  34060. switchPanningModelToHRTF(): void;
  34061. /**
  34062. * Switch the panning model to Equal Power:
  34063. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34064. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34065. */
  34066. switchPanningModelToEqualPower(): void;
  34067. private _switchPanningModel;
  34068. /**
  34069. * Connect this sound to a sound track audio node like gain...
  34070. * @param soundTrackAudioNode the sound track audio node to connect to
  34071. */
  34072. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34073. /**
  34074. * Transform this sound into a directional source
  34075. * @param coneInnerAngle Size of the inner cone in degree
  34076. * @param coneOuterAngle Size of the outer cone in degree
  34077. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34078. */
  34079. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34080. /**
  34081. * Gets or sets the inner angle for the directional cone.
  34082. */
  34083. /**
  34084. * Gets or sets the inner angle for the directional cone.
  34085. */
  34086. directionalConeInnerAngle: number;
  34087. /**
  34088. * Gets or sets the outer angle for the directional cone.
  34089. */
  34090. /**
  34091. * Gets or sets the outer angle for the directional cone.
  34092. */
  34093. directionalConeOuterAngle: number;
  34094. /**
  34095. * Sets the position of the emitter if spatial sound is enabled
  34096. * @param newPosition Defines the new posisiton
  34097. */
  34098. setPosition(newPosition: Vector3): void;
  34099. /**
  34100. * Sets the local direction of the emitter if spatial sound is enabled
  34101. * @param newLocalDirection Defines the new local direction
  34102. */
  34103. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34104. private _updateDirection;
  34105. /** @hidden */
  34106. updateDistanceFromListener(): void;
  34107. /**
  34108. * Sets a new custom attenuation function for the sound.
  34109. * @param callback Defines the function used for the attenuation
  34110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34111. */
  34112. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34113. /**
  34114. * Play the sound
  34115. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34116. * @param offset (optional) Start the sound setting it at a specific time
  34117. */
  34118. play(time?: number, offset?: number): void;
  34119. private _onended;
  34120. /**
  34121. * Stop the sound
  34122. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34123. */
  34124. stop(time?: number): void;
  34125. /**
  34126. * Put the sound in pause
  34127. */
  34128. pause(): void;
  34129. /**
  34130. * Sets a dedicated volume for this sounds
  34131. * @param newVolume Define the new volume of the sound
  34132. * @param time Define in how long the sound should be at this value
  34133. */
  34134. setVolume(newVolume: number, time?: number): void;
  34135. /**
  34136. * Set the sound play back rate
  34137. * @param newPlaybackRate Define the playback rate the sound should be played at
  34138. */
  34139. setPlaybackRate(newPlaybackRate: number): void;
  34140. /**
  34141. * Gets the volume of the sound.
  34142. * @returns the volume of the sound
  34143. */
  34144. getVolume(): number;
  34145. /**
  34146. * Attach the sound to a dedicated mesh
  34147. * @param transformNode The transform node to connect the sound with
  34148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34149. */
  34150. attachToMesh(transformNode: TransformNode): void;
  34151. /**
  34152. * Detach the sound from the previously attached mesh
  34153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34154. */
  34155. detachFromMesh(): void;
  34156. private _onRegisterAfterWorldMatrixUpdate;
  34157. /**
  34158. * Clone the current sound in the scene.
  34159. * @returns the new sound clone
  34160. */
  34161. clone(): Nullable<Sound>;
  34162. /**
  34163. * Gets the current underlying audio buffer containing the data
  34164. * @returns the audio buffer
  34165. */
  34166. getAudioBuffer(): Nullable<AudioBuffer>;
  34167. /**
  34168. * Serializes the Sound in a JSON representation
  34169. * @returns the JSON representation of the sound
  34170. */
  34171. serialize(): any;
  34172. /**
  34173. * Parse a JSON representation of a sound to innstantiate in a given scene
  34174. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34175. * @param scene Define the scene the new parsed sound should be created in
  34176. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34177. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34178. * @returns the newly parsed sound
  34179. */
  34180. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34181. }
  34182. }
  34183. declare module BABYLON {
  34184. /**
  34185. * This defines an action helpful to play a defined sound on a triggered action.
  34186. */
  34187. export class PlaySoundAction extends Action {
  34188. private _sound;
  34189. /**
  34190. * Instantiate the action
  34191. * @param triggerOptions defines the trigger options
  34192. * @param sound defines the sound to play
  34193. * @param condition defines the trigger related conditions
  34194. */
  34195. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34196. /** @hidden */
  34197. _prepare(): void;
  34198. /**
  34199. * Execute the action and play the sound.
  34200. */
  34201. execute(): void;
  34202. /**
  34203. * Serializes the actions and its related information.
  34204. * @param parent defines the object to serialize in
  34205. * @returns the serialized object
  34206. */
  34207. serialize(parent: any): any;
  34208. }
  34209. /**
  34210. * This defines an action helpful to stop a defined sound on a triggered action.
  34211. */
  34212. export class StopSoundAction extends Action {
  34213. private _sound;
  34214. /**
  34215. * Instantiate the action
  34216. * @param triggerOptions defines the trigger options
  34217. * @param sound defines the sound to stop
  34218. * @param condition defines the trigger related conditions
  34219. */
  34220. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34221. /** @hidden */
  34222. _prepare(): void;
  34223. /**
  34224. * Execute the action and stop the sound.
  34225. */
  34226. execute(): void;
  34227. /**
  34228. * Serializes the actions and its related information.
  34229. * @param parent defines the object to serialize in
  34230. * @returns the serialized object
  34231. */
  34232. serialize(parent: any): any;
  34233. }
  34234. }
  34235. declare module BABYLON {
  34236. /**
  34237. * This defines an action responsible to change the value of a property
  34238. * by interpolating between its current value and the newly set one once triggered.
  34239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34240. */
  34241. export class InterpolateValueAction extends Action {
  34242. /**
  34243. * Defines the path of the property where the value should be interpolated
  34244. */
  34245. propertyPath: string;
  34246. /**
  34247. * Defines the target value at the end of the interpolation.
  34248. */
  34249. value: any;
  34250. /**
  34251. * Defines the time it will take for the property to interpolate to the value.
  34252. */
  34253. duration: number;
  34254. /**
  34255. * Defines if the other scene animations should be stopped when the action has been triggered
  34256. */
  34257. stopOtherAnimations?: boolean;
  34258. /**
  34259. * Defines a callback raised once the interpolation animation has been done.
  34260. */
  34261. onInterpolationDone?: () => void;
  34262. /**
  34263. * Observable triggered once the interpolation animation has been done.
  34264. */
  34265. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34266. private _target;
  34267. private _effectiveTarget;
  34268. private _property;
  34269. /**
  34270. * Instantiate the action
  34271. * @param triggerOptions defines the trigger options
  34272. * @param target defines the object containing the value to interpolate
  34273. * @param propertyPath defines the path to the property in the target object
  34274. * @param value defines the target value at the end of the interpolation
  34275. * @param duration deines the time it will take for the property to interpolate to the value.
  34276. * @param condition defines the trigger related conditions
  34277. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34278. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34279. */
  34280. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34281. /** @hidden */
  34282. _prepare(): void;
  34283. /**
  34284. * Execute the action starts the value interpolation.
  34285. */
  34286. execute(): void;
  34287. /**
  34288. * Serializes the actions and its related information.
  34289. * @param parent defines the object to serialize in
  34290. * @returns the serialized object
  34291. */
  34292. serialize(parent: any): any;
  34293. }
  34294. }
  34295. declare module BABYLON {
  34296. /**
  34297. * Options allowed during the creation of a sound track.
  34298. */
  34299. export interface ISoundTrackOptions {
  34300. /**
  34301. * The volume the sound track should take during creation
  34302. */
  34303. volume?: number;
  34304. /**
  34305. * Define if the sound track is the main sound track of the scene
  34306. */
  34307. mainTrack?: boolean;
  34308. }
  34309. /**
  34310. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34311. * It will be also used in a future release to apply effects on a specific track.
  34312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34313. */
  34314. export class SoundTrack {
  34315. /**
  34316. * The unique identifier of the sound track in the scene.
  34317. */
  34318. id: number;
  34319. /**
  34320. * The list of sounds included in the sound track.
  34321. */
  34322. soundCollection: Array<Sound>;
  34323. private _outputAudioNode;
  34324. private _scene;
  34325. private _isMainTrack;
  34326. private _connectedAnalyser;
  34327. private _options;
  34328. private _isInitialized;
  34329. /**
  34330. * Creates a new sound track.
  34331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34332. * @param scene Define the scene the sound track belongs to
  34333. * @param options
  34334. */
  34335. constructor(scene: Scene, options?: ISoundTrackOptions);
  34336. private _initializeSoundTrackAudioGraph;
  34337. /**
  34338. * Release the sound track and its associated resources
  34339. */
  34340. dispose(): void;
  34341. /**
  34342. * Adds a sound to this sound track
  34343. * @param sound define the cound to add
  34344. * @ignoreNaming
  34345. */
  34346. AddSound(sound: Sound): void;
  34347. /**
  34348. * Removes a sound to this sound track
  34349. * @param sound define the cound to remove
  34350. * @ignoreNaming
  34351. */
  34352. RemoveSound(sound: Sound): void;
  34353. /**
  34354. * Set a global volume for the full sound track.
  34355. * @param newVolume Define the new volume of the sound track
  34356. */
  34357. setVolume(newVolume: number): void;
  34358. /**
  34359. * Switch the panning model to HRTF:
  34360. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34361. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34362. */
  34363. switchPanningModelToHRTF(): void;
  34364. /**
  34365. * Switch the panning model to Equal Power:
  34366. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34368. */
  34369. switchPanningModelToEqualPower(): void;
  34370. /**
  34371. * Connect the sound track to an audio analyser allowing some amazing
  34372. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34374. * @param analyser The analyser to connect to the engine
  34375. */
  34376. connectToAnalyser(analyser: Analyser): void;
  34377. }
  34378. }
  34379. declare module BABYLON {
  34380. interface AbstractScene {
  34381. /**
  34382. * The list of sounds used in the scene.
  34383. */
  34384. sounds: Nullable<Array<Sound>>;
  34385. }
  34386. interface Scene {
  34387. /**
  34388. * @hidden
  34389. * Backing field
  34390. */
  34391. _mainSoundTrack: SoundTrack;
  34392. /**
  34393. * The main sound track played by the scene.
  34394. * It cotains your primary collection of sounds.
  34395. */
  34396. mainSoundTrack: SoundTrack;
  34397. /**
  34398. * The list of sound tracks added to the scene
  34399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34400. */
  34401. soundTracks: Nullable<Array<SoundTrack>>;
  34402. /**
  34403. * Gets a sound using a given name
  34404. * @param name defines the name to search for
  34405. * @return the found sound or null if not found at all.
  34406. */
  34407. getSoundByName(name: string): Nullable<Sound>;
  34408. /**
  34409. * Gets or sets if audio support is enabled
  34410. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34411. */
  34412. audioEnabled: boolean;
  34413. /**
  34414. * Gets or sets if audio will be output to headphones
  34415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34416. */
  34417. headphone: boolean;
  34418. }
  34419. /**
  34420. * Defines the sound scene component responsible to manage any sounds
  34421. * in a given scene.
  34422. */
  34423. export class AudioSceneComponent implements ISceneSerializableComponent {
  34424. /**
  34425. * The component name helpfull to identify the component in the list of scene components.
  34426. */
  34427. readonly name: string;
  34428. /**
  34429. * The scene the component belongs to.
  34430. */
  34431. scene: Scene;
  34432. private _audioEnabled;
  34433. /**
  34434. * Gets whether audio is enabled or not.
  34435. * Please use related enable/disable method to switch state.
  34436. */
  34437. readonly audioEnabled: boolean;
  34438. private _headphone;
  34439. /**
  34440. * Gets whether audio is outputing to headphone or not.
  34441. * Please use the according Switch methods to change output.
  34442. */
  34443. readonly headphone: boolean;
  34444. /**
  34445. * Creates a new instance of the component for the given scene
  34446. * @param scene Defines the scene to register the component in
  34447. */
  34448. constructor(scene: Scene);
  34449. /**
  34450. * Registers the component in a given scene
  34451. */
  34452. register(): void;
  34453. /**
  34454. * Rebuilds the elements related to this component in case of
  34455. * context lost for instance.
  34456. */
  34457. rebuild(): void;
  34458. /**
  34459. * Serializes the component data to the specified json object
  34460. * @param serializationObject The object to serialize to
  34461. */
  34462. serialize(serializationObject: any): void;
  34463. /**
  34464. * Adds all the element from the container to the scene
  34465. * @param container the container holding the elements
  34466. */
  34467. addFromContainer(container: AbstractScene): void;
  34468. /**
  34469. * Removes all the elements in the container from the scene
  34470. * @param container contains the elements to remove
  34471. * @param dispose if the removed element should be disposed (default: false)
  34472. */
  34473. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34474. /**
  34475. * Disposes the component and the associated ressources.
  34476. */
  34477. dispose(): void;
  34478. /**
  34479. * Disables audio in the associated scene.
  34480. */
  34481. disableAudio(): void;
  34482. /**
  34483. * Enables audio in the associated scene.
  34484. */
  34485. enableAudio(): void;
  34486. /**
  34487. * Switch audio to headphone output.
  34488. */
  34489. switchAudioModeForHeadphones(): void;
  34490. /**
  34491. * Switch audio to normal speakers.
  34492. */
  34493. switchAudioModeForNormalSpeakers(): void;
  34494. private _afterRender;
  34495. }
  34496. }
  34497. declare module BABYLON {
  34498. /**
  34499. * Wraps one or more Sound objects and selects one with random weight for playback.
  34500. */
  34501. export class WeightedSound {
  34502. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34503. loop: boolean;
  34504. private _coneInnerAngle;
  34505. private _coneOuterAngle;
  34506. private _volume;
  34507. /** A Sound is currently playing. */
  34508. isPlaying: boolean;
  34509. /** A Sound is currently paused. */
  34510. isPaused: boolean;
  34511. private _sounds;
  34512. private _weights;
  34513. private _currentIndex?;
  34514. /**
  34515. * Creates a new WeightedSound from the list of sounds given.
  34516. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34517. * @param sounds Array of Sounds that will be selected from.
  34518. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34519. */
  34520. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34521. /**
  34522. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34523. */
  34524. /**
  34525. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34526. */
  34527. directionalConeInnerAngle: number;
  34528. /**
  34529. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34530. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34531. */
  34532. /**
  34533. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34534. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34535. */
  34536. directionalConeOuterAngle: number;
  34537. /**
  34538. * Playback volume.
  34539. */
  34540. /**
  34541. * Playback volume.
  34542. */
  34543. volume: number;
  34544. private _onended;
  34545. /**
  34546. * Suspend playback
  34547. */
  34548. pause(): void;
  34549. /**
  34550. * Stop playback
  34551. */
  34552. stop(): void;
  34553. /**
  34554. * Start playback.
  34555. * @param startOffset Position the clip head at a specific time in seconds.
  34556. */
  34557. play(startOffset?: number): void;
  34558. }
  34559. }
  34560. declare module BABYLON {
  34561. /**
  34562. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34563. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34564. */
  34565. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34566. /**
  34567. * Gets the name of the behavior.
  34568. */
  34569. readonly name: string;
  34570. /**
  34571. * The easing function used by animations
  34572. */
  34573. static EasingFunction: BackEase;
  34574. /**
  34575. * The easing mode used by animations
  34576. */
  34577. static EasingMode: number;
  34578. /**
  34579. * The duration of the animation, in milliseconds
  34580. */
  34581. transitionDuration: number;
  34582. /**
  34583. * Length of the distance animated by the transition when lower radius is reached
  34584. */
  34585. lowerRadiusTransitionRange: number;
  34586. /**
  34587. * Length of the distance animated by the transition when upper radius is reached
  34588. */
  34589. upperRadiusTransitionRange: number;
  34590. private _autoTransitionRange;
  34591. /**
  34592. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34593. */
  34594. /**
  34595. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34596. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34597. */
  34598. autoTransitionRange: boolean;
  34599. private _attachedCamera;
  34600. private _onAfterCheckInputsObserver;
  34601. private _onMeshTargetChangedObserver;
  34602. /**
  34603. * Initializes the behavior.
  34604. */
  34605. init(): void;
  34606. /**
  34607. * Attaches the behavior to its arc rotate camera.
  34608. * @param camera Defines the camera to attach the behavior to
  34609. */
  34610. attach(camera: ArcRotateCamera): void;
  34611. /**
  34612. * Detaches the behavior from its current arc rotate camera.
  34613. */
  34614. detach(): void;
  34615. private _radiusIsAnimating;
  34616. private _radiusBounceTransition;
  34617. private _animatables;
  34618. private _cachedWheelPrecision;
  34619. /**
  34620. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34621. * @param radiusLimit The limit to check against.
  34622. * @return Bool to indicate if at limit.
  34623. */
  34624. private _isRadiusAtLimit;
  34625. /**
  34626. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34627. * @param radiusDelta The delta by which to animate to. Can be negative.
  34628. */
  34629. private _applyBoundRadiusAnimation;
  34630. /**
  34631. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34632. */
  34633. protected _clearAnimationLocks(): void;
  34634. /**
  34635. * Stops and removes all animations that have been applied to the camera
  34636. */
  34637. stopAllAnimations(): void;
  34638. }
  34639. }
  34640. declare module BABYLON {
  34641. /**
  34642. * 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.
  34643. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34644. */
  34645. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34646. /**
  34647. * Gets the name of the behavior.
  34648. */
  34649. readonly name: string;
  34650. private _mode;
  34651. private _radiusScale;
  34652. private _positionScale;
  34653. private _defaultElevation;
  34654. private _elevationReturnTime;
  34655. private _elevationReturnWaitTime;
  34656. private _zoomStopsAnimation;
  34657. private _framingTime;
  34658. /**
  34659. * The easing function used by animations
  34660. */
  34661. static EasingFunction: ExponentialEase;
  34662. /**
  34663. * The easing mode used by animations
  34664. */
  34665. static EasingMode: number;
  34666. /**
  34667. * Sets the current mode used by the behavior
  34668. */
  34669. /**
  34670. * Gets current mode used by the behavior.
  34671. */
  34672. mode: number;
  34673. /**
  34674. * Sets the scale applied to the radius (1 by default)
  34675. */
  34676. /**
  34677. * Gets the scale applied to the radius
  34678. */
  34679. radiusScale: number;
  34680. /**
  34681. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34682. */
  34683. /**
  34684. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34685. */
  34686. positionScale: number;
  34687. /**
  34688. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34689. * behaviour is triggered, in radians.
  34690. */
  34691. /**
  34692. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34693. * behaviour is triggered, in radians.
  34694. */
  34695. defaultElevation: number;
  34696. /**
  34697. * Sets the time (in milliseconds) taken to return to the default beta position.
  34698. * Negative value indicates camera should not return to default.
  34699. */
  34700. /**
  34701. * Gets the time (in milliseconds) taken to return to the default beta position.
  34702. * Negative value indicates camera should not return to default.
  34703. */
  34704. elevationReturnTime: number;
  34705. /**
  34706. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34707. */
  34708. /**
  34709. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34710. */
  34711. elevationReturnWaitTime: number;
  34712. /**
  34713. * Sets the flag that indicates if user zooming should stop animation.
  34714. */
  34715. /**
  34716. * Gets the flag that indicates if user zooming should stop animation.
  34717. */
  34718. zoomStopsAnimation: boolean;
  34719. /**
  34720. * Sets the transition time when framing the mesh, in milliseconds
  34721. */
  34722. /**
  34723. * Gets the transition time when framing the mesh, in milliseconds
  34724. */
  34725. framingTime: number;
  34726. /**
  34727. * Define if the behavior should automatically change the configured
  34728. * camera limits and sensibilities.
  34729. */
  34730. autoCorrectCameraLimitsAndSensibility: boolean;
  34731. private _onPrePointerObservableObserver;
  34732. private _onAfterCheckInputsObserver;
  34733. private _onMeshTargetChangedObserver;
  34734. private _attachedCamera;
  34735. private _isPointerDown;
  34736. private _lastInteractionTime;
  34737. /**
  34738. * Initializes the behavior.
  34739. */
  34740. init(): void;
  34741. /**
  34742. * Attaches the behavior to its arc rotate camera.
  34743. * @param camera Defines the camera to attach the behavior to
  34744. */
  34745. attach(camera: ArcRotateCamera): void;
  34746. /**
  34747. * Detaches the behavior from its current arc rotate camera.
  34748. */
  34749. detach(): void;
  34750. private _animatables;
  34751. private _betaIsAnimating;
  34752. private _betaTransition;
  34753. private _radiusTransition;
  34754. private _vectorTransition;
  34755. /**
  34756. * Targets the given mesh and updates zoom level accordingly.
  34757. * @param mesh The mesh to target.
  34758. * @param radius Optional. If a cached radius position already exists, overrides default.
  34759. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34760. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34761. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34762. */
  34763. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34764. /**
  34765. * Targets the given mesh with its children and updates zoom level accordingly.
  34766. * @param mesh The mesh to target.
  34767. * @param radius Optional. If a cached radius position already exists, overrides default.
  34768. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34769. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34770. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34771. */
  34772. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34773. /**
  34774. * Targets the given meshes with their children and updates zoom level accordingly.
  34775. * @param meshes The mesh to target.
  34776. * @param radius Optional. If a cached radius position already exists, overrides default.
  34777. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34778. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34779. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34780. */
  34781. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34782. /**
  34783. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34784. * @param minimumWorld Determines the smaller position of the bounding box extend
  34785. * @param maximumWorld Determines the bigger position of the bounding box extend
  34786. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34787. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34788. */
  34789. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34790. /**
  34791. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34792. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34793. * frustum width.
  34794. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34795. * to fully enclose the mesh in the viewing frustum.
  34796. */
  34797. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34798. /**
  34799. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34800. * is automatically returned to its default position (expected to be above ground plane).
  34801. */
  34802. private _maintainCameraAboveGround;
  34803. /**
  34804. * Returns the frustum slope based on the canvas ratio and camera FOV
  34805. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34806. */
  34807. private _getFrustumSlope;
  34808. /**
  34809. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34810. */
  34811. private _clearAnimationLocks;
  34812. /**
  34813. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34814. */
  34815. private _applyUserInteraction;
  34816. /**
  34817. * Stops and removes all animations that have been applied to the camera
  34818. */
  34819. stopAllAnimations(): void;
  34820. /**
  34821. * Gets a value indicating if the user is moving the camera
  34822. */
  34823. readonly isUserIsMoving: boolean;
  34824. /**
  34825. * The camera can move all the way towards the mesh.
  34826. */
  34827. static IgnoreBoundsSizeMode: number;
  34828. /**
  34829. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34830. */
  34831. static FitFrustumSidesMode: number;
  34832. }
  34833. }
  34834. declare module BABYLON {
  34835. /**
  34836. * Base class for Camera Pointer Inputs.
  34837. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34838. * for example usage.
  34839. */
  34840. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34841. /**
  34842. * Defines the camera the input is attached to.
  34843. */
  34844. abstract camera: Camera;
  34845. /**
  34846. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34847. */
  34848. protected _altKey: boolean;
  34849. protected _ctrlKey: boolean;
  34850. protected _metaKey: boolean;
  34851. protected _shiftKey: boolean;
  34852. /**
  34853. * Which mouse buttons were pressed at time of last mouse event.
  34854. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34855. */
  34856. protected _buttonsPressed: number;
  34857. /**
  34858. * Defines the buttons associated with the input to handle camera move.
  34859. */
  34860. buttons: number[];
  34861. /**
  34862. * Attach the input controls to a specific dom element to get the input from.
  34863. * @param element Defines the element the controls should be listened from
  34864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34865. */
  34866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34867. /**
  34868. * Detach the current controls from the specified dom element.
  34869. * @param element Defines the element to stop listening the inputs from
  34870. */
  34871. detachControl(element: Nullable<HTMLElement>): void;
  34872. /**
  34873. * Gets the class name of the current input.
  34874. * @returns the class name
  34875. */
  34876. getClassName(): string;
  34877. /**
  34878. * Get the friendly name associated with the input class.
  34879. * @returns the input friendly name
  34880. */
  34881. getSimpleName(): string;
  34882. /**
  34883. * Called on pointer POINTERDOUBLETAP event.
  34884. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34885. */
  34886. protected onDoubleTap(type: string): void;
  34887. /**
  34888. * Called on pointer POINTERMOVE event if only a single touch is active.
  34889. * Override this method to provide functionality.
  34890. */
  34891. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34892. /**
  34893. * Called on pointer POINTERMOVE event if multiple touches are active.
  34894. * Override this method to provide functionality.
  34895. */
  34896. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34897. /**
  34898. * Called on JS contextmenu event.
  34899. * Override this method to provide functionality.
  34900. */
  34901. protected onContextMenu(evt: PointerEvent): void;
  34902. /**
  34903. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34904. * press.
  34905. * Override this method to provide functionality.
  34906. */
  34907. protected onButtonDown(evt: PointerEvent): void;
  34908. /**
  34909. * Called each time a new POINTERUP event occurs. Ie, for each button
  34910. * release.
  34911. * Override this method to provide functionality.
  34912. */
  34913. protected onButtonUp(evt: PointerEvent): void;
  34914. /**
  34915. * Called when window becomes inactive.
  34916. * Override this method to provide functionality.
  34917. */
  34918. protected onLostFocus(): void;
  34919. private _pointerInput;
  34920. private _observer;
  34921. private _onLostFocus;
  34922. private pointA;
  34923. private pointB;
  34924. }
  34925. }
  34926. declare module BABYLON {
  34927. /**
  34928. * Manage the pointers inputs to control an arc rotate camera.
  34929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34930. */
  34931. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34932. /**
  34933. * Defines the camera the input is attached to.
  34934. */
  34935. camera: ArcRotateCamera;
  34936. /**
  34937. * Gets the class name of the current input.
  34938. * @returns the class name
  34939. */
  34940. getClassName(): string;
  34941. /**
  34942. * Defines the buttons associated with the input to handle camera move.
  34943. */
  34944. buttons: number[];
  34945. /**
  34946. * Defines the pointer angular sensibility along the X axis or how fast is
  34947. * the camera rotating.
  34948. */
  34949. angularSensibilityX: number;
  34950. /**
  34951. * Defines the pointer angular sensibility along the Y axis or how fast is
  34952. * the camera rotating.
  34953. */
  34954. angularSensibilityY: number;
  34955. /**
  34956. * Defines the pointer pinch precision or how fast is the camera zooming.
  34957. */
  34958. pinchPrecision: number;
  34959. /**
  34960. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34961. * from 0.
  34962. * It defines the percentage of current camera.radius to use as delta when
  34963. * pinch zoom is used.
  34964. */
  34965. pinchDeltaPercentage: number;
  34966. /**
  34967. * Defines the pointer panning sensibility or how fast is the camera moving.
  34968. */
  34969. panningSensibility: number;
  34970. /**
  34971. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34972. */
  34973. multiTouchPanning: boolean;
  34974. /**
  34975. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34976. * zoom (pinch) through multitouch.
  34977. */
  34978. multiTouchPanAndZoom: boolean;
  34979. /**
  34980. * Revers pinch action direction.
  34981. */
  34982. pinchInwards: boolean;
  34983. private _isPanClick;
  34984. private _twoFingerActivityCount;
  34985. private _isPinching;
  34986. /**
  34987. * Called on pointer POINTERMOVE event if only a single touch is active.
  34988. */
  34989. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34990. /**
  34991. * Called on pointer POINTERDOUBLETAP event.
  34992. */
  34993. protected onDoubleTap(type: string): void;
  34994. /**
  34995. * Called on pointer POINTERMOVE event if multiple touches are active.
  34996. */
  34997. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34998. /**
  34999. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35000. * press.
  35001. */
  35002. protected onButtonDown(evt: PointerEvent): void;
  35003. /**
  35004. * Called each time a new POINTERUP event occurs. Ie, for each button
  35005. * release.
  35006. */
  35007. protected onButtonUp(evt: PointerEvent): void;
  35008. /**
  35009. * Called when window becomes inactive.
  35010. */
  35011. protected onLostFocus(): void;
  35012. }
  35013. }
  35014. declare module BABYLON {
  35015. /**
  35016. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35018. */
  35019. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35020. /**
  35021. * Defines the camera the input is attached to.
  35022. */
  35023. camera: ArcRotateCamera;
  35024. /**
  35025. * Defines the list of key codes associated with the up action (increase alpha)
  35026. */
  35027. keysUp: number[];
  35028. /**
  35029. * Defines the list of key codes associated with the down action (decrease alpha)
  35030. */
  35031. keysDown: number[];
  35032. /**
  35033. * Defines the list of key codes associated with the left action (increase beta)
  35034. */
  35035. keysLeft: number[];
  35036. /**
  35037. * Defines the list of key codes associated with the right action (decrease beta)
  35038. */
  35039. keysRight: number[];
  35040. /**
  35041. * Defines the list of key codes associated with the reset action.
  35042. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35043. */
  35044. keysReset: number[];
  35045. /**
  35046. * Defines the panning sensibility of the inputs.
  35047. * (How fast is the camera paning)
  35048. */
  35049. panningSensibility: number;
  35050. /**
  35051. * Defines the zooming sensibility of the inputs.
  35052. * (How fast is the camera zooming)
  35053. */
  35054. zoomingSensibility: number;
  35055. /**
  35056. * Defines wether maintaining the alt key down switch the movement mode from
  35057. * orientation to zoom.
  35058. */
  35059. useAltToZoom: boolean;
  35060. /**
  35061. * Rotation speed of the camera
  35062. */
  35063. angularSpeed: number;
  35064. private _keys;
  35065. private _ctrlPressed;
  35066. private _altPressed;
  35067. private _onCanvasBlurObserver;
  35068. private _onKeyboardObserver;
  35069. private _engine;
  35070. private _scene;
  35071. /**
  35072. * Attach the input controls to a specific dom element to get the input from.
  35073. * @param element Defines the element the controls should be listened from
  35074. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35075. */
  35076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35077. /**
  35078. * Detach the current controls from the specified dom element.
  35079. * @param element Defines the element to stop listening the inputs from
  35080. */
  35081. detachControl(element: Nullable<HTMLElement>): void;
  35082. /**
  35083. * Update the current camera state depending on the inputs that have been used this frame.
  35084. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35085. */
  35086. checkInputs(): void;
  35087. /**
  35088. * Gets the class name of the current intput.
  35089. * @returns the class name
  35090. */
  35091. getClassName(): string;
  35092. /**
  35093. * Get the friendly name associated with the input class.
  35094. * @returns the input friendly name
  35095. */
  35096. getSimpleName(): string;
  35097. }
  35098. }
  35099. declare module BABYLON {
  35100. /**
  35101. * Manage the mouse wheel inputs to control an arc rotate camera.
  35102. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35103. */
  35104. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35105. /**
  35106. * Defines the camera the input is attached to.
  35107. */
  35108. camera: ArcRotateCamera;
  35109. /**
  35110. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35111. */
  35112. wheelPrecision: number;
  35113. /**
  35114. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35115. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35116. */
  35117. wheelDeltaPercentage: number;
  35118. private _wheel;
  35119. private _observer;
  35120. private computeDeltaFromMouseWheelLegacyEvent;
  35121. /**
  35122. * Attach the input controls to a specific dom element to get the input from.
  35123. * @param element Defines the element the controls should be listened from
  35124. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35125. */
  35126. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35127. /**
  35128. * Detach the current controls from the specified dom element.
  35129. * @param element Defines the element to stop listening the inputs from
  35130. */
  35131. detachControl(element: Nullable<HTMLElement>): void;
  35132. /**
  35133. * Gets the class name of the current intput.
  35134. * @returns the class name
  35135. */
  35136. getClassName(): string;
  35137. /**
  35138. * Get the friendly name associated with the input class.
  35139. * @returns the input friendly name
  35140. */
  35141. getSimpleName(): string;
  35142. }
  35143. }
  35144. declare module BABYLON {
  35145. /**
  35146. * Default Inputs manager for the ArcRotateCamera.
  35147. * It groups all the default supported inputs for ease of use.
  35148. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35149. */
  35150. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35151. /**
  35152. * Instantiates a new ArcRotateCameraInputsManager.
  35153. * @param camera Defines the camera the inputs belong to
  35154. */
  35155. constructor(camera: ArcRotateCamera);
  35156. /**
  35157. * Add mouse wheel input support to the input manager.
  35158. * @returns the current input manager
  35159. */
  35160. addMouseWheel(): ArcRotateCameraInputsManager;
  35161. /**
  35162. * Add pointers input support to the input manager.
  35163. * @returns the current input manager
  35164. */
  35165. addPointers(): ArcRotateCameraInputsManager;
  35166. /**
  35167. * Add keyboard input support to the input manager.
  35168. * @returns the current input manager
  35169. */
  35170. addKeyboard(): ArcRotateCameraInputsManager;
  35171. }
  35172. }
  35173. declare module BABYLON {
  35174. /**
  35175. * This represents an orbital type of camera.
  35176. *
  35177. * 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.
  35178. * 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.
  35179. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35180. */
  35181. export class ArcRotateCamera extends TargetCamera {
  35182. /**
  35183. * Defines the rotation angle of the camera along the longitudinal axis.
  35184. */
  35185. alpha: number;
  35186. /**
  35187. * Defines the rotation angle of the camera along the latitudinal axis.
  35188. */
  35189. beta: number;
  35190. /**
  35191. * Defines the radius of the camera from it s target point.
  35192. */
  35193. radius: number;
  35194. protected _target: Vector3;
  35195. protected _targetHost: Nullable<AbstractMesh>;
  35196. /**
  35197. * Defines the target point of the camera.
  35198. * The camera looks towards it form the radius distance.
  35199. */
  35200. target: Vector3;
  35201. /**
  35202. * Define the current local position of the camera in the scene
  35203. */
  35204. position: Vector3;
  35205. protected _upVector: Vector3;
  35206. protected _upToYMatrix: Matrix;
  35207. protected _YToUpMatrix: Matrix;
  35208. /**
  35209. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35210. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35211. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35212. */
  35213. upVector: Vector3;
  35214. /**
  35215. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35216. */
  35217. setMatUp(): void;
  35218. /**
  35219. * Current inertia value on the longitudinal axis.
  35220. * The bigger this number the longer it will take for the camera to stop.
  35221. */
  35222. inertialAlphaOffset: number;
  35223. /**
  35224. * Current inertia value on the latitudinal axis.
  35225. * The bigger this number the longer it will take for the camera to stop.
  35226. */
  35227. inertialBetaOffset: number;
  35228. /**
  35229. * Current inertia value on the radius axis.
  35230. * The bigger this number the longer it will take for the camera to stop.
  35231. */
  35232. inertialRadiusOffset: number;
  35233. /**
  35234. * Minimum allowed angle on the longitudinal axis.
  35235. * This can help limiting how the Camera is able to move in the scene.
  35236. */
  35237. lowerAlphaLimit: Nullable<number>;
  35238. /**
  35239. * Maximum allowed angle on the longitudinal axis.
  35240. * This can help limiting how the Camera is able to move in the scene.
  35241. */
  35242. upperAlphaLimit: Nullable<number>;
  35243. /**
  35244. * Minimum allowed angle on the latitudinal axis.
  35245. * This can help limiting how the Camera is able to move in the scene.
  35246. */
  35247. lowerBetaLimit: number;
  35248. /**
  35249. * Maximum allowed angle on the latitudinal axis.
  35250. * This can help limiting how the Camera is able to move in the scene.
  35251. */
  35252. upperBetaLimit: number;
  35253. /**
  35254. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35255. * This can help limiting how the Camera is able to move in the scene.
  35256. */
  35257. lowerRadiusLimit: Nullable<number>;
  35258. /**
  35259. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35260. * This can help limiting how the Camera is able to move in the scene.
  35261. */
  35262. upperRadiusLimit: Nullable<number>;
  35263. /**
  35264. * Defines the current inertia value used during panning of the camera along the X axis.
  35265. */
  35266. inertialPanningX: number;
  35267. /**
  35268. * Defines the current inertia value used during panning of the camera along the Y axis.
  35269. */
  35270. inertialPanningY: number;
  35271. /**
  35272. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35273. * Basically if your fingers moves away from more than this distance you will be considered
  35274. * in pinch mode.
  35275. */
  35276. pinchToPanMaxDistance: number;
  35277. /**
  35278. * Defines the maximum distance the camera can pan.
  35279. * This could help keeping the cammera always in your scene.
  35280. */
  35281. panningDistanceLimit: Nullable<number>;
  35282. /**
  35283. * Defines the target of the camera before paning.
  35284. */
  35285. panningOriginTarget: Vector3;
  35286. /**
  35287. * Defines the value of the inertia used during panning.
  35288. * 0 would mean stop inertia and one would mean no decelleration at all.
  35289. */
  35290. panningInertia: number;
  35291. /**
  35292. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35293. */
  35294. angularSensibilityX: number;
  35295. /**
  35296. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35297. */
  35298. angularSensibilityY: number;
  35299. /**
  35300. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35301. */
  35302. pinchPrecision: number;
  35303. /**
  35304. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35305. * It will be used instead of pinchDeltaPrecision if different from 0.
  35306. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35307. */
  35308. pinchDeltaPercentage: number;
  35309. /**
  35310. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35311. */
  35312. panningSensibility: number;
  35313. /**
  35314. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35315. */
  35316. keysUp: number[];
  35317. /**
  35318. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35319. */
  35320. keysDown: number[];
  35321. /**
  35322. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35323. */
  35324. keysLeft: number[];
  35325. /**
  35326. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35327. */
  35328. keysRight: number[];
  35329. /**
  35330. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35331. */
  35332. wheelPrecision: number;
  35333. /**
  35334. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35335. * It will be used instead of pinchDeltaPrecision if different from 0.
  35336. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35337. */
  35338. wheelDeltaPercentage: number;
  35339. /**
  35340. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35341. */
  35342. zoomOnFactor: number;
  35343. /**
  35344. * Defines a screen offset for the camera position.
  35345. */
  35346. targetScreenOffset: Vector2;
  35347. /**
  35348. * Allows the camera to be completely reversed.
  35349. * If false the camera can not arrive upside down.
  35350. */
  35351. allowUpsideDown: boolean;
  35352. /**
  35353. * Define if double tap/click is used to restore the previously saved state of the camera.
  35354. */
  35355. useInputToRestoreState: boolean;
  35356. /** @hidden */
  35357. _viewMatrix: Matrix;
  35358. /** @hidden */
  35359. _useCtrlForPanning: boolean;
  35360. /** @hidden */
  35361. _panningMouseButton: number;
  35362. /**
  35363. * Defines the input associated to the camera.
  35364. */
  35365. inputs: ArcRotateCameraInputsManager;
  35366. /** @hidden */
  35367. _reset: () => void;
  35368. /**
  35369. * Defines the allowed panning axis.
  35370. */
  35371. panningAxis: Vector3;
  35372. protected _localDirection: Vector3;
  35373. protected _transformedDirection: Vector3;
  35374. private _bouncingBehavior;
  35375. /**
  35376. * Gets the bouncing behavior of the camera if it has been enabled.
  35377. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35378. */
  35379. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35380. /**
  35381. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35382. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35383. */
  35384. useBouncingBehavior: boolean;
  35385. private _framingBehavior;
  35386. /**
  35387. * Gets the framing behavior of the camera if it has been enabled.
  35388. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35389. */
  35390. readonly framingBehavior: Nullable<FramingBehavior>;
  35391. /**
  35392. * Defines if the framing behavior of the camera is enabled on the camera.
  35393. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35394. */
  35395. useFramingBehavior: boolean;
  35396. private _autoRotationBehavior;
  35397. /**
  35398. * Gets the auto rotation behavior of the camera if it has been enabled.
  35399. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35400. */
  35401. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35402. /**
  35403. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35404. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35405. */
  35406. useAutoRotationBehavior: boolean;
  35407. /**
  35408. * Observable triggered when the mesh target has been changed on the camera.
  35409. */
  35410. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35411. /**
  35412. * Event raised when the camera is colliding with a mesh.
  35413. */
  35414. onCollide: (collidedMesh: AbstractMesh) => void;
  35415. /**
  35416. * Defines whether the camera should check collision with the objects oh the scene.
  35417. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35418. */
  35419. checkCollisions: boolean;
  35420. /**
  35421. * Defines the collision radius of the camera.
  35422. * This simulates a sphere around the camera.
  35423. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35424. */
  35425. collisionRadius: Vector3;
  35426. protected _collider: Collider;
  35427. protected _previousPosition: Vector3;
  35428. protected _collisionVelocity: Vector3;
  35429. protected _newPosition: Vector3;
  35430. protected _previousAlpha: number;
  35431. protected _previousBeta: number;
  35432. protected _previousRadius: number;
  35433. protected _collisionTriggered: boolean;
  35434. protected _targetBoundingCenter: Nullable<Vector3>;
  35435. private _computationVector;
  35436. /**
  35437. * Instantiates a new ArcRotateCamera in a given scene
  35438. * @param name Defines the name of the camera
  35439. * @param alpha Defines the camera rotation along the logitudinal axis
  35440. * @param beta Defines the camera rotation along the latitudinal axis
  35441. * @param radius Defines the camera distance from its target
  35442. * @param target Defines the camera target
  35443. * @param scene Defines the scene the camera belongs to
  35444. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35445. */
  35446. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35447. /** @hidden */
  35448. _initCache(): void;
  35449. /** @hidden */
  35450. _updateCache(ignoreParentClass?: boolean): void;
  35451. protected _getTargetPosition(): Vector3;
  35452. private _storedAlpha;
  35453. private _storedBeta;
  35454. private _storedRadius;
  35455. private _storedTarget;
  35456. /**
  35457. * Stores the current state of the camera (alpha, beta, radius and target)
  35458. * @returns the camera itself
  35459. */
  35460. storeState(): Camera;
  35461. /**
  35462. * @hidden
  35463. * Restored camera state. You must call storeState() first
  35464. */
  35465. _restoreStateValues(): boolean;
  35466. /** @hidden */
  35467. _isSynchronizedViewMatrix(): boolean;
  35468. /**
  35469. * Attached controls to the current camera.
  35470. * @param element Defines the element the controls should be listened from
  35471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35472. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35473. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35474. */
  35475. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35476. /**
  35477. * Detach the current controls from the camera.
  35478. * The camera will stop reacting to inputs.
  35479. * @param element Defines the element to stop listening the inputs from
  35480. */
  35481. detachControl(element: HTMLElement): void;
  35482. /** @hidden */
  35483. _checkInputs(): void;
  35484. protected _checkLimits(): void;
  35485. /**
  35486. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35487. */
  35488. rebuildAnglesAndRadius(): void;
  35489. /**
  35490. * Use a position to define the current camera related information like aplha, beta and radius
  35491. * @param position Defines the position to set the camera at
  35492. */
  35493. setPosition(position: Vector3): void;
  35494. /**
  35495. * Defines the target the camera should look at.
  35496. * This will automatically adapt alpha beta and radius to fit within the new target.
  35497. * @param target Defines the new target as a Vector or a mesh
  35498. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35499. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35500. */
  35501. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35502. /** @hidden */
  35503. _getViewMatrix(): Matrix;
  35504. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35505. /**
  35506. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35507. * @param meshes Defines the mesh to zoom on
  35508. * @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)
  35509. */
  35510. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35511. /**
  35512. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35513. * The target will be changed but the radius
  35514. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35515. * @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)
  35516. */
  35517. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35518. min: Vector3;
  35519. max: Vector3;
  35520. distance: number;
  35521. }, doNotUpdateMaxZ?: boolean): void;
  35522. /**
  35523. * @override
  35524. * Override Camera.createRigCamera
  35525. */
  35526. createRigCamera(name: string, cameraIndex: number): Camera;
  35527. /**
  35528. * @hidden
  35529. * @override
  35530. * Override Camera._updateRigCameras
  35531. */
  35532. _updateRigCameras(): void;
  35533. /**
  35534. * Destroy the camera and release the current resources hold by it.
  35535. */
  35536. dispose(): void;
  35537. /**
  35538. * Gets the current object class name.
  35539. * @return the class name
  35540. */
  35541. getClassName(): string;
  35542. }
  35543. }
  35544. declare module BABYLON {
  35545. /**
  35546. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35547. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35548. */
  35549. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35550. /**
  35551. * Gets the name of the behavior.
  35552. */
  35553. readonly name: string;
  35554. private _zoomStopsAnimation;
  35555. private _idleRotationSpeed;
  35556. private _idleRotationWaitTime;
  35557. private _idleRotationSpinupTime;
  35558. /**
  35559. * Sets the flag that indicates if user zooming should stop animation.
  35560. */
  35561. /**
  35562. * Gets the flag that indicates if user zooming should stop animation.
  35563. */
  35564. zoomStopsAnimation: boolean;
  35565. /**
  35566. * Sets the default speed at which the camera rotates around the model.
  35567. */
  35568. /**
  35569. * Gets the default speed at which the camera rotates around the model.
  35570. */
  35571. idleRotationSpeed: number;
  35572. /**
  35573. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35574. */
  35575. /**
  35576. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35577. */
  35578. idleRotationWaitTime: number;
  35579. /**
  35580. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35581. */
  35582. /**
  35583. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35584. */
  35585. idleRotationSpinupTime: number;
  35586. /**
  35587. * Gets a value indicating if the camera is currently rotating because of this behavior
  35588. */
  35589. readonly rotationInProgress: boolean;
  35590. private _onPrePointerObservableObserver;
  35591. private _onAfterCheckInputsObserver;
  35592. private _attachedCamera;
  35593. private _isPointerDown;
  35594. private _lastFrameTime;
  35595. private _lastInteractionTime;
  35596. private _cameraRotationSpeed;
  35597. /**
  35598. * Initializes the behavior.
  35599. */
  35600. init(): void;
  35601. /**
  35602. * Attaches the behavior to its arc rotate camera.
  35603. * @param camera Defines the camera to attach the behavior to
  35604. */
  35605. attach(camera: ArcRotateCamera): void;
  35606. /**
  35607. * Detaches the behavior from its current arc rotate camera.
  35608. */
  35609. detach(): void;
  35610. /**
  35611. * Returns true if user is scrolling.
  35612. * @return true if user is scrolling.
  35613. */
  35614. private _userIsZooming;
  35615. private _lastFrameRadius;
  35616. private _shouldAnimationStopForInteraction;
  35617. /**
  35618. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35619. */
  35620. private _applyUserInteraction;
  35621. private _userIsMoving;
  35622. }
  35623. }
  35624. declare module BABYLON {
  35625. /**
  35626. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35627. */
  35628. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35629. private ui;
  35630. /**
  35631. * The name of the behavior
  35632. */
  35633. name: string;
  35634. /**
  35635. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35636. */
  35637. distanceAwayFromFace: number;
  35638. /**
  35639. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35640. */
  35641. distanceAwayFromBottomOfFace: number;
  35642. private _faceVectors;
  35643. private _target;
  35644. private _scene;
  35645. private _onRenderObserver;
  35646. private _tmpMatrix;
  35647. private _tmpVector;
  35648. /**
  35649. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35650. * @param ui The transform node that should be attched to the mesh
  35651. */
  35652. constructor(ui: TransformNode);
  35653. /**
  35654. * Initializes the behavior
  35655. */
  35656. init(): void;
  35657. private _closestFace;
  35658. private _zeroVector;
  35659. private _lookAtTmpMatrix;
  35660. private _lookAtToRef;
  35661. /**
  35662. * Attaches the AttachToBoxBehavior to the passed in mesh
  35663. * @param target The mesh that the specified node will be attached to
  35664. */
  35665. attach(target: Mesh): void;
  35666. /**
  35667. * Detaches the behavior from the mesh
  35668. */
  35669. detach(): void;
  35670. }
  35671. }
  35672. declare module BABYLON {
  35673. /**
  35674. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35675. */
  35676. export class FadeInOutBehavior implements Behavior<Mesh> {
  35677. /**
  35678. * Time in milliseconds to delay before fading in (Default: 0)
  35679. */
  35680. delay: number;
  35681. /**
  35682. * Time in milliseconds for the mesh to fade in (Default: 300)
  35683. */
  35684. fadeInTime: number;
  35685. private _millisecondsPerFrame;
  35686. private _hovered;
  35687. private _hoverValue;
  35688. private _ownerNode;
  35689. /**
  35690. * Instatiates the FadeInOutBehavior
  35691. */
  35692. constructor();
  35693. /**
  35694. * The name of the behavior
  35695. */
  35696. readonly name: string;
  35697. /**
  35698. * Initializes the behavior
  35699. */
  35700. init(): void;
  35701. /**
  35702. * Attaches the fade behavior on the passed in mesh
  35703. * @param ownerNode The mesh that will be faded in/out once attached
  35704. */
  35705. attach(ownerNode: Mesh): void;
  35706. /**
  35707. * Detaches the behavior from the mesh
  35708. */
  35709. detach(): void;
  35710. /**
  35711. * Triggers the mesh to begin fading in or out
  35712. * @param value if the object should fade in or out (true to fade in)
  35713. */
  35714. fadeIn(value: boolean): void;
  35715. private _update;
  35716. private _setAllVisibility;
  35717. }
  35718. }
  35719. declare module BABYLON {
  35720. /**
  35721. * Class containing a set of static utilities functions for managing Pivots
  35722. * @hidden
  35723. */
  35724. export class PivotTools {
  35725. private static _PivotCached;
  35726. private static _OldPivotPoint;
  35727. private static _PivotTranslation;
  35728. private static _PivotTmpVector;
  35729. /** @hidden */
  35730. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35731. /** @hidden */
  35732. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35733. }
  35734. }
  35735. declare module BABYLON {
  35736. /**
  35737. * Class containing static functions to help procedurally build meshes
  35738. */
  35739. export class PlaneBuilder {
  35740. /**
  35741. * Creates a plane mesh
  35742. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35743. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35744. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35746. * * 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
  35747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35748. * @param name defines the name of the mesh
  35749. * @param options defines the options used to create the mesh
  35750. * @param scene defines the hosting scene
  35751. * @returns the plane mesh
  35752. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35753. */
  35754. static CreatePlane(name: string, options: {
  35755. size?: number;
  35756. width?: number;
  35757. height?: number;
  35758. sideOrientation?: number;
  35759. frontUVs?: Vector4;
  35760. backUVs?: Vector4;
  35761. updatable?: boolean;
  35762. sourcePlane?: Plane;
  35763. }, scene?: Nullable<Scene>): Mesh;
  35764. }
  35765. }
  35766. declare module BABYLON {
  35767. /**
  35768. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35769. */
  35770. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35771. private static _AnyMouseID;
  35772. private _attachedNode;
  35773. private _dragPlane;
  35774. private _scene;
  35775. private _pointerObserver;
  35776. private _beforeRenderObserver;
  35777. private static _planeScene;
  35778. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35779. /**
  35780. * 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)
  35781. */
  35782. maxDragAngle: number;
  35783. /**
  35784. * @hidden
  35785. */
  35786. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35787. /**
  35788. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35789. */
  35790. currentDraggingPointerID: number;
  35791. /**
  35792. * The last position where the pointer hit the drag plane in world space
  35793. */
  35794. lastDragPosition: Vector3;
  35795. /**
  35796. * If the behavior is currently in a dragging state
  35797. */
  35798. dragging: boolean;
  35799. /**
  35800. * 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)
  35801. */
  35802. dragDeltaRatio: number;
  35803. /**
  35804. * If the drag plane orientation should be updated during the dragging (Default: true)
  35805. */
  35806. updateDragPlane: boolean;
  35807. private _debugMode;
  35808. private _moving;
  35809. /**
  35810. * Fires each time the attached mesh is dragged with the pointer
  35811. * * delta between last drag position and current drag position in world space
  35812. * * dragDistance along the drag axis
  35813. * * dragPlaneNormal normal of the current drag plane used during the drag
  35814. * * dragPlanePoint in world space where the drag intersects the drag plane
  35815. */
  35816. onDragObservable: Observable<{
  35817. delta: Vector3;
  35818. dragPlanePoint: Vector3;
  35819. dragPlaneNormal: Vector3;
  35820. dragDistance: number;
  35821. pointerId: number;
  35822. }>;
  35823. /**
  35824. * Fires each time a drag begins (eg. mouse down on mesh)
  35825. */
  35826. onDragStartObservable: Observable<{
  35827. dragPlanePoint: Vector3;
  35828. pointerId: number;
  35829. }>;
  35830. /**
  35831. * Fires each time a drag ends (eg. mouse release after drag)
  35832. */
  35833. onDragEndObservable: Observable<{
  35834. dragPlanePoint: Vector3;
  35835. pointerId: number;
  35836. }>;
  35837. /**
  35838. * If the attached mesh should be moved when dragged
  35839. */
  35840. moveAttached: boolean;
  35841. /**
  35842. * If the drag behavior will react to drag events (Default: true)
  35843. */
  35844. enabled: boolean;
  35845. /**
  35846. * If camera controls should be detached during the drag
  35847. */
  35848. detachCameraControls: boolean;
  35849. /**
  35850. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35851. */
  35852. useObjectOrienationForDragging: boolean;
  35853. private _options;
  35854. /**
  35855. * Creates a pointer drag behavior that can be attached to a mesh
  35856. * @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)
  35857. */
  35858. constructor(options?: {
  35859. dragAxis?: Vector3;
  35860. dragPlaneNormal?: Vector3;
  35861. });
  35862. /**
  35863. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35864. */
  35865. validateDrag: (targetPosition: Vector3) => boolean;
  35866. /**
  35867. * The name of the behavior
  35868. */
  35869. readonly name: string;
  35870. /**
  35871. * Initializes the behavior
  35872. */
  35873. init(): void;
  35874. private _tmpVector;
  35875. private _alternatePickedPoint;
  35876. private _worldDragAxis;
  35877. private _targetPosition;
  35878. private _attachedElement;
  35879. /**
  35880. * Attaches the drag behavior the passed in mesh
  35881. * @param ownerNode The mesh that will be dragged around once attached
  35882. */
  35883. attach(ownerNode: AbstractMesh): void;
  35884. /**
  35885. * Force relase the drag action by code.
  35886. */
  35887. releaseDrag(): void;
  35888. private _startDragRay;
  35889. private _lastPointerRay;
  35890. /**
  35891. * Simulates the start of a pointer drag event on the behavior
  35892. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35893. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35894. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35895. */
  35896. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35897. private _startDrag;
  35898. private _dragDelta;
  35899. private _moveDrag;
  35900. private _pickWithRayOnDragPlane;
  35901. private _pointA;
  35902. private _pointB;
  35903. private _pointC;
  35904. private _lineA;
  35905. private _lineB;
  35906. private _localAxis;
  35907. private _lookAt;
  35908. private _updateDragPlanePosition;
  35909. /**
  35910. * Detaches the behavior from the mesh
  35911. */
  35912. detach(): void;
  35913. }
  35914. }
  35915. declare module BABYLON {
  35916. /**
  35917. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35918. */
  35919. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35920. private _dragBehaviorA;
  35921. private _dragBehaviorB;
  35922. private _startDistance;
  35923. private _initialScale;
  35924. private _targetScale;
  35925. private _ownerNode;
  35926. private _sceneRenderObserver;
  35927. /**
  35928. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35929. */
  35930. constructor();
  35931. /**
  35932. * The name of the behavior
  35933. */
  35934. readonly name: string;
  35935. /**
  35936. * Initializes the behavior
  35937. */
  35938. init(): void;
  35939. private _getCurrentDistance;
  35940. /**
  35941. * Attaches the scale behavior the passed in mesh
  35942. * @param ownerNode The mesh that will be scaled around once attached
  35943. */
  35944. attach(ownerNode: Mesh): void;
  35945. /**
  35946. * Detaches the behavior from the mesh
  35947. */
  35948. detach(): void;
  35949. }
  35950. }
  35951. declare module BABYLON {
  35952. /**
  35953. * 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
  35954. */
  35955. export class SixDofDragBehavior implements Behavior<Mesh> {
  35956. private static _virtualScene;
  35957. private _ownerNode;
  35958. private _sceneRenderObserver;
  35959. private _scene;
  35960. private _targetPosition;
  35961. private _virtualOriginMesh;
  35962. private _virtualDragMesh;
  35963. private _pointerObserver;
  35964. private _moving;
  35965. private _startingOrientation;
  35966. /**
  35967. * 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)
  35968. */
  35969. private zDragFactor;
  35970. /**
  35971. * If the object should rotate to face the drag origin
  35972. */
  35973. rotateDraggedObject: boolean;
  35974. /**
  35975. * If the behavior is currently in a dragging state
  35976. */
  35977. dragging: boolean;
  35978. /**
  35979. * 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)
  35980. */
  35981. dragDeltaRatio: number;
  35982. /**
  35983. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35984. */
  35985. currentDraggingPointerID: number;
  35986. /**
  35987. * If camera controls should be detached during the drag
  35988. */
  35989. detachCameraControls: boolean;
  35990. /**
  35991. * Fires each time a drag starts
  35992. */
  35993. onDragStartObservable: Observable<{}>;
  35994. /**
  35995. * Fires each time a drag ends (eg. mouse release after drag)
  35996. */
  35997. onDragEndObservable: Observable<{}>;
  35998. /**
  35999. * 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
  36000. */
  36001. constructor();
  36002. /**
  36003. * The name of the behavior
  36004. */
  36005. readonly name: string;
  36006. /**
  36007. * Initializes the behavior
  36008. */
  36009. init(): void;
  36010. /**
  36011. * Attaches the scale behavior the passed in mesh
  36012. * @param ownerNode The mesh that will be scaled around once attached
  36013. */
  36014. attach(ownerNode: Mesh): void;
  36015. /**
  36016. * Detaches the behavior from the mesh
  36017. */
  36018. detach(): void;
  36019. }
  36020. }
  36021. declare module BABYLON {
  36022. /**
  36023. * Class used to apply inverse kinematics to bones
  36024. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36025. */
  36026. export class BoneIKController {
  36027. private static _tmpVecs;
  36028. private static _tmpQuat;
  36029. private static _tmpMats;
  36030. /**
  36031. * Gets or sets the target mesh
  36032. */
  36033. targetMesh: AbstractMesh;
  36034. /** Gets or sets the mesh used as pole */
  36035. poleTargetMesh: AbstractMesh;
  36036. /**
  36037. * Gets or sets the bone used as pole
  36038. */
  36039. poleTargetBone: Nullable<Bone>;
  36040. /**
  36041. * Gets or sets the target position
  36042. */
  36043. targetPosition: Vector3;
  36044. /**
  36045. * Gets or sets the pole target position
  36046. */
  36047. poleTargetPosition: Vector3;
  36048. /**
  36049. * Gets or sets the pole target local offset
  36050. */
  36051. poleTargetLocalOffset: Vector3;
  36052. /**
  36053. * Gets or sets the pole angle
  36054. */
  36055. poleAngle: number;
  36056. /**
  36057. * Gets or sets the mesh associated with the controller
  36058. */
  36059. mesh: AbstractMesh;
  36060. /**
  36061. * 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)
  36062. */
  36063. slerpAmount: number;
  36064. private _bone1Quat;
  36065. private _bone1Mat;
  36066. private _bone2Ang;
  36067. private _bone1;
  36068. private _bone2;
  36069. private _bone1Length;
  36070. private _bone2Length;
  36071. private _maxAngle;
  36072. private _maxReach;
  36073. private _rightHandedSystem;
  36074. private _bendAxis;
  36075. private _slerping;
  36076. private _adjustRoll;
  36077. /**
  36078. * Gets or sets maximum allowed angle
  36079. */
  36080. maxAngle: number;
  36081. /**
  36082. * Creates a new BoneIKController
  36083. * @param mesh defines the mesh to control
  36084. * @param bone defines the bone to control
  36085. * @param options defines options to set up the controller
  36086. */
  36087. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36088. targetMesh?: AbstractMesh;
  36089. poleTargetMesh?: AbstractMesh;
  36090. poleTargetBone?: Bone;
  36091. poleTargetLocalOffset?: Vector3;
  36092. poleAngle?: number;
  36093. bendAxis?: Vector3;
  36094. maxAngle?: number;
  36095. slerpAmount?: number;
  36096. });
  36097. private _setMaxAngle;
  36098. /**
  36099. * Force the controller to update the bones
  36100. */
  36101. update(): void;
  36102. }
  36103. }
  36104. declare module BABYLON {
  36105. /**
  36106. * Class used to make a bone look toward a point in space
  36107. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36108. */
  36109. export class BoneLookController {
  36110. private static _tmpVecs;
  36111. private static _tmpQuat;
  36112. private static _tmpMats;
  36113. /**
  36114. * The target Vector3 that the bone will look at
  36115. */
  36116. target: Vector3;
  36117. /**
  36118. * The mesh that the bone is attached to
  36119. */
  36120. mesh: AbstractMesh;
  36121. /**
  36122. * The bone that will be looking to the target
  36123. */
  36124. bone: Bone;
  36125. /**
  36126. * The up axis of the coordinate system that is used when the bone is rotated
  36127. */
  36128. upAxis: Vector3;
  36129. /**
  36130. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36131. */
  36132. upAxisSpace: Space;
  36133. /**
  36134. * Used to make an adjustment to the yaw of the bone
  36135. */
  36136. adjustYaw: number;
  36137. /**
  36138. * Used to make an adjustment to the pitch of the bone
  36139. */
  36140. adjustPitch: number;
  36141. /**
  36142. * Used to make an adjustment to the roll of the bone
  36143. */
  36144. adjustRoll: number;
  36145. /**
  36146. * 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)
  36147. */
  36148. slerpAmount: number;
  36149. private _minYaw;
  36150. private _maxYaw;
  36151. private _minPitch;
  36152. private _maxPitch;
  36153. private _minYawSin;
  36154. private _minYawCos;
  36155. private _maxYawSin;
  36156. private _maxYawCos;
  36157. private _midYawConstraint;
  36158. private _minPitchTan;
  36159. private _maxPitchTan;
  36160. private _boneQuat;
  36161. private _slerping;
  36162. private _transformYawPitch;
  36163. private _transformYawPitchInv;
  36164. private _firstFrameSkipped;
  36165. private _yawRange;
  36166. private _fowardAxis;
  36167. /**
  36168. * Gets or sets the minimum yaw angle that the bone can look to
  36169. */
  36170. minYaw: number;
  36171. /**
  36172. * Gets or sets the maximum yaw angle that the bone can look to
  36173. */
  36174. maxYaw: number;
  36175. /**
  36176. * Gets or sets the minimum pitch angle that the bone can look to
  36177. */
  36178. minPitch: number;
  36179. /**
  36180. * Gets or sets the maximum pitch angle that the bone can look to
  36181. */
  36182. maxPitch: number;
  36183. /**
  36184. * Create a BoneLookController
  36185. * @param mesh the mesh that the bone belongs to
  36186. * @param bone the bone that will be looking to the target
  36187. * @param target the target Vector3 to look at
  36188. * @param options optional settings:
  36189. * * maxYaw: the maximum angle the bone will yaw to
  36190. * * minYaw: the minimum angle the bone will yaw to
  36191. * * maxPitch: the maximum angle the bone will pitch to
  36192. * * minPitch: the minimum angle the bone will yaw to
  36193. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36194. * * upAxis: the up axis of the coordinate system
  36195. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36196. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36197. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36198. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36199. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36200. * * adjustRoll: used to make an adjustment to the roll of the bone
  36201. **/
  36202. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36203. maxYaw?: number;
  36204. minYaw?: number;
  36205. maxPitch?: number;
  36206. minPitch?: number;
  36207. slerpAmount?: number;
  36208. upAxis?: Vector3;
  36209. upAxisSpace?: Space;
  36210. yawAxis?: Vector3;
  36211. pitchAxis?: Vector3;
  36212. adjustYaw?: number;
  36213. adjustPitch?: number;
  36214. adjustRoll?: number;
  36215. });
  36216. /**
  36217. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36218. */
  36219. update(): void;
  36220. private _getAngleDiff;
  36221. private _getAngleBetween;
  36222. private _isAngleBetween;
  36223. }
  36224. }
  36225. declare module BABYLON {
  36226. /**
  36227. * Manage the gamepad inputs to control an arc rotate camera.
  36228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36229. */
  36230. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36231. /**
  36232. * Defines the camera the input is attached to.
  36233. */
  36234. camera: ArcRotateCamera;
  36235. /**
  36236. * Defines the gamepad the input is gathering event from.
  36237. */
  36238. gamepad: Nullable<Gamepad>;
  36239. /**
  36240. * Defines the gamepad rotation sensiblity.
  36241. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36242. */
  36243. gamepadRotationSensibility: number;
  36244. /**
  36245. * Defines the gamepad move sensiblity.
  36246. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36247. */
  36248. gamepadMoveSensibility: number;
  36249. private _onGamepadConnectedObserver;
  36250. private _onGamepadDisconnectedObserver;
  36251. /**
  36252. * Attach the input controls to a specific dom element to get the input from.
  36253. * @param element Defines the element the controls should be listened from
  36254. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36255. */
  36256. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36257. /**
  36258. * Detach the current controls from the specified dom element.
  36259. * @param element Defines the element to stop listening the inputs from
  36260. */
  36261. detachControl(element: Nullable<HTMLElement>): void;
  36262. /**
  36263. * Update the current camera state depending on the inputs that have been used this frame.
  36264. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36265. */
  36266. checkInputs(): void;
  36267. /**
  36268. * Gets the class name of the current intput.
  36269. * @returns the class name
  36270. */
  36271. getClassName(): string;
  36272. /**
  36273. * Get the friendly name associated with the input class.
  36274. * @returns the input friendly name
  36275. */
  36276. getSimpleName(): string;
  36277. }
  36278. }
  36279. declare module BABYLON {
  36280. interface ArcRotateCameraInputsManager {
  36281. /**
  36282. * Add orientation input support to the input manager.
  36283. * @returns the current input manager
  36284. */
  36285. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36286. }
  36287. /**
  36288. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36289. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36290. */
  36291. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36292. /**
  36293. * Defines the camera the input is attached to.
  36294. */
  36295. camera: ArcRotateCamera;
  36296. /**
  36297. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36298. */
  36299. alphaCorrection: number;
  36300. /**
  36301. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36302. */
  36303. gammaCorrection: number;
  36304. private _alpha;
  36305. private _gamma;
  36306. private _dirty;
  36307. private _deviceOrientationHandler;
  36308. /**
  36309. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36310. */
  36311. constructor();
  36312. /**
  36313. * Attach the input controls to a specific dom element to get the input from.
  36314. * @param element Defines the element the controls should be listened from
  36315. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36316. */
  36317. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36318. /** @hidden */
  36319. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36320. /**
  36321. * Update the current camera state depending on the inputs that have been used this frame.
  36322. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36323. */
  36324. checkInputs(): void;
  36325. /**
  36326. * Detach the current controls from the specified dom element.
  36327. * @param element Defines the element to stop listening the inputs from
  36328. */
  36329. detachControl(element: Nullable<HTMLElement>): void;
  36330. /**
  36331. * Gets the class name of the current intput.
  36332. * @returns the class name
  36333. */
  36334. getClassName(): string;
  36335. /**
  36336. * Get the friendly name associated with the input class.
  36337. * @returns the input friendly name
  36338. */
  36339. getSimpleName(): string;
  36340. }
  36341. }
  36342. declare module BABYLON {
  36343. /**
  36344. * Listen to mouse events to control the camera.
  36345. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36346. */
  36347. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36348. /**
  36349. * Defines the camera the input is attached to.
  36350. */
  36351. camera: FlyCamera;
  36352. /**
  36353. * Defines if touch is enabled. (Default is true.)
  36354. */
  36355. touchEnabled: boolean;
  36356. /**
  36357. * Defines the buttons associated with the input to handle camera rotation.
  36358. */
  36359. buttons: number[];
  36360. /**
  36361. * Assign buttons for Yaw control.
  36362. */
  36363. buttonsYaw: number[];
  36364. /**
  36365. * Assign buttons for Pitch control.
  36366. */
  36367. buttonsPitch: number[];
  36368. /**
  36369. * Assign buttons for Roll control.
  36370. */
  36371. buttonsRoll: number[];
  36372. /**
  36373. * Detect if any button is being pressed while mouse is moved.
  36374. * -1 = Mouse locked.
  36375. * 0 = Left button.
  36376. * 1 = Middle Button.
  36377. * 2 = Right Button.
  36378. */
  36379. activeButton: number;
  36380. /**
  36381. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36382. * Higher values reduce its sensitivity.
  36383. */
  36384. angularSensibility: number;
  36385. private _mousemoveCallback;
  36386. private _observer;
  36387. private _rollObserver;
  36388. private previousPosition;
  36389. private noPreventDefault;
  36390. private element;
  36391. /**
  36392. * Listen to mouse events to control the camera.
  36393. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36394. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36395. */
  36396. constructor(touchEnabled?: boolean);
  36397. /**
  36398. * Attach the mouse control to the HTML DOM element.
  36399. * @param element Defines the element that listens to the input events.
  36400. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36401. */
  36402. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36403. /**
  36404. * Detach the current controls from the specified dom element.
  36405. * @param element Defines the element to stop listening the inputs from
  36406. */
  36407. detachControl(element: Nullable<HTMLElement>): void;
  36408. /**
  36409. * Gets the class name of the current input.
  36410. * @returns the class name.
  36411. */
  36412. getClassName(): string;
  36413. /**
  36414. * Get the friendly name associated with the input class.
  36415. * @returns the input's friendly name.
  36416. */
  36417. getSimpleName(): string;
  36418. private _pointerInput;
  36419. private _onMouseMove;
  36420. /**
  36421. * Rotate camera by mouse offset.
  36422. */
  36423. private rotateCamera;
  36424. }
  36425. }
  36426. declare module BABYLON {
  36427. /**
  36428. * Default Inputs manager for the FlyCamera.
  36429. * It groups all the default supported inputs for ease of use.
  36430. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36431. */
  36432. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36433. /**
  36434. * Instantiates a new FlyCameraInputsManager.
  36435. * @param camera Defines the camera the inputs belong to.
  36436. */
  36437. constructor(camera: FlyCamera);
  36438. /**
  36439. * Add keyboard input support to the input manager.
  36440. * @returns the new FlyCameraKeyboardMoveInput().
  36441. */
  36442. addKeyboard(): FlyCameraInputsManager;
  36443. /**
  36444. * Add mouse input support to the input manager.
  36445. * @param touchEnabled Enable touch screen support.
  36446. * @returns the new FlyCameraMouseInput().
  36447. */
  36448. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36449. }
  36450. }
  36451. declare module BABYLON {
  36452. /**
  36453. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36454. * such as in a 3D Space Shooter or a Flight Simulator.
  36455. */
  36456. export class FlyCamera extends TargetCamera {
  36457. /**
  36458. * Define the collision ellipsoid of the camera.
  36459. * This is helpful for simulating a camera body, like a player's body.
  36460. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36461. */
  36462. ellipsoid: Vector3;
  36463. /**
  36464. * Define an offset for the position of the ellipsoid around the camera.
  36465. * This can be helpful if the camera is attached away from the player's body center,
  36466. * such as at its head.
  36467. */
  36468. ellipsoidOffset: Vector3;
  36469. /**
  36470. * Enable or disable collisions of the camera with the rest of the scene objects.
  36471. */
  36472. checkCollisions: boolean;
  36473. /**
  36474. * Enable or disable gravity on the camera.
  36475. */
  36476. applyGravity: boolean;
  36477. /**
  36478. * Define the current direction the camera is moving to.
  36479. */
  36480. cameraDirection: Vector3;
  36481. /**
  36482. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36483. * This overrides and empties cameraRotation.
  36484. */
  36485. rotationQuaternion: Quaternion;
  36486. /**
  36487. * Track Roll to maintain the wanted Rolling when looking around.
  36488. */
  36489. _trackRoll: number;
  36490. /**
  36491. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36492. */
  36493. rollCorrect: number;
  36494. /**
  36495. * Mimic a banked turn, Rolling the camera when Yawing.
  36496. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36497. */
  36498. bankedTurn: boolean;
  36499. /**
  36500. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36501. */
  36502. bankedTurnLimit: number;
  36503. /**
  36504. * Value of 0 disables the banked Roll.
  36505. * Value of 1 is equal to the Yaw angle in radians.
  36506. */
  36507. bankedTurnMultiplier: number;
  36508. /**
  36509. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36510. */
  36511. inputs: FlyCameraInputsManager;
  36512. /**
  36513. * Gets the input sensibility for mouse input.
  36514. * Higher values reduce sensitivity.
  36515. */
  36516. /**
  36517. * Sets the input sensibility for a mouse input.
  36518. * Higher values reduce sensitivity.
  36519. */
  36520. angularSensibility: number;
  36521. /**
  36522. * Get the keys for camera movement forward.
  36523. */
  36524. /**
  36525. * Set the keys for camera movement forward.
  36526. */
  36527. keysForward: number[];
  36528. /**
  36529. * Get the keys for camera movement backward.
  36530. */
  36531. keysBackward: number[];
  36532. /**
  36533. * Get the keys for camera movement up.
  36534. */
  36535. /**
  36536. * Set the keys for camera movement up.
  36537. */
  36538. keysUp: number[];
  36539. /**
  36540. * Get the keys for camera movement down.
  36541. */
  36542. /**
  36543. * Set the keys for camera movement down.
  36544. */
  36545. keysDown: number[];
  36546. /**
  36547. * Get the keys for camera movement left.
  36548. */
  36549. /**
  36550. * Set the keys for camera movement left.
  36551. */
  36552. keysLeft: number[];
  36553. /**
  36554. * Set the keys for camera movement right.
  36555. */
  36556. /**
  36557. * Set the keys for camera movement right.
  36558. */
  36559. keysRight: number[];
  36560. /**
  36561. * Event raised when the camera collides with a mesh in the scene.
  36562. */
  36563. onCollide: (collidedMesh: AbstractMesh) => void;
  36564. private _collider;
  36565. private _needMoveForGravity;
  36566. private _oldPosition;
  36567. private _diffPosition;
  36568. private _newPosition;
  36569. /** @hidden */
  36570. _localDirection: Vector3;
  36571. /** @hidden */
  36572. _transformedDirection: Vector3;
  36573. /**
  36574. * Instantiates a FlyCamera.
  36575. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36576. * such as in a 3D Space Shooter or a Flight Simulator.
  36577. * @param name Define the name of the camera in the scene.
  36578. * @param position Define the starting position of the camera in the scene.
  36579. * @param scene Define the scene the camera belongs to.
  36580. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36581. */
  36582. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36583. /**
  36584. * Attach a control to the HTML DOM element.
  36585. * @param element Defines the element that listens to the input events.
  36586. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36587. */
  36588. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36589. /**
  36590. * Detach a control from the HTML DOM element.
  36591. * The camera will stop reacting to that input.
  36592. * @param element Defines the element that listens to the input events.
  36593. */
  36594. detachControl(element: HTMLElement): void;
  36595. private _collisionMask;
  36596. /**
  36597. * Get the mask that the camera ignores in collision events.
  36598. */
  36599. /**
  36600. * Set the mask that the camera ignores in collision events.
  36601. */
  36602. collisionMask: number;
  36603. /** @hidden */
  36604. _collideWithWorld(displacement: Vector3): void;
  36605. /** @hidden */
  36606. private _onCollisionPositionChange;
  36607. /** @hidden */
  36608. _checkInputs(): void;
  36609. /** @hidden */
  36610. _decideIfNeedsToMove(): boolean;
  36611. /** @hidden */
  36612. _updatePosition(): void;
  36613. /**
  36614. * Restore the Roll to its target value at the rate specified.
  36615. * @param rate - Higher means slower restoring.
  36616. * @hidden
  36617. */
  36618. restoreRoll(rate: number): void;
  36619. /**
  36620. * Destroy the camera and release the current resources held by it.
  36621. */
  36622. dispose(): void;
  36623. /**
  36624. * Get the current object class name.
  36625. * @returns the class name.
  36626. */
  36627. getClassName(): string;
  36628. }
  36629. }
  36630. declare module BABYLON {
  36631. /**
  36632. * Listen to keyboard events to control the camera.
  36633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36634. */
  36635. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36636. /**
  36637. * Defines the camera the input is attached to.
  36638. */
  36639. camera: FlyCamera;
  36640. /**
  36641. * The list of keyboard keys used to control the forward move of the camera.
  36642. */
  36643. keysForward: number[];
  36644. /**
  36645. * The list of keyboard keys used to control the backward move of the camera.
  36646. */
  36647. keysBackward: number[];
  36648. /**
  36649. * The list of keyboard keys used to control the forward move of the camera.
  36650. */
  36651. keysUp: number[];
  36652. /**
  36653. * The list of keyboard keys used to control the backward move of the camera.
  36654. */
  36655. keysDown: number[];
  36656. /**
  36657. * The list of keyboard keys used to control the right strafe move of the camera.
  36658. */
  36659. keysRight: number[];
  36660. /**
  36661. * The list of keyboard keys used to control the left strafe move of the camera.
  36662. */
  36663. keysLeft: number[];
  36664. private _keys;
  36665. private _onCanvasBlurObserver;
  36666. private _onKeyboardObserver;
  36667. private _engine;
  36668. private _scene;
  36669. /**
  36670. * Attach the input controls to a specific dom element to get the input from.
  36671. * @param element Defines the element the controls should be listened from
  36672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36673. */
  36674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36675. /**
  36676. * Detach the current controls from the specified dom element.
  36677. * @param element Defines the element to stop listening the inputs from
  36678. */
  36679. detachControl(element: Nullable<HTMLElement>): void;
  36680. /**
  36681. * Gets the class name of the current intput.
  36682. * @returns the class name
  36683. */
  36684. getClassName(): string;
  36685. /** @hidden */
  36686. _onLostFocus(e: FocusEvent): void;
  36687. /**
  36688. * Get the friendly name associated with the input class.
  36689. * @returns the input friendly name
  36690. */
  36691. getSimpleName(): string;
  36692. /**
  36693. * Update the current camera state depending on the inputs that have been used this frame.
  36694. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36695. */
  36696. checkInputs(): void;
  36697. }
  36698. }
  36699. declare module BABYLON {
  36700. /**
  36701. * Manage the mouse wheel inputs to control a follow camera.
  36702. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36703. */
  36704. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36705. /**
  36706. * Defines the camera the input is attached to.
  36707. */
  36708. camera: FollowCamera;
  36709. /**
  36710. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36711. */
  36712. axisControlRadius: boolean;
  36713. /**
  36714. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36715. */
  36716. axisControlHeight: boolean;
  36717. /**
  36718. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36719. */
  36720. axisControlRotation: boolean;
  36721. /**
  36722. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36723. * relation to mouseWheel events.
  36724. */
  36725. wheelPrecision: number;
  36726. /**
  36727. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36728. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36729. */
  36730. wheelDeltaPercentage: number;
  36731. private _wheel;
  36732. private _observer;
  36733. /**
  36734. * Attach the input controls to a specific dom element to get the input from.
  36735. * @param element Defines the element the controls should be listened from
  36736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36737. */
  36738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36739. /**
  36740. * Detach the current controls from the specified dom element.
  36741. * @param element Defines the element to stop listening the inputs from
  36742. */
  36743. detachControl(element: Nullable<HTMLElement>): void;
  36744. /**
  36745. * Gets the class name of the current intput.
  36746. * @returns the class name
  36747. */
  36748. getClassName(): string;
  36749. /**
  36750. * Get the friendly name associated with the input class.
  36751. * @returns the input friendly name
  36752. */
  36753. getSimpleName(): string;
  36754. }
  36755. }
  36756. declare module BABYLON {
  36757. /**
  36758. * Manage the pointers inputs to control an follow camera.
  36759. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36760. */
  36761. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36762. /**
  36763. * Defines the camera the input is attached to.
  36764. */
  36765. camera: FollowCamera;
  36766. /**
  36767. * Gets the class name of the current input.
  36768. * @returns the class name
  36769. */
  36770. getClassName(): string;
  36771. /**
  36772. * Defines the pointer angular sensibility along the X axis or how fast is
  36773. * the camera rotating.
  36774. * A negative number will reverse the axis direction.
  36775. */
  36776. angularSensibilityX: number;
  36777. /**
  36778. * Defines the pointer angular sensibility along the Y axis or how fast is
  36779. * the camera rotating.
  36780. * A negative number will reverse the axis direction.
  36781. */
  36782. angularSensibilityY: number;
  36783. /**
  36784. * Defines the pointer pinch precision or how fast is the camera zooming.
  36785. * A negative number will reverse the axis direction.
  36786. */
  36787. pinchPrecision: number;
  36788. /**
  36789. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36790. * from 0.
  36791. * It defines the percentage of current camera.radius to use as delta when
  36792. * pinch zoom is used.
  36793. */
  36794. pinchDeltaPercentage: number;
  36795. /**
  36796. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36797. */
  36798. axisXControlRadius: boolean;
  36799. /**
  36800. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36801. */
  36802. axisXControlHeight: boolean;
  36803. /**
  36804. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36805. */
  36806. axisXControlRotation: boolean;
  36807. /**
  36808. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36809. */
  36810. axisYControlRadius: boolean;
  36811. /**
  36812. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36813. */
  36814. axisYControlHeight: boolean;
  36815. /**
  36816. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36817. */
  36818. axisYControlRotation: boolean;
  36819. /**
  36820. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36821. */
  36822. axisPinchControlRadius: boolean;
  36823. /**
  36824. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36825. */
  36826. axisPinchControlHeight: boolean;
  36827. /**
  36828. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36829. */
  36830. axisPinchControlRotation: boolean;
  36831. /**
  36832. * Log error messages if basic misconfiguration has occurred.
  36833. */
  36834. warningEnable: boolean;
  36835. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36836. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36837. private _warningCounter;
  36838. private _warning;
  36839. }
  36840. }
  36841. declare module BABYLON {
  36842. /**
  36843. * Default Inputs manager for the FollowCamera.
  36844. * It groups all the default supported inputs for ease of use.
  36845. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36846. */
  36847. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36848. /**
  36849. * Instantiates a new FollowCameraInputsManager.
  36850. * @param camera Defines the camera the inputs belong to
  36851. */
  36852. constructor(camera: FollowCamera);
  36853. /**
  36854. * Add keyboard input support to the input manager.
  36855. * @returns the current input manager
  36856. */
  36857. addKeyboard(): FollowCameraInputsManager;
  36858. /**
  36859. * Add mouse wheel input support to the input manager.
  36860. * @returns the current input manager
  36861. */
  36862. addMouseWheel(): FollowCameraInputsManager;
  36863. /**
  36864. * Add pointers input support to the input manager.
  36865. * @returns the current input manager
  36866. */
  36867. addPointers(): FollowCameraInputsManager;
  36868. /**
  36869. * Add orientation input support to the input manager.
  36870. * @returns the current input manager
  36871. */
  36872. addVRDeviceOrientation(): FollowCameraInputsManager;
  36873. }
  36874. }
  36875. declare module BABYLON {
  36876. /**
  36877. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36878. * an arc rotate version arcFollowCamera are available.
  36879. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36880. */
  36881. export class FollowCamera extends TargetCamera {
  36882. /**
  36883. * Distance the follow camera should follow an object at
  36884. */
  36885. radius: number;
  36886. /**
  36887. * Minimum allowed distance of the camera to the axis of rotation
  36888. * (The camera can not get closer).
  36889. * This can help limiting how the Camera is able to move in the scene.
  36890. */
  36891. lowerRadiusLimit: Nullable<number>;
  36892. /**
  36893. * Maximum allowed distance of the camera to the axis of rotation
  36894. * (The camera can not get further).
  36895. * This can help limiting how the Camera is able to move in the scene.
  36896. */
  36897. upperRadiusLimit: Nullable<number>;
  36898. /**
  36899. * Define a rotation offset between the camera and the object it follows
  36900. */
  36901. rotationOffset: number;
  36902. /**
  36903. * Minimum allowed angle to camera position relative to target object.
  36904. * This can help limiting how the Camera is able to move in the scene.
  36905. */
  36906. lowerRotationOffsetLimit: Nullable<number>;
  36907. /**
  36908. * Maximum allowed angle to camera position relative to target object.
  36909. * This can help limiting how the Camera is able to move in the scene.
  36910. */
  36911. upperRotationOffsetLimit: Nullable<number>;
  36912. /**
  36913. * Define a height offset between the camera and the object it follows.
  36914. * It can help following an object from the top (like a car chaing a plane)
  36915. */
  36916. heightOffset: number;
  36917. /**
  36918. * Minimum allowed height of camera position relative to target object.
  36919. * This can help limiting how the Camera is able to move in the scene.
  36920. */
  36921. lowerHeightOffsetLimit: Nullable<number>;
  36922. /**
  36923. * Maximum allowed height of camera position relative to target object.
  36924. * This can help limiting how the Camera is able to move in the scene.
  36925. */
  36926. upperHeightOffsetLimit: Nullable<number>;
  36927. /**
  36928. * Define how fast the camera can accelerate to follow it s target.
  36929. */
  36930. cameraAcceleration: number;
  36931. /**
  36932. * Define the speed limit of the camera following an object.
  36933. */
  36934. maxCameraSpeed: number;
  36935. /**
  36936. * Define the target of the camera.
  36937. */
  36938. lockedTarget: Nullable<AbstractMesh>;
  36939. /**
  36940. * Defines the input associated with the camera.
  36941. */
  36942. inputs: FollowCameraInputsManager;
  36943. /**
  36944. * Instantiates the follow camera.
  36945. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36946. * @param name Define the name of the camera in the scene
  36947. * @param position Define the position of the camera
  36948. * @param scene Define the scene the camera belong to
  36949. * @param lockedTarget Define the target of the camera
  36950. */
  36951. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36952. private _follow;
  36953. /**
  36954. * Attached controls to the current camera.
  36955. * @param element Defines the element the controls should be listened from
  36956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36957. */
  36958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36959. /**
  36960. * Detach the current controls from the camera.
  36961. * The camera will stop reacting to inputs.
  36962. * @param element Defines the element to stop listening the inputs from
  36963. */
  36964. detachControl(element: HTMLElement): void;
  36965. /** @hidden */
  36966. _checkInputs(): void;
  36967. private _checkLimits;
  36968. /**
  36969. * Gets the camera class name.
  36970. * @returns the class name
  36971. */
  36972. getClassName(): string;
  36973. }
  36974. /**
  36975. * Arc Rotate version of the follow camera.
  36976. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36977. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36978. */
  36979. export class ArcFollowCamera extends TargetCamera {
  36980. /** The longitudinal angle of the camera */
  36981. alpha: number;
  36982. /** The latitudinal angle of the camera */
  36983. beta: number;
  36984. /** The radius of the camera from its target */
  36985. radius: number;
  36986. /** Define the camera target (the messh it should follow) */
  36987. target: Nullable<AbstractMesh>;
  36988. private _cartesianCoordinates;
  36989. /**
  36990. * Instantiates a new ArcFollowCamera
  36991. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36992. * @param name Define the name of the camera
  36993. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36994. * @param beta Define the rotation angle of the camera around the elevation axis
  36995. * @param radius Define the radius of the camera from its target point
  36996. * @param target Define the target of the camera
  36997. * @param scene Define the scene the camera belongs to
  36998. */
  36999. constructor(name: string,
  37000. /** The longitudinal angle of the camera */
  37001. alpha: number,
  37002. /** The latitudinal angle of the camera */
  37003. beta: number,
  37004. /** The radius of the camera from its target */
  37005. radius: number,
  37006. /** Define the camera target (the messh it should follow) */
  37007. target: Nullable<AbstractMesh>, scene: Scene);
  37008. private _follow;
  37009. /** @hidden */
  37010. _checkInputs(): void;
  37011. /**
  37012. * Returns the class name of the object.
  37013. * It is mostly used internally for serialization purposes.
  37014. */
  37015. getClassName(): string;
  37016. }
  37017. }
  37018. declare module BABYLON {
  37019. /**
  37020. * Manage the keyboard inputs to control the movement of a follow camera.
  37021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37022. */
  37023. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37024. /**
  37025. * Defines the camera the input is attached to.
  37026. */
  37027. camera: FollowCamera;
  37028. /**
  37029. * Defines the list of key codes associated with the up action (increase heightOffset)
  37030. */
  37031. keysHeightOffsetIncr: number[];
  37032. /**
  37033. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37034. */
  37035. keysHeightOffsetDecr: number[];
  37036. /**
  37037. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37038. */
  37039. keysHeightOffsetModifierAlt: boolean;
  37040. /**
  37041. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37042. */
  37043. keysHeightOffsetModifierCtrl: boolean;
  37044. /**
  37045. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37046. */
  37047. keysHeightOffsetModifierShift: boolean;
  37048. /**
  37049. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37050. */
  37051. keysRotationOffsetIncr: number[];
  37052. /**
  37053. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37054. */
  37055. keysRotationOffsetDecr: number[];
  37056. /**
  37057. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37058. */
  37059. keysRotationOffsetModifierAlt: boolean;
  37060. /**
  37061. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37062. */
  37063. keysRotationOffsetModifierCtrl: boolean;
  37064. /**
  37065. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37066. */
  37067. keysRotationOffsetModifierShift: boolean;
  37068. /**
  37069. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37070. */
  37071. keysRadiusIncr: number[];
  37072. /**
  37073. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37074. */
  37075. keysRadiusDecr: number[];
  37076. /**
  37077. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37078. */
  37079. keysRadiusModifierAlt: boolean;
  37080. /**
  37081. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37082. */
  37083. keysRadiusModifierCtrl: boolean;
  37084. /**
  37085. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37086. */
  37087. keysRadiusModifierShift: boolean;
  37088. /**
  37089. * Defines the rate of change of heightOffset.
  37090. */
  37091. heightSensibility: number;
  37092. /**
  37093. * Defines the rate of change of rotationOffset.
  37094. */
  37095. rotationSensibility: number;
  37096. /**
  37097. * Defines the rate of change of radius.
  37098. */
  37099. radiusSensibility: number;
  37100. private _keys;
  37101. private _ctrlPressed;
  37102. private _altPressed;
  37103. private _shiftPressed;
  37104. private _onCanvasBlurObserver;
  37105. private _onKeyboardObserver;
  37106. private _engine;
  37107. private _scene;
  37108. /**
  37109. * Attach the input controls to a specific dom element to get the input from.
  37110. * @param element Defines the element the controls should be listened from
  37111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37112. */
  37113. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37114. /**
  37115. * Detach the current controls from the specified dom element.
  37116. * @param element Defines the element to stop listening the inputs from
  37117. */
  37118. detachControl(element: Nullable<HTMLElement>): void;
  37119. /**
  37120. * Update the current camera state depending on the inputs that have been used this frame.
  37121. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37122. */
  37123. checkInputs(): void;
  37124. /**
  37125. * Gets the class name of the current input.
  37126. * @returns the class name
  37127. */
  37128. getClassName(): string;
  37129. /**
  37130. * Get the friendly name associated with the input class.
  37131. * @returns the input friendly name
  37132. */
  37133. getSimpleName(): string;
  37134. /**
  37135. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37136. * allow modification of the heightOffset value.
  37137. */
  37138. private _modifierHeightOffset;
  37139. /**
  37140. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37141. * allow modification of the rotationOffset value.
  37142. */
  37143. private _modifierRotationOffset;
  37144. /**
  37145. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37146. * allow modification of the radius value.
  37147. */
  37148. private _modifierRadius;
  37149. }
  37150. }
  37151. declare module BABYLON {
  37152. interface FreeCameraInputsManager {
  37153. /**
  37154. * @hidden
  37155. */
  37156. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37157. /**
  37158. * Add orientation input support to the input manager.
  37159. * @returns the current input manager
  37160. */
  37161. addDeviceOrientation(): FreeCameraInputsManager;
  37162. }
  37163. /**
  37164. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37165. * Screen rotation is taken into account.
  37166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37167. */
  37168. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37169. private _camera;
  37170. private _screenOrientationAngle;
  37171. private _constantTranform;
  37172. private _screenQuaternion;
  37173. private _alpha;
  37174. private _beta;
  37175. private _gamma;
  37176. /**
  37177. * @hidden
  37178. */
  37179. _onDeviceOrientationChangedObservable: Observable<void>;
  37180. /**
  37181. * Instantiates a new input
  37182. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37183. */
  37184. constructor();
  37185. /**
  37186. * Define the camera controlled by the input.
  37187. */
  37188. camera: FreeCamera;
  37189. /**
  37190. * Attach the input controls to a specific dom element to get the input from.
  37191. * @param element Defines the element the controls should be listened from
  37192. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37193. */
  37194. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37195. private _orientationChanged;
  37196. private _deviceOrientation;
  37197. /**
  37198. * Detach the current controls from the specified dom element.
  37199. * @param element Defines the element to stop listening the inputs from
  37200. */
  37201. detachControl(element: Nullable<HTMLElement>): void;
  37202. /**
  37203. * Update the current camera state depending on the inputs that have been used this frame.
  37204. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37205. */
  37206. checkInputs(): void;
  37207. /**
  37208. * Gets the class name of the current intput.
  37209. * @returns the class name
  37210. */
  37211. getClassName(): string;
  37212. /**
  37213. * Get the friendly name associated with the input class.
  37214. * @returns the input friendly name
  37215. */
  37216. getSimpleName(): string;
  37217. }
  37218. }
  37219. declare module BABYLON {
  37220. /**
  37221. * Manage the gamepad inputs to control a free camera.
  37222. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37223. */
  37224. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37225. /**
  37226. * Define the camera the input is attached to.
  37227. */
  37228. camera: FreeCamera;
  37229. /**
  37230. * Define the Gamepad controlling the input
  37231. */
  37232. gamepad: Nullable<Gamepad>;
  37233. /**
  37234. * Defines the gamepad rotation sensiblity.
  37235. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37236. */
  37237. gamepadAngularSensibility: number;
  37238. /**
  37239. * Defines the gamepad move sensiblity.
  37240. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37241. */
  37242. gamepadMoveSensibility: number;
  37243. private _onGamepadConnectedObserver;
  37244. private _onGamepadDisconnectedObserver;
  37245. private _cameraTransform;
  37246. private _deltaTransform;
  37247. private _vector3;
  37248. private _vector2;
  37249. /**
  37250. * Attach the input controls to a specific dom element to get the input from.
  37251. * @param element Defines the element the controls should be listened from
  37252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37253. */
  37254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37255. /**
  37256. * Detach the current controls from the specified dom element.
  37257. * @param element Defines the element to stop listening the inputs from
  37258. */
  37259. detachControl(element: Nullable<HTMLElement>): void;
  37260. /**
  37261. * Update the current camera state depending on the inputs that have been used this frame.
  37262. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37263. */
  37264. checkInputs(): void;
  37265. /**
  37266. * Gets the class name of the current intput.
  37267. * @returns the class name
  37268. */
  37269. getClassName(): string;
  37270. /**
  37271. * Get the friendly name associated with the input class.
  37272. * @returns the input friendly name
  37273. */
  37274. getSimpleName(): string;
  37275. }
  37276. }
  37277. declare module BABYLON {
  37278. /**
  37279. * Defines the potential axis of a Joystick
  37280. */
  37281. export enum JoystickAxis {
  37282. /** X axis */
  37283. X = 0,
  37284. /** Y axis */
  37285. Y = 1,
  37286. /** Z axis */
  37287. Z = 2
  37288. }
  37289. /**
  37290. * Class used to define virtual joystick (used in touch mode)
  37291. */
  37292. export class VirtualJoystick {
  37293. /**
  37294. * Gets or sets a boolean indicating that left and right values must be inverted
  37295. */
  37296. reverseLeftRight: boolean;
  37297. /**
  37298. * Gets or sets a boolean indicating that up and down values must be inverted
  37299. */
  37300. reverseUpDown: boolean;
  37301. /**
  37302. * Gets the offset value for the position (ie. the change of the position value)
  37303. */
  37304. deltaPosition: Vector3;
  37305. /**
  37306. * Gets a boolean indicating if the virtual joystick was pressed
  37307. */
  37308. pressed: boolean;
  37309. /**
  37310. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37311. */
  37312. static Canvas: Nullable<HTMLCanvasElement>;
  37313. private static _globalJoystickIndex;
  37314. private static vjCanvasContext;
  37315. private static vjCanvasWidth;
  37316. private static vjCanvasHeight;
  37317. private static halfWidth;
  37318. private _action;
  37319. private _axisTargetedByLeftAndRight;
  37320. private _axisTargetedByUpAndDown;
  37321. private _joystickSensibility;
  37322. private _inversedSensibility;
  37323. private _joystickPointerID;
  37324. private _joystickColor;
  37325. private _joystickPointerPos;
  37326. private _joystickPreviousPointerPos;
  37327. private _joystickPointerStartPos;
  37328. private _deltaJoystickVector;
  37329. private _leftJoystick;
  37330. private _touches;
  37331. private _onPointerDownHandlerRef;
  37332. private _onPointerMoveHandlerRef;
  37333. private _onPointerUpHandlerRef;
  37334. private _onResize;
  37335. /**
  37336. * Creates a new virtual joystick
  37337. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37338. */
  37339. constructor(leftJoystick?: boolean);
  37340. /**
  37341. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37342. * @param newJoystickSensibility defines the new sensibility
  37343. */
  37344. setJoystickSensibility(newJoystickSensibility: number): void;
  37345. private _onPointerDown;
  37346. private _onPointerMove;
  37347. private _onPointerUp;
  37348. /**
  37349. * Change the color of the virtual joystick
  37350. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37351. */
  37352. setJoystickColor(newColor: string): void;
  37353. /**
  37354. * Defines a callback to call when the joystick is touched
  37355. * @param action defines the callback
  37356. */
  37357. setActionOnTouch(action: () => any): void;
  37358. /**
  37359. * Defines which axis you'd like to control for left & right
  37360. * @param axis defines the axis to use
  37361. */
  37362. setAxisForLeftRight(axis: JoystickAxis): void;
  37363. /**
  37364. * Defines which axis you'd like to control for up & down
  37365. * @param axis defines the axis to use
  37366. */
  37367. setAxisForUpDown(axis: JoystickAxis): void;
  37368. private _drawVirtualJoystick;
  37369. /**
  37370. * Release internal HTML canvas
  37371. */
  37372. releaseCanvas(): void;
  37373. }
  37374. }
  37375. declare module BABYLON {
  37376. interface FreeCameraInputsManager {
  37377. /**
  37378. * Add virtual joystick input support to the input manager.
  37379. * @returns the current input manager
  37380. */
  37381. addVirtualJoystick(): FreeCameraInputsManager;
  37382. }
  37383. /**
  37384. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37385. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37386. */
  37387. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37388. /**
  37389. * Defines the camera the input is attached to.
  37390. */
  37391. camera: FreeCamera;
  37392. private _leftjoystick;
  37393. private _rightjoystick;
  37394. /**
  37395. * Gets the left stick of the virtual joystick.
  37396. * @returns The virtual Joystick
  37397. */
  37398. getLeftJoystick(): VirtualJoystick;
  37399. /**
  37400. * Gets the right stick of the virtual joystick.
  37401. * @returns The virtual Joystick
  37402. */
  37403. getRightJoystick(): VirtualJoystick;
  37404. /**
  37405. * Update the current camera state depending on the inputs that have been used this frame.
  37406. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37407. */
  37408. checkInputs(): void;
  37409. /**
  37410. * Attach the input controls to a specific dom element to get the input from.
  37411. * @param element Defines the element the controls should be listened from
  37412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37413. */
  37414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37415. /**
  37416. * Detach the current controls from the specified dom element.
  37417. * @param element Defines the element to stop listening the inputs from
  37418. */
  37419. detachControl(element: Nullable<HTMLElement>): void;
  37420. /**
  37421. * Gets the class name of the current intput.
  37422. * @returns the class name
  37423. */
  37424. getClassName(): string;
  37425. /**
  37426. * Get the friendly name associated with the input class.
  37427. * @returns the input friendly name
  37428. */
  37429. getSimpleName(): string;
  37430. }
  37431. }
  37432. declare module BABYLON {
  37433. /**
  37434. * This represents a FPS type of camera controlled by touch.
  37435. * This is like a universal camera minus the Gamepad controls.
  37436. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37437. */
  37438. export class TouchCamera extends FreeCamera {
  37439. /**
  37440. * Defines the touch sensibility for rotation.
  37441. * The higher the faster.
  37442. */
  37443. touchAngularSensibility: number;
  37444. /**
  37445. * Defines the touch sensibility for move.
  37446. * The higher the faster.
  37447. */
  37448. touchMoveSensibility: number;
  37449. /**
  37450. * Instantiates a new touch camera.
  37451. * This represents a FPS type of camera controlled by touch.
  37452. * This is like a universal camera minus the Gamepad controls.
  37453. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37454. * @param name Define the name of the camera in the scene
  37455. * @param position Define the start position of the camera in the scene
  37456. * @param scene Define the scene the camera belongs to
  37457. */
  37458. constructor(name: string, position: Vector3, scene: Scene);
  37459. /**
  37460. * Gets the current object class name.
  37461. * @return the class name
  37462. */
  37463. getClassName(): string;
  37464. /** @hidden */
  37465. _setupInputs(): void;
  37466. }
  37467. }
  37468. declare module BABYLON {
  37469. /**
  37470. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37471. * being tilted forward or back and left or right.
  37472. */
  37473. export class DeviceOrientationCamera extends FreeCamera {
  37474. private _initialQuaternion;
  37475. private _quaternionCache;
  37476. private _tmpDragQuaternion;
  37477. /**
  37478. * Creates a new device orientation camera
  37479. * @param name The name of the camera
  37480. * @param position The start position camera
  37481. * @param scene The scene the camera belongs to
  37482. */
  37483. constructor(name: string, position: Vector3, scene: Scene);
  37484. /**
  37485. * @hidden
  37486. * Disabled pointer input on first orientation sensor update (Default: true)
  37487. */
  37488. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37489. private _dragFactor;
  37490. /**
  37491. * Enabled turning on the y axis when the orientation sensor is active
  37492. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37493. */
  37494. enableHorizontalDragging(dragFactor?: number): void;
  37495. /**
  37496. * Gets the current instance class name ("DeviceOrientationCamera").
  37497. * This helps avoiding instanceof at run time.
  37498. * @returns the class name
  37499. */
  37500. getClassName(): string;
  37501. /**
  37502. * @hidden
  37503. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37504. */
  37505. _checkInputs(): void;
  37506. /**
  37507. * Reset the camera to its default orientation on the specified axis only.
  37508. * @param axis The axis to reset
  37509. */
  37510. resetToCurrentRotation(axis?: Axis): void;
  37511. }
  37512. }
  37513. declare module BABYLON {
  37514. /**
  37515. * Defines supported buttons for XBox360 compatible gamepads
  37516. */
  37517. export enum Xbox360Button {
  37518. /** A */
  37519. A = 0,
  37520. /** B */
  37521. B = 1,
  37522. /** X */
  37523. X = 2,
  37524. /** Y */
  37525. Y = 3,
  37526. /** Start */
  37527. Start = 4,
  37528. /** Back */
  37529. Back = 5,
  37530. /** Left button */
  37531. LB = 6,
  37532. /** Right button */
  37533. RB = 7,
  37534. /** Left stick */
  37535. LeftStick = 8,
  37536. /** Right stick */
  37537. RightStick = 9
  37538. }
  37539. /** Defines values for XBox360 DPad */
  37540. export enum Xbox360Dpad {
  37541. /** Up */
  37542. Up = 0,
  37543. /** Down */
  37544. Down = 1,
  37545. /** Left */
  37546. Left = 2,
  37547. /** Right */
  37548. Right = 3
  37549. }
  37550. /**
  37551. * Defines a XBox360 gamepad
  37552. */
  37553. export class Xbox360Pad extends Gamepad {
  37554. private _leftTrigger;
  37555. private _rightTrigger;
  37556. private _onlefttriggerchanged;
  37557. private _onrighttriggerchanged;
  37558. private _onbuttondown;
  37559. private _onbuttonup;
  37560. private _ondpaddown;
  37561. private _ondpadup;
  37562. /** Observable raised when a button is pressed */
  37563. onButtonDownObservable: Observable<Xbox360Button>;
  37564. /** Observable raised when a button is released */
  37565. onButtonUpObservable: Observable<Xbox360Button>;
  37566. /** Observable raised when a pad is pressed */
  37567. onPadDownObservable: Observable<Xbox360Dpad>;
  37568. /** Observable raised when a pad is released */
  37569. onPadUpObservable: Observable<Xbox360Dpad>;
  37570. private _buttonA;
  37571. private _buttonB;
  37572. private _buttonX;
  37573. private _buttonY;
  37574. private _buttonBack;
  37575. private _buttonStart;
  37576. private _buttonLB;
  37577. private _buttonRB;
  37578. private _buttonLeftStick;
  37579. private _buttonRightStick;
  37580. private _dPadUp;
  37581. private _dPadDown;
  37582. private _dPadLeft;
  37583. private _dPadRight;
  37584. private _isXboxOnePad;
  37585. /**
  37586. * Creates a new XBox360 gamepad object
  37587. * @param id defines the id of this gamepad
  37588. * @param index defines its index
  37589. * @param gamepad defines the internal HTML gamepad object
  37590. * @param xboxOne defines if it is a XBox One gamepad
  37591. */
  37592. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37593. /**
  37594. * Defines the callback to call when left trigger is pressed
  37595. * @param callback defines the callback to use
  37596. */
  37597. onlefttriggerchanged(callback: (value: number) => void): void;
  37598. /**
  37599. * Defines the callback to call when right trigger is pressed
  37600. * @param callback defines the callback to use
  37601. */
  37602. onrighttriggerchanged(callback: (value: number) => void): void;
  37603. /**
  37604. * Gets the left trigger value
  37605. */
  37606. /**
  37607. * Sets the left trigger value
  37608. */
  37609. leftTrigger: number;
  37610. /**
  37611. * Gets the right trigger value
  37612. */
  37613. /**
  37614. * Sets the right trigger value
  37615. */
  37616. rightTrigger: number;
  37617. /**
  37618. * Defines the callback to call when a button is pressed
  37619. * @param callback defines the callback to use
  37620. */
  37621. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37622. /**
  37623. * Defines the callback to call when a button is released
  37624. * @param callback defines the callback to use
  37625. */
  37626. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37627. /**
  37628. * Defines the callback to call when a pad is pressed
  37629. * @param callback defines the callback to use
  37630. */
  37631. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37632. /**
  37633. * Defines the callback to call when a pad is released
  37634. * @param callback defines the callback to use
  37635. */
  37636. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37637. private _setButtonValue;
  37638. private _setDPadValue;
  37639. /**
  37640. * Gets the value of the `A` button
  37641. */
  37642. /**
  37643. * Sets the value of the `A` button
  37644. */
  37645. buttonA: number;
  37646. /**
  37647. * Gets the value of the `B` button
  37648. */
  37649. /**
  37650. * Sets the value of the `B` button
  37651. */
  37652. buttonB: number;
  37653. /**
  37654. * Gets the value of the `X` button
  37655. */
  37656. /**
  37657. * Sets the value of the `X` button
  37658. */
  37659. buttonX: number;
  37660. /**
  37661. * Gets the value of the `Y` button
  37662. */
  37663. /**
  37664. * Sets the value of the `Y` button
  37665. */
  37666. buttonY: number;
  37667. /**
  37668. * Gets the value of the `Start` button
  37669. */
  37670. /**
  37671. * Sets the value of the `Start` button
  37672. */
  37673. buttonStart: number;
  37674. /**
  37675. * Gets the value of the `Back` button
  37676. */
  37677. /**
  37678. * Sets the value of the `Back` button
  37679. */
  37680. buttonBack: number;
  37681. /**
  37682. * Gets the value of the `Left` button
  37683. */
  37684. /**
  37685. * Sets the value of the `Left` button
  37686. */
  37687. buttonLB: number;
  37688. /**
  37689. * Gets the value of the `Right` button
  37690. */
  37691. /**
  37692. * Sets the value of the `Right` button
  37693. */
  37694. buttonRB: number;
  37695. /**
  37696. * Gets the value of the Left joystick
  37697. */
  37698. /**
  37699. * Sets the value of the Left joystick
  37700. */
  37701. buttonLeftStick: number;
  37702. /**
  37703. * Gets the value of the Right joystick
  37704. */
  37705. /**
  37706. * Sets the value of the Right joystick
  37707. */
  37708. buttonRightStick: number;
  37709. /**
  37710. * Gets the value of D-pad up
  37711. */
  37712. /**
  37713. * Sets the value of D-pad up
  37714. */
  37715. dPadUp: number;
  37716. /**
  37717. * Gets the value of D-pad down
  37718. */
  37719. /**
  37720. * Sets the value of D-pad down
  37721. */
  37722. dPadDown: number;
  37723. /**
  37724. * Gets the value of D-pad left
  37725. */
  37726. /**
  37727. * Sets the value of D-pad left
  37728. */
  37729. dPadLeft: number;
  37730. /**
  37731. * Gets the value of D-pad right
  37732. */
  37733. /**
  37734. * Sets the value of D-pad right
  37735. */
  37736. dPadRight: number;
  37737. /**
  37738. * Force the gamepad to synchronize with device values
  37739. */
  37740. update(): void;
  37741. /**
  37742. * Disposes the gamepad
  37743. */
  37744. dispose(): void;
  37745. }
  37746. }
  37747. declare module BABYLON {
  37748. /**
  37749. * Manager for handling gamepads
  37750. */
  37751. export class GamepadManager {
  37752. private _scene?;
  37753. private _babylonGamepads;
  37754. private _oneGamepadConnected;
  37755. /** @hidden */
  37756. _isMonitoring: boolean;
  37757. private _gamepadEventSupported;
  37758. private _gamepadSupport;
  37759. /**
  37760. * observable to be triggered when the gamepad controller has been connected
  37761. */
  37762. onGamepadConnectedObservable: Observable<Gamepad>;
  37763. /**
  37764. * observable to be triggered when the gamepad controller has been disconnected
  37765. */
  37766. onGamepadDisconnectedObservable: Observable<Gamepad>;
  37767. private _onGamepadConnectedEvent;
  37768. private _onGamepadDisconnectedEvent;
  37769. /**
  37770. * Initializes the gamepad manager
  37771. * @param _scene BabylonJS scene
  37772. */
  37773. constructor(_scene?: Scene | undefined);
  37774. /**
  37775. * The gamepads in the game pad manager
  37776. */
  37777. readonly gamepads: Gamepad[];
  37778. /**
  37779. * Get the gamepad controllers based on type
  37780. * @param type The type of gamepad controller
  37781. * @returns Nullable gamepad
  37782. */
  37783. getGamepadByType(type?: number): Nullable<Gamepad>;
  37784. /**
  37785. * Disposes the gamepad manager
  37786. */
  37787. dispose(): void;
  37788. private _addNewGamepad;
  37789. private _startMonitoringGamepads;
  37790. private _stopMonitoringGamepads;
  37791. /** @hidden */
  37792. _checkGamepadsStatus(): void;
  37793. private _updateGamepadObjects;
  37794. }
  37795. }
  37796. declare module BABYLON {
  37797. interface Scene {
  37798. /** @hidden */
  37799. _gamepadManager: Nullable<GamepadManager>;
  37800. /**
  37801. * Gets the gamepad manager associated with the scene
  37802. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  37803. */
  37804. gamepadManager: GamepadManager;
  37805. }
  37806. /**
  37807. * Interface representing a free camera inputs manager
  37808. */
  37809. interface FreeCameraInputsManager {
  37810. /**
  37811. * Adds gamepad input support to the FreeCameraInputsManager.
  37812. * @returns the FreeCameraInputsManager
  37813. */
  37814. addGamepad(): FreeCameraInputsManager;
  37815. }
  37816. /**
  37817. * Interface representing an arc rotate camera inputs manager
  37818. */
  37819. interface ArcRotateCameraInputsManager {
  37820. /**
  37821. * Adds gamepad input support to the ArcRotateCamera InputManager.
  37822. * @returns the camera inputs manager
  37823. */
  37824. addGamepad(): ArcRotateCameraInputsManager;
  37825. }
  37826. /**
  37827. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37828. */
  37829. export class GamepadSystemSceneComponent implements ISceneComponent {
  37830. /**
  37831. * The component name helpfull to identify the component in the list of scene components.
  37832. */
  37833. readonly name: string;
  37834. /**
  37835. * The scene the component belongs to.
  37836. */
  37837. scene: Scene;
  37838. /**
  37839. * Creates a new instance of the component for the given scene
  37840. * @param scene Defines the scene to register the component in
  37841. */
  37842. constructor(scene: Scene);
  37843. /**
  37844. * Registers the component in a given scene
  37845. */
  37846. register(): void;
  37847. /**
  37848. * Rebuilds the elements related to this component in case of
  37849. * context lost for instance.
  37850. */
  37851. rebuild(): void;
  37852. /**
  37853. * Disposes the component and the associated ressources
  37854. */
  37855. dispose(): void;
  37856. private _beforeCameraUpdate;
  37857. }
  37858. }
  37859. declare module BABYLON {
  37860. /**
  37861. * 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,
  37862. * which still works and will still be found in many Playgrounds.
  37863. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37864. */
  37865. export class UniversalCamera extends TouchCamera {
  37866. /**
  37867. * Defines the gamepad rotation sensiblity.
  37868. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37869. */
  37870. gamepadAngularSensibility: number;
  37871. /**
  37872. * Defines the gamepad move sensiblity.
  37873. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37874. */
  37875. gamepadMoveSensibility: number;
  37876. /**
  37877. * 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,
  37878. * which still works and will still be found in many Playgrounds.
  37879. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37880. * @param name Define the name of the camera in the scene
  37881. * @param position Define the start position of the camera in the scene
  37882. * @param scene Define the scene the camera belongs to
  37883. */
  37884. constructor(name: string, position: Vector3, scene: Scene);
  37885. /**
  37886. * Gets the current object class name.
  37887. * @return the class name
  37888. */
  37889. getClassName(): string;
  37890. }
  37891. }
  37892. declare module BABYLON {
  37893. /**
  37894. * This represents a FPS type of camera. This is only here for back compat purpose.
  37895. * Please use the UniversalCamera instead as both are identical.
  37896. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37897. */
  37898. export class GamepadCamera extends UniversalCamera {
  37899. /**
  37900. * Instantiates a new Gamepad Camera
  37901. * This represents a FPS type of camera. This is only here for back compat purpose.
  37902. * Please use the UniversalCamera instead as both are identical.
  37903. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37904. * @param name Define the name of the camera in the scene
  37905. * @param position Define the start position of the camera in the scene
  37906. * @param scene Define the scene the camera belongs to
  37907. */
  37908. constructor(name: string, position: Vector3, scene: Scene);
  37909. /**
  37910. * Gets the current object class name.
  37911. * @return the class name
  37912. */
  37913. getClassName(): string;
  37914. }
  37915. }
  37916. declare module BABYLON {
  37917. /** @hidden */
  37918. export var passPixelShader: {
  37919. name: string;
  37920. shader: string;
  37921. };
  37922. }
  37923. declare module BABYLON {
  37924. /** @hidden */
  37925. export var passCubePixelShader: {
  37926. name: string;
  37927. shader: string;
  37928. };
  37929. }
  37930. declare module BABYLON {
  37931. /**
  37932. * PassPostProcess which produces an output the same as it's input
  37933. */
  37934. export class PassPostProcess extends PostProcess {
  37935. /**
  37936. * Creates the PassPostProcess
  37937. * @param name The name of the effect.
  37938. * @param options The required width/height ratio to downsize to before computing the render pass.
  37939. * @param camera The camera to apply the render pass to.
  37940. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37941. * @param engine The engine which the post process will be applied. (default: current engine)
  37942. * @param reusable If the post process can be reused on the same frame. (default: false)
  37943. * @param textureType The type of texture to be used when performing the post processing.
  37944. * @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)
  37945. */
  37946. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37947. }
  37948. /**
  37949. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37950. */
  37951. export class PassCubePostProcess extends PostProcess {
  37952. private _face;
  37953. /**
  37954. * Gets or sets the cube face to display.
  37955. * * 0 is +X
  37956. * * 1 is -X
  37957. * * 2 is +Y
  37958. * * 3 is -Y
  37959. * * 4 is +Z
  37960. * * 5 is -Z
  37961. */
  37962. face: number;
  37963. /**
  37964. * Creates the PassCubePostProcess
  37965. * @param name The name of the effect.
  37966. * @param options The required width/height ratio to downsize to before computing the render pass.
  37967. * @param camera The camera to apply the render pass to.
  37968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37969. * @param engine The engine which the post process will be applied. (default: current engine)
  37970. * @param reusable If the post process can be reused on the same frame. (default: false)
  37971. * @param textureType The type of texture to be used when performing the post processing.
  37972. * @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)
  37973. */
  37974. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37975. }
  37976. }
  37977. declare module BABYLON {
  37978. /** @hidden */
  37979. export var anaglyphPixelShader: {
  37980. name: string;
  37981. shader: string;
  37982. };
  37983. }
  37984. declare module BABYLON {
  37985. /**
  37986. * Postprocess used to generate anaglyphic rendering
  37987. */
  37988. export class AnaglyphPostProcess extends PostProcess {
  37989. private _passedProcess;
  37990. /**
  37991. * Creates a new AnaglyphPostProcess
  37992. * @param name defines postprocess name
  37993. * @param options defines creation options or target ratio scale
  37994. * @param rigCameras defines cameras using this postprocess
  37995. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37996. * @param engine defines hosting engine
  37997. * @param reusable defines if the postprocess will be reused multiple times per frame
  37998. */
  37999. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38000. }
  38001. }
  38002. declare module BABYLON {
  38003. /**
  38004. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38005. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38006. */
  38007. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38008. /**
  38009. * Creates a new AnaglyphArcRotateCamera
  38010. * @param name defines camera name
  38011. * @param alpha defines alpha angle (in radians)
  38012. * @param beta defines beta angle (in radians)
  38013. * @param radius defines radius
  38014. * @param target defines camera target
  38015. * @param interaxialDistance defines distance between each color axis
  38016. * @param scene defines the hosting scene
  38017. */
  38018. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38019. /**
  38020. * Gets camera class name
  38021. * @returns AnaglyphArcRotateCamera
  38022. */
  38023. getClassName(): string;
  38024. }
  38025. }
  38026. declare module BABYLON {
  38027. /**
  38028. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38029. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38030. */
  38031. export class AnaglyphFreeCamera extends FreeCamera {
  38032. /**
  38033. * Creates a new AnaglyphFreeCamera
  38034. * @param name defines camera name
  38035. * @param position defines initial position
  38036. * @param interaxialDistance defines distance between each color axis
  38037. * @param scene defines the hosting scene
  38038. */
  38039. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38040. /**
  38041. * Gets camera class name
  38042. * @returns AnaglyphFreeCamera
  38043. */
  38044. getClassName(): string;
  38045. }
  38046. }
  38047. declare module BABYLON {
  38048. /**
  38049. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38050. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38051. */
  38052. export class AnaglyphGamepadCamera extends GamepadCamera {
  38053. /**
  38054. * Creates a new AnaglyphGamepadCamera
  38055. * @param name defines camera name
  38056. * @param position defines initial position
  38057. * @param interaxialDistance defines distance between each color axis
  38058. * @param scene defines the hosting scene
  38059. */
  38060. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38061. /**
  38062. * Gets camera class name
  38063. * @returns AnaglyphGamepadCamera
  38064. */
  38065. getClassName(): string;
  38066. }
  38067. }
  38068. declare module BABYLON {
  38069. /**
  38070. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38071. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38072. */
  38073. export class AnaglyphUniversalCamera extends UniversalCamera {
  38074. /**
  38075. * Creates a new AnaglyphUniversalCamera
  38076. * @param name defines camera name
  38077. * @param position defines initial position
  38078. * @param interaxialDistance defines distance between each color axis
  38079. * @param scene defines the hosting scene
  38080. */
  38081. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38082. /**
  38083. * Gets camera class name
  38084. * @returns AnaglyphUniversalCamera
  38085. */
  38086. getClassName(): string;
  38087. }
  38088. }
  38089. declare module BABYLON {
  38090. /** @hidden */
  38091. export var stereoscopicInterlacePixelShader: {
  38092. name: string;
  38093. shader: string;
  38094. };
  38095. }
  38096. declare module BABYLON {
  38097. /**
  38098. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38099. */
  38100. export class StereoscopicInterlacePostProcess extends PostProcess {
  38101. private _stepSize;
  38102. private _passedProcess;
  38103. /**
  38104. * Initializes a StereoscopicInterlacePostProcess
  38105. * @param name The name of the effect.
  38106. * @param rigCameras The rig cameras to be appled to the post process
  38107. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38109. * @param engine The engine which the post process will be applied. (default: current engine)
  38110. * @param reusable If the post process can be reused on the same frame. (default: false)
  38111. */
  38112. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38113. }
  38114. }
  38115. declare module BABYLON {
  38116. /**
  38117. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38118. * @see http://doc.babylonjs.com/features/cameras
  38119. */
  38120. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38121. /**
  38122. * Creates a new StereoscopicArcRotateCamera
  38123. * @param name defines camera name
  38124. * @param alpha defines alpha angle (in radians)
  38125. * @param beta defines beta angle (in radians)
  38126. * @param radius defines radius
  38127. * @param target defines camera target
  38128. * @param interaxialDistance defines distance between each color axis
  38129. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38130. * @param scene defines the hosting scene
  38131. */
  38132. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38133. /**
  38134. * Gets camera class name
  38135. * @returns StereoscopicArcRotateCamera
  38136. */
  38137. getClassName(): string;
  38138. }
  38139. }
  38140. declare module BABYLON {
  38141. /**
  38142. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38143. * @see http://doc.babylonjs.com/features/cameras
  38144. */
  38145. export class StereoscopicFreeCamera extends FreeCamera {
  38146. /**
  38147. * Creates a new StereoscopicFreeCamera
  38148. * @param name defines camera name
  38149. * @param position defines initial position
  38150. * @param interaxialDistance defines distance between each color axis
  38151. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38152. * @param scene defines the hosting scene
  38153. */
  38154. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38155. /**
  38156. * Gets camera class name
  38157. * @returns StereoscopicFreeCamera
  38158. */
  38159. getClassName(): string;
  38160. }
  38161. }
  38162. declare module BABYLON {
  38163. /**
  38164. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38165. * @see http://doc.babylonjs.com/features/cameras
  38166. */
  38167. export class StereoscopicGamepadCamera extends GamepadCamera {
  38168. /**
  38169. * Creates a new StereoscopicGamepadCamera
  38170. * @param name defines camera name
  38171. * @param position defines initial position
  38172. * @param interaxialDistance defines distance between each color axis
  38173. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38174. * @param scene defines the hosting scene
  38175. */
  38176. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38177. /**
  38178. * Gets camera class name
  38179. * @returns StereoscopicGamepadCamera
  38180. */
  38181. getClassName(): string;
  38182. }
  38183. }
  38184. declare module BABYLON {
  38185. /**
  38186. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38187. * @see http://doc.babylonjs.com/features/cameras
  38188. */
  38189. export class StereoscopicUniversalCamera extends UniversalCamera {
  38190. /**
  38191. * Creates a new StereoscopicUniversalCamera
  38192. * @param name defines camera name
  38193. * @param position defines initial position
  38194. * @param interaxialDistance defines distance between each color axis
  38195. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38196. * @param scene defines the hosting scene
  38197. */
  38198. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38199. /**
  38200. * Gets camera class name
  38201. * @returns StereoscopicUniversalCamera
  38202. */
  38203. getClassName(): string;
  38204. }
  38205. }
  38206. declare module BABYLON {
  38207. /**
  38208. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38209. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38210. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38211. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38212. */
  38213. export class VirtualJoysticksCamera extends FreeCamera {
  38214. /**
  38215. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38216. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38217. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38218. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38219. * @param name Define the name of the camera in the scene
  38220. * @param position Define the start position of the camera in the scene
  38221. * @param scene Define the scene the camera belongs to
  38222. */
  38223. constructor(name: string, position: Vector3, scene: Scene);
  38224. /**
  38225. * Gets the current object class name.
  38226. * @return the class name
  38227. */
  38228. getClassName(): string;
  38229. }
  38230. }
  38231. declare module BABYLON {
  38232. /**
  38233. * This represents all the required metrics to create a VR camera.
  38234. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38235. */
  38236. export class VRCameraMetrics {
  38237. /**
  38238. * Define the horizontal resolution off the screen.
  38239. */
  38240. hResolution: number;
  38241. /**
  38242. * Define the vertical resolution off the screen.
  38243. */
  38244. vResolution: number;
  38245. /**
  38246. * Define the horizontal screen size.
  38247. */
  38248. hScreenSize: number;
  38249. /**
  38250. * Define the vertical screen size.
  38251. */
  38252. vScreenSize: number;
  38253. /**
  38254. * Define the vertical screen center position.
  38255. */
  38256. vScreenCenter: number;
  38257. /**
  38258. * Define the distance of the eyes to the screen.
  38259. */
  38260. eyeToScreenDistance: number;
  38261. /**
  38262. * Define the distance between both lenses
  38263. */
  38264. lensSeparationDistance: number;
  38265. /**
  38266. * Define the distance between both viewer's eyes.
  38267. */
  38268. interpupillaryDistance: number;
  38269. /**
  38270. * Define the distortion factor of the VR postprocess.
  38271. * Please, touch with care.
  38272. */
  38273. distortionK: number[];
  38274. /**
  38275. * Define the chromatic aberration correction factors for the VR post process.
  38276. */
  38277. chromaAbCorrection: number[];
  38278. /**
  38279. * Define the scale factor of the post process.
  38280. * The smaller the better but the slower.
  38281. */
  38282. postProcessScaleFactor: number;
  38283. /**
  38284. * Define an offset for the lens center.
  38285. */
  38286. lensCenterOffset: number;
  38287. /**
  38288. * Define if the current vr camera should compensate the distortion of the lense or not.
  38289. */
  38290. compensateDistortion: boolean;
  38291. /**
  38292. * Defines if multiview should be enabled when rendering (Default: false)
  38293. */
  38294. multiviewEnabled: boolean;
  38295. /**
  38296. * Gets the rendering aspect ratio based on the provided resolutions.
  38297. */
  38298. readonly aspectRatio: number;
  38299. /**
  38300. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38301. */
  38302. readonly aspectRatioFov: number;
  38303. /**
  38304. * @hidden
  38305. */
  38306. readonly leftHMatrix: Matrix;
  38307. /**
  38308. * @hidden
  38309. */
  38310. readonly rightHMatrix: Matrix;
  38311. /**
  38312. * @hidden
  38313. */
  38314. readonly leftPreViewMatrix: Matrix;
  38315. /**
  38316. * @hidden
  38317. */
  38318. readonly rightPreViewMatrix: Matrix;
  38319. /**
  38320. * Get the default VRMetrics based on the most generic setup.
  38321. * @returns the default vr metrics
  38322. */
  38323. static GetDefault(): VRCameraMetrics;
  38324. }
  38325. }
  38326. declare module BABYLON {
  38327. /** @hidden */
  38328. export var vrDistortionCorrectionPixelShader: {
  38329. name: string;
  38330. shader: string;
  38331. };
  38332. }
  38333. declare module BABYLON {
  38334. /**
  38335. * VRDistortionCorrectionPostProcess used for mobile VR
  38336. */
  38337. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38338. private _isRightEye;
  38339. private _distortionFactors;
  38340. private _postProcessScaleFactor;
  38341. private _lensCenterOffset;
  38342. private _scaleIn;
  38343. private _scaleFactor;
  38344. private _lensCenter;
  38345. /**
  38346. * Initializes the VRDistortionCorrectionPostProcess
  38347. * @param name The name of the effect.
  38348. * @param camera The camera to apply the render pass to.
  38349. * @param isRightEye If this is for the right eye distortion
  38350. * @param vrMetrics All the required metrics for the VR camera
  38351. */
  38352. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38353. }
  38354. }
  38355. declare module BABYLON {
  38356. /**
  38357. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38358. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38359. */
  38360. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38361. /**
  38362. * Creates a new VRDeviceOrientationArcRotateCamera
  38363. * @param name defines camera name
  38364. * @param alpha defines the camera rotation along the logitudinal axis
  38365. * @param beta defines the camera rotation along the latitudinal axis
  38366. * @param radius defines the camera distance from its target
  38367. * @param target defines the camera target
  38368. * @param scene defines the scene the camera belongs to
  38369. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38370. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38371. */
  38372. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38373. /**
  38374. * Gets camera class name
  38375. * @returns VRDeviceOrientationArcRotateCamera
  38376. */
  38377. getClassName(): string;
  38378. }
  38379. }
  38380. declare module BABYLON {
  38381. /**
  38382. * Camera used to simulate VR rendering (based on FreeCamera)
  38383. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38384. */
  38385. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38386. /**
  38387. * Creates a new VRDeviceOrientationFreeCamera
  38388. * @param name defines camera name
  38389. * @param position defines the start position of the camera
  38390. * @param scene defines the scene the camera belongs to
  38391. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38392. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38393. */
  38394. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38395. /**
  38396. * Gets camera class name
  38397. * @returns VRDeviceOrientationFreeCamera
  38398. */
  38399. getClassName(): string;
  38400. }
  38401. }
  38402. declare module BABYLON {
  38403. /**
  38404. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38405. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38406. */
  38407. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38408. /**
  38409. * Creates a new VRDeviceOrientationGamepadCamera
  38410. * @param name defines camera name
  38411. * @param position defines the start position of the camera
  38412. * @param scene defines the scene the camera belongs to
  38413. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38414. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38415. */
  38416. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38417. /**
  38418. * Gets camera class name
  38419. * @returns VRDeviceOrientationGamepadCamera
  38420. */
  38421. getClassName(): string;
  38422. }
  38423. }
  38424. declare module BABYLON {
  38425. /**
  38426. * Base class of materials working in push mode in babylon JS
  38427. * @hidden
  38428. */
  38429. export class PushMaterial extends Material {
  38430. protected _activeEffect: Effect;
  38431. protected _normalMatrix: Matrix;
  38432. /**
  38433. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38434. * This means that the material can keep using a previous shader while a new one is being compiled.
  38435. * This is mostly used when shader parallel compilation is supported (true by default)
  38436. */
  38437. allowShaderHotSwapping: boolean;
  38438. constructor(name: string, scene: Scene);
  38439. getEffect(): Effect;
  38440. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38441. /**
  38442. * Binds the given world matrix to the active effect
  38443. *
  38444. * @param world the matrix to bind
  38445. */
  38446. bindOnlyWorldMatrix(world: Matrix): void;
  38447. /**
  38448. * Binds the given normal matrix to the active effect
  38449. *
  38450. * @param normalMatrix the matrix to bind
  38451. */
  38452. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38453. bind(world: Matrix, mesh?: Mesh): void;
  38454. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38455. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38456. }
  38457. }
  38458. declare module BABYLON {
  38459. /**
  38460. * This groups all the flags used to control the materials channel.
  38461. */
  38462. export class MaterialFlags {
  38463. private static _DiffuseTextureEnabled;
  38464. /**
  38465. * Are diffuse textures enabled in the application.
  38466. */
  38467. static DiffuseTextureEnabled: boolean;
  38468. private static _AmbientTextureEnabled;
  38469. /**
  38470. * Are ambient textures enabled in the application.
  38471. */
  38472. static AmbientTextureEnabled: boolean;
  38473. private static _OpacityTextureEnabled;
  38474. /**
  38475. * Are opacity textures enabled in the application.
  38476. */
  38477. static OpacityTextureEnabled: boolean;
  38478. private static _ReflectionTextureEnabled;
  38479. /**
  38480. * Are reflection textures enabled in the application.
  38481. */
  38482. static ReflectionTextureEnabled: boolean;
  38483. private static _EmissiveTextureEnabled;
  38484. /**
  38485. * Are emissive textures enabled in the application.
  38486. */
  38487. static EmissiveTextureEnabled: boolean;
  38488. private static _SpecularTextureEnabled;
  38489. /**
  38490. * Are specular textures enabled in the application.
  38491. */
  38492. static SpecularTextureEnabled: boolean;
  38493. private static _BumpTextureEnabled;
  38494. /**
  38495. * Are bump textures enabled in the application.
  38496. */
  38497. static BumpTextureEnabled: boolean;
  38498. private static _LightmapTextureEnabled;
  38499. /**
  38500. * Are lightmap textures enabled in the application.
  38501. */
  38502. static LightmapTextureEnabled: boolean;
  38503. private static _RefractionTextureEnabled;
  38504. /**
  38505. * Are refraction textures enabled in the application.
  38506. */
  38507. static RefractionTextureEnabled: boolean;
  38508. private static _ColorGradingTextureEnabled;
  38509. /**
  38510. * Are color grading textures enabled in the application.
  38511. */
  38512. static ColorGradingTextureEnabled: boolean;
  38513. private static _FresnelEnabled;
  38514. /**
  38515. * Are fresnels enabled in the application.
  38516. */
  38517. static FresnelEnabled: boolean;
  38518. private static _ClearCoatTextureEnabled;
  38519. /**
  38520. * Are clear coat textures enabled in the application.
  38521. */
  38522. static ClearCoatTextureEnabled: boolean;
  38523. private static _ClearCoatBumpTextureEnabled;
  38524. /**
  38525. * Are clear coat bump textures enabled in the application.
  38526. */
  38527. static ClearCoatBumpTextureEnabled: boolean;
  38528. private static _ClearCoatTintTextureEnabled;
  38529. /**
  38530. * Are clear coat tint textures enabled in the application.
  38531. */
  38532. static ClearCoatTintTextureEnabled: boolean;
  38533. private static _SheenTextureEnabled;
  38534. /**
  38535. * Are sheen textures enabled in the application.
  38536. */
  38537. static SheenTextureEnabled: boolean;
  38538. private static _AnisotropicTextureEnabled;
  38539. /**
  38540. * Are anisotropic textures enabled in the application.
  38541. */
  38542. static AnisotropicTextureEnabled: boolean;
  38543. private static _ThicknessTextureEnabled;
  38544. /**
  38545. * Are thickness textures enabled in the application.
  38546. */
  38547. static ThicknessTextureEnabled: boolean;
  38548. }
  38549. }
  38550. declare module BABYLON {
  38551. /** @hidden */
  38552. export var defaultFragmentDeclaration: {
  38553. name: string;
  38554. shader: string;
  38555. };
  38556. }
  38557. declare module BABYLON {
  38558. /** @hidden */
  38559. export var defaultUboDeclaration: {
  38560. name: string;
  38561. shader: string;
  38562. };
  38563. }
  38564. declare module BABYLON {
  38565. /** @hidden */
  38566. export var lightFragmentDeclaration: {
  38567. name: string;
  38568. shader: string;
  38569. };
  38570. }
  38571. declare module BABYLON {
  38572. /** @hidden */
  38573. export var lightUboDeclaration: {
  38574. name: string;
  38575. shader: string;
  38576. };
  38577. }
  38578. declare module BABYLON {
  38579. /** @hidden */
  38580. export var lightsFragmentFunctions: {
  38581. name: string;
  38582. shader: string;
  38583. };
  38584. }
  38585. declare module BABYLON {
  38586. /** @hidden */
  38587. export var shadowsFragmentFunctions: {
  38588. name: string;
  38589. shader: string;
  38590. };
  38591. }
  38592. declare module BABYLON {
  38593. /** @hidden */
  38594. export var fresnelFunction: {
  38595. name: string;
  38596. shader: string;
  38597. };
  38598. }
  38599. declare module BABYLON {
  38600. /** @hidden */
  38601. export var reflectionFunction: {
  38602. name: string;
  38603. shader: string;
  38604. };
  38605. }
  38606. declare module BABYLON {
  38607. /** @hidden */
  38608. export var bumpFragmentFunctions: {
  38609. name: string;
  38610. shader: string;
  38611. };
  38612. }
  38613. declare module BABYLON {
  38614. /** @hidden */
  38615. export var logDepthDeclaration: {
  38616. name: string;
  38617. shader: string;
  38618. };
  38619. }
  38620. declare module BABYLON {
  38621. /** @hidden */
  38622. export var bumpFragment: {
  38623. name: string;
  38624. shader: string;
  38625. };
  38626. }
  38627. declare module BABYLON {
  38628. /** @hidden */
  38629. export var depthPrePass: {
  38630. name: string;
  38631. shader: string;
  38632. };
  38633. }
  38634. declare module BABYLON {
  38635. /** @hidden */
  38636. export var lightFragment: {
  38637. name: string;
  38638. shader: string;
  38639. };
  38640. }
  38641. declare module BABYLON {
  38642. /** @hidden */
  38643. export var logDepthFragment: {
  38644. name: string;
  38645. shader: string;
  38646. };
  38647. }
  38648. declare module BABYLON {
  38649. /** @hidden */
  38650. export var defaultPixelShader: {
  38651. name: string;
  38652. shader: string;
  38653. };
  38654. }
  38655. declare module BABYLON {
  38656. /** @hidden */
  38657. export var defaultVertexDeclaration: {
  38658. name: string;
  38659. shader: string;
  38660. };
  38661. }
  38662. declare module BABYLON {
  38663. /** @hidden */
  38664. export var bumpVertexDeclaration: {
  38665. name: string;
  38666. shader: string;
  38667. };
  38668. }
  38669. declare module BABYLON {
  38670. /** @hidden */
  38671. export var bumpVertex: {
  38672. name: string;
  38673. shader: string;
  38674. };
  38675. }
  38676. declare module BABYLON {
  38677. /** @hidden */
  38678. export var fogVertex: {
  38679. name: string;
  38680. shader: string;
  38681. };
  38682. }
  38683. declare module BABYLON {
  38684. /** @hidden */
  38685. export var shadowsVertex: {
  38686. name: string;
  38687. shader: string;
  38688. };
  38689. }
  38690. declare module BABYLON {
  38691. /** @hidden */
  38692. export var pointCloudVertex: {
  38693. name: string;
  38694. shader: string;
  38695. };
  38696. }
  38697. declare module BABYLON {
  38698. /** @hidden */
  38699. export var logDepthVertex: {
  38700. name: string;
  38701. shader: string;
  38702. };
  38703. }
  38704. declare module BABYLON {
  38705. /** @hidden */
  38706. export var defaultVertexShader: {
  38707. name: string;
  38708. shader: string;
  38709. };
  38710. }
  38711. declare module BABYLON {
  38712. /** @hidden */
  38713. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38714. MAINUV1: boolean;
  38715. MAINUV2: boolean;
  38716. DIFFUSE: boolean;
  38717. DIFFUSEDIRECTUV: number;
  38718. AMBIENT: boolean;
  38719. AMBIENTDIRECTUV: number;
  38720. OPACITY: boolean;
  38721. OPACITYDIRECTUV: number;
  38722. OPACITYRGB: boolean;
  38723. REFLECTION: boolean;
  38724. EMISSIVE: boolean;
  38725. EMISSIVEDIRECTUV: number;
  38726. SPECULAR: boolean;
  38727. SPECULARDIRECTUV: number;
  38728. BUMP: boolean;
  38729. BUMPDIRECTUV: number;
  38730. PARALLAX: boolean;
  38731. PARALLAXOCCLUSION: boolean;
  38732. SPECULAROVERALPHA: boolean;
  38733. CLIPPLANE: boolean;
  38734. CLIPPLANE2: boolean;
  38735. CLIPPLANE3: boolean;
  38736. CLIPPLANE4: boolean;
  38737. ALPHATEST: boolean;
  38738. DEPTHPREPASS: boolean;
  38739. ALPHAFROMDIFFUSE: boolean;
  38740. POINTSIZE: boolean;
  38741. FOG: boolean;
  38742. SPECULARTERM: boolean;
  38743. DIFFUSEFRESNEL: boolean;
  38744. OPACITYFRESNEL: boolean;
  38745. REFLECTIONFRESNEL: boolean;
  38746. REFRACTIONFRESNEL: boolean;
  38747. EMISSIVEFRESNEL: boolean;
  38748. FRESNEL: boolean;
  38749. NORMAL: boolean;
  38750. UV1: boolean;
  38751. UV2: boolean;
  38752. VERTEXCOLOR: boolean;
  38753. VERTEXALPHA: boolean;
  38754. NUM_BONE_INFLUENCERS: number;
  38755. BonesPerMesh: number;
  38756. BONETEXTURE: boolean;
  38757. INSTANCES: boolean;
  38758. GLOSSINESS: boolean;
  38759. ROUGHNESS: boolean;
  38760. EMISSIVEASILLUMINATION: boolean;
  38761. LINKEMISSIVEWITHDIFFUSE: boolean;
  38762. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38763. LIGHTMAP: boolean;
  38764. LIGHTMAPDIRECTUV: number;
  38765. OBJECTSPACE_NORMALMAP: boolean;
  38766. USELIGHTMAPASSHADOWMAP: boolean;
  38767. REFLECTIONMAP_3D: boolean;
  38768. REFLECTIONMAP_SPHERICAL: boolean;
  38769. REFLECTIONMAP_PLANAR: boolean;
  38770. REFLECTIONMAP_CUBIC: boolean;
  38771. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38772. REFLECTIONMAP_PROJECTION: boolean;
  38773. REFLECTIONMAP_SKYBOX: boolean;
  38774. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38775. REFLECTIONMAP_EXPLICIT: boolean;
  38776. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38777. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38778. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38779. INVERTCUBICMAP: boolean;
  38780. LOGARITHMICDEPTH: boolean;
  38781. REFRACTION: boolean;
  38782. REFRACTIONMAP_3D: boolean;
  38783. REFLECTIONOVERALPHA: boolean;
  38784. TWOSIDEDLIGHTING: boolean;
  38785. SHADOWFLOAT: boolean;
  38786. MORPHTARGETS: boolean;
  38787. MORPHTARGETS_NORMAL: boolean;
  38788. MORPHTARGETS_TANGENT: boolean;
  38789. NUM_MORPH_INFLUENCERS: number;
  38790. NONUNIFORMSCALING: boolean;
  38791. PREMULTIPLYALPHA: boolean;
  38792. IMAGEPROCESSING: boolean;
  38793. VIGNETTE: boolean;
  38794. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38795. VIGNETTEBLENDMODEOPAQUE: boolean;
  38796. TONEMAPPING: boolean;
  38797. TONEMAPPING_ACES: boolean;
  38798. CONTRAST: boolean;
  38799. COLORCURVES: boolean;
  38800. COLORGRADING: boolean;
  38801. COLORGRADING3D: boolean;
  38802. SAMPLER3DGREENDEPTH: boolean;
  38803. SAMPLER3DBGRMAP: boolean;
  38804. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38805. MULTIVIEW: boolean;
  38806. /**
  38807. * If the reflection texture on this material is in linear color space
  38808. * @hidden
  38809. */
  38810. IS_REFLECTION_LINEAR: boolean;
  38811. /**
  38812. * If the refraction texture on this material is in linear color space
  38813. * @hidden
  38814. */
  38815. IS_REFRACTION_LINEAR: boolean;
  38816. EXPOSURE: boolean;
  38817. constructor();
  38818. setReflectionMode(modeToEnable: string): void;
  38819. }
  38820. /**
  38821. * This is the default material used in Babylon. It is the best trade off between quality
  38822. * and performances.
  38823. * @see http://doc.babylonjs.com/babylon101/materials
  38824. */
  38825. export class StandardMaterial extends PushMaterial {
  38826. private _diffuseTexture;
  38827. /**
  38828. * The basic texture of the material as viewed under a light.
  38829. */
  38830. diffuseTexture: Nullable<BaseTexture>;
  38831. private _ambientTexture;
  38832. /**
  38833. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38834. */
  38835. ambientTexture: Nullable<BaseTexture>;
  38836. private _opacityTexture;
  38837. /**
  38838. * Define the transparency of the material from a texture.
  38839. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38840. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38841. */
  38842. opacityTexture: Nullable<BaseTexture>;
  38843. private _reflectionTexture;
  38844. /**
  38845. * Define the texture used to display the reflection.
  38846. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38847. */
  38848. reflectionTexture: Nullable<BaseTexture>;
  38849. private _emissiveTexture;
  38850. /**
  38851. * Define texture of the material as if self lit.
  38852. * This will be mixed in the final result even in the absence of light.
  38853. */
  38854. emissiveTexture: Nullable<BaseTexture>;
  38855. private _specularTexture;
  38856. /**
  38857. * Define how the color and intensity of the highlight given by the light in the material.
  38858. */
  38859. specularTexture: Nullable<BaseTexture>;
  38860. private _bumpTexture;
  38861. /**
  38862. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38863. * 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.
  38864. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38865. */
  38866. bumpTexture: Nullable<BaseTexture>;
  38867. private _lightmapTexture;
  38868. /**
  38869. * Complex lighting can be computationally expensive to compute at runtime.
  38870. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38871. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38872. */
  38873. lightmapTexture: Nullable<BaseTexture>;
  38874. private _refractionTexture;
  38875. /**
  38876. * Define the texture used to display the refraction.
  38877. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38878. */
  38879. refractionTexture: Nullable<BaseTexture>;
  38880. /**
  38881. * The color of the material lit by the environmental background lighting.
  38882. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38883. */
  38884. ambientColor: Color3;
  38885. /**
  38886. * The basic color of the material as viewed under a light.
  38887. */
  38888. diffuseColor: Color3;
  38889. /**
  38890. * Define how the color and intensity of the highlight given by the light in the material.
  38891. */
  38892. specularColor: Color3;
  38893. /**
  38894. * Define the color of the material as if self lit.
  38895. * This will be mixed in the final result even in the absence of light.
  38896. */
  38897. emissiveColor: Color3;
  38898. /**
  38899. * Defines how sharp are the highlights in the material.
  38900. * The bigger the value the sharper giving a more glossy feeling to the result.
  38901. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38902. */
  38903. specularPower: number;
  38904. private _useAlphaFromDiffuseTexture;
  38905. /**
  38906. * Does the transparency come from the diffuse texture alpha channel.
  38907. */
  38908. useAlphaFromDiffuseTexture: boolean;
  38909. private _useEmissiveAsIllumination;
  38910. /**
  38911. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38912. */
  38913. useEmissiveAsIllumination: boolean;
  38914. private _linkEmissiveWithDiffuse;
  38915. /**
  38916. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38917. * the emissive level when the final color is close to one.
  38918. */
  38919. linkEmissiveWithDiffuse: boolean;
  38920. private _useSpecularOverAlpha;
  38921. /**
  38922. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38923. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38924. */
  38925. useSpecularOverAlpha: boolean;
  38926. private _useReflectionOverAlpha;
  38927. /**
  38928. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38929. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38930. */
  38931. useReflectionOverAlpha: boolean;
  38932. private _disableLighting;
  38933. /**
  38934. * Does lights from the scene impacts this material.
  38935. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38936. */
  38937. disableLighting: boolean;
  38938. private _useObjectSpaceNormalMap;
  38939. /**
  38940. * Allows using an object space normal map (instead of tangent space).
  38941. */
  38942. useObjectSpaceNormalMap: boolean;
  38943. private _useParallax;
  38944. /**
  38945. * Is parallax enabled or not.
  38946. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38947. */
  38948. useParallax: boolean;
  38949. private _useParallaxOcclusion;
  38950. /**
  38951. * Is parallax occlusion enabled or not.
  38952. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38953. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38954. */
  38955. useParallaxOcclusion: boolean;
  38956. /**
  38957. * 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.
  38958. */
  38959. parallaxScaleBias: number;
  38960. private _roughness;
  38961. /**
  38962. * Helps to define how blurry the reflections should appears in the material.
  38963. */
  38964. roughness: number;
  38965. /**
  38966. * In case of refraction, define the value of the indice of refraction.
  38967. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38968. */
  38969. indexOfRefraction: number;
  38970. /**
  38971. * Invert the refraction texture alongside the y axis.
  38972. * It can be useful with procedural textures or probe for instance.
  38973. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38974. */
  38975. invertRefractionY: boolean;
  38976. /**
  38977. * Defines the alpha limits in alpha test mode.
  38978. */
  38979. alphaCutOff: number;
  38980. private _useLightmapAsShadowmap;
  38981. /**
  38982. * In case of light mapping, define whether the map contains light or shadow informations.
  38983. */
  38984. useLightmapAsShadowmap: boolean;
  38985. private _diffuseFresnelParameters;
  38986. /**
  38987. * Define the diffuse fresnel parameters of the material.
  38988. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38989. */
  38990. diffuseFresnelParameters: FresnelParameters;
  38991. private _opacityFresnelParameters;
  38992. /**
  38993. * Define the opacity fresnel parameters of the material.
  38994. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38995. */
  38996. opacityFresnelParameters: FresnelParameters;
  38997. private _reflectionFresnelParameters;
  38998. /**
  38999. * Define the reflection fresnel parameters of the material.
  39000. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39001. */
  39002. reflectionFresnelParameters: FresnelParameters;
  39003. private _refractionFresnelParameters;
  39004. /**
  39005. * Define the refraction fresnel parameters of the material.
  39006. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39007. */
  39008. refractionFresnelParameters: FresnelParameters;
  39009. private _emissiveFresnelParameters;
  39010. /**
  39011. * Define the emissive fresnel parameters of the material.
  39012. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39013. */
  39014. emissiveFresnelParameters: FresnelParameters;
  39015. private _useReflectionFresnelFromSpecular;
  39016. /**
  39017. * If true automatically deducts the fresnels values from the material specularity.
  39018. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39019. */
  39020. useReflectionFresnelFromSpecular: boolean;
  39021. private _useGlossinessFromSpecularMapAlpha;
  39022. /**
  39023. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39024. */
  39025. useGlossinessFromSpecularMapAlpha: boolean;
  39026. private _maxSimultaneousLights;
  39027. /**
  39028. * Defines the maximum number of lights that can be used in the material
  39029. */
  39030. maxSimultaneousLights: number;
  39031. private _invertNormalMapX;
  39032. /**
  39033. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39034. */
  39035. invertNormalMapX: boolean;
  39036. private _invertNormalMapY;
  39037. /**
  39038. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39039. */
  39040. invertNormalMapY: boolean;
  39041. private _twoSidedLighting;
  39042. /**
  39043. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39044. */
  39045. twoSidedLighting: boolean;
  39046. /**
  39047. * Default configuration related to image processing available in the standard Material.
  39048. */
  39049. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39050. /**
  39051. * Gets the image processing configuration used either in this material.
  39052. */
  39053. /**
  39054. * Sets the Default image processing configuration used either in the this material.
  39055. *
  39056. * If sets to null, the scene one is in use.
  39057. */
  39058. imageProcessingConfiguration: ImageProcessingConfiguration;
  39059. /**
  39060. * Keep track of the image processing observer to allow dispose and replace.
  39061. */
  39062. private _imageProcessingObserver;
  39063. /**
  39064. * Attaches a new image processing configuration to the Standard Material.
  39065. * @param configuration
  39066. */
  39067. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39068. /**
  39069. * Gets wether the color curves effect is enabled.
  39070. */
  39071. /**
  39072. * Sets wether the color curves effect is enabled.
  39073. */
  39074. cameraColorCurvesEnabled: boolean;
  39075. /**
  39076. * Gets wether the color grading effect is enabled.
  39077. */
  39078. /**
  39079. * Gets wether the color grading effect is enabled.
  39080. */
  39081. cameraColorGradingEnabled: boolean;
  39082. /**
  39083. * Gets wether tonemapping is enabled or not.
  39084. */
  39085. /**
  39086. * Sets wether tonemapping is enabled or not
  39087. */
  39088. cameraToneMappingEnabled: boolean;
  39089. /**
  39090. * The camera exposure used on this material.
  39091. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39092. * This corresponds to a photographic exposure.
  39093. */
  39094. /**
  39095. * The camera exposure used on this material.
  39096. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39097. * This corresponds to a photographic exposure.
  39098. */
  39099. cameraExposure: number;
  39100. /**
  39101. * Gets The camera contrast used on this material.
  39102. */
  39103. /**
  39104. * Sets The camera contrast used on this material.
  39105. */
  39106. cameraContrast: number;
  39107. /**
  39108. * Gets the Color Grading 2D Lookup Texture.
  39109. */
  39110. /**
  39111. * Sets the Color Grading 2D Lookup Texture.
  39112. */
  39113. cameraColorGradingTexture: Nullable<BaseTexture>;
  39114. /**
  39115. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39116. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39117. * 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;
  39118. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39119. */
  39120. /**
  39121. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39122. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39123. * 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;
  39124. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39125. */
  39126. cameraColorCurves: Nullable<ColorCurves>;
  39127. /**
  39128. * Custom callback helping to override the default shader used in the material.
  39129. */
  39130. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39131. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39132. protected _worldViewProjectionMatrix: Matrix;
  39133. protected _globalAmbientColor: Color3;
  39134. protected _useLogarithmicDepth: boolean;
  39135. /**
  39136. * Instantiates a new standard material.
  39137. * This is the default material used in Babylon. It is the best trade off between quality
  39138. * and performances.
  39139. * @see http://doc.babylonjs.com/babylon101/materials
  39140. * @param name Define the name of the material in the scene
  39141. * @param scene Define the scene the material belong to
  39142. */
  39143. constructor(name: string, scene: Scene);
  39144. /**
  39145. * Gets a boolean indicating that current material needs to register RTT
  39146. */
  39147. readonly hasRenderTargetTextures: boolean;
  39148. /**
  39149. * Gets the current class name of the material e.g. "StandardMaterial"
  39150. * Mainly use in serialization.
  39151. * @returns the class name
  39152. */
  39153. getClassName(): string;
  39154. /**
  39155. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39156. * You can try switching to logarithmic depth.
  39157. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39158. */
  39159. useLogarithmicDepth: boolean;
  39160. /**
  39161. * Specifies if the material will require alpha blending
  39162. * @returns a boolean specifying if alpha blending is needed
  39163. */
  39164. needAlphaBlending(): boolean;
  39165. /**
  39166. * Specifies if this material should be rendered in alpha test mode
  39167. * @returns a boolean specifying if an alpha test is needed.
  39168. */
  39169. needAlphaTesting(): boolean;
  39170. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39171. /**
  39172. * Get the texture used for alpha test purpose.
  39173. * @returns the diffuse texture in case of the standard material.
  39174. */
  39175. getAlphaTestTexture(): Nullable<BaseTexture>;
  39176. /**
  39177. * Get if the submesh is ready to be used and all its information available.
  39178. * Child classes can use it to update shaders
  39179. * @param mesh defines the mesh to check
  39180. * @param subMesh defines which submesh to check
  39181. * @param useInstances specifies that instances should be used
  39182. * @returns a boolean indicating that the submesh is ready or not
  39183. */
  39184. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39185. /**
  39186. * Builds the material UBO layouts.
  39187. * Used internally during the effect preparation.
  39188. */
  39189. buildUniformLayout(): void;
  39190. /**
  39191. * Unbinds the material from the mesh
  39192. */
  39193. unbind(): void;
  39194. /**
  39195. * Binds the submesh to this material by preparing the effect and shader to draw
  39196. * @param world defines the world transformation matrix
  39197. * @param mesh defines the mesh containing the submesh
  39198. * @param subMesh defines the submesh to bind the material to
  39199. */
  39200. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39201. /**
  39202. * Get the list of animatables in the material.
  39203. * @returns the list of animatables object used in the material
  39204. */
  39205. getAnimatables(): IAnimatable[];
  39206. /**
  39207. * Gets the active textures from the material
  39208. * @returns an array of textures
  39209. */
  39210. getActiveTextures(): BaseTexture[];
  39211. /**
  39212. * Specifies if the material uses a texture
  39213. * @param texture defines the texture to check against the material
  39214. * @returns a boolean specifying if the material uses the texture
  39215. */
  39216. hasTexture(texture: BaseTexture): boolean;
  39217. /**
  39218. * Disposes the material
  39219. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39220. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39221. */
  39222. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39223. /**
  39224. * Makes a duplicate of the material, and gives it a new name
  39225. * @param name defines the new name for the duplicated material
  39226. * @returns the cloned material
  39227. */
  39228. clone(name: string): StandardMaterial;
  39229. /**
  39230. * Serializes this material in a JSON representation
  39231. * @returns the serialized material object
  39232. */
  39233. serialize(): any;
  39234. /**
  39235. * Creates a standard material from parsed material data
  39236. * @param source defines the JSON representation of the material
  39237. * @param scene defines the hosting scene
  39238. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39239. * @returns a new standard material
  39240. */
  39241. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39242. /**
  39243. * Are diffuse textures enabled in the application.
  39244. */
  39245. static DiffuseTextureEnabled: boolean;
  39246. /**
  39247. * Are ambient textures enabled in the application.
  39248. */
  39249. static AmbientTextureEnabled: boolean;
  39250. /**
  39251. * Are opacity textures enabled in the application.
  39252. */
  39253. static OpacityTextureEnabled: boolean;
  39254. /**
  39255. * Are reflection textures enabled in the application.
  39256. */
  39257. static ReflectionTextureEnabled: boolean;
  39258. /**
  39259. * Are emissive textures enabled in the application.
  39260. */
  39261. static EmissiveTextureEnabled: boolean;
  39262. /**
  39263. * Are specular textures enabled in the application.
  39264. */
  39265. static SpecularTextureEnabled: boolean;
  39266. /**
  39267. * Are bump textures enabled in the application.
  39268. */
  39269. static BumpTextureEnabled: boolean;
  39270. /**
  39271. * Are lightmap textures enabled in the application.
  39272. */
  39273. static LightmapTextureEnabled: boolean;
  39274. /**
  39275. * Are refraction textures enabled in the application.
  39276. */
  39277. static RefractionTextureEnabled: boolean;
  39278. /**
  39279. * Are color grading textures enabled in the application.
  39280. */
  39281. static ColorGradingTextureEnabled: boolean;
  39282. /**
  39283. * Are fresnels enabled in the application.
  39284. */
  39285. static FresnelEnabled: boolean;
  39286. }
  39287. }
  39288. declare module BABYLON {
  39289. /**
  39290. * A class extending Texture allowing drawing on a texture
  39291. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39292. */
  39293. export class DynamicTexture extends Texture {
  39294. private _generateMipMaps;
  39295. private _canvas;
  39296. private _context;
  39297. private _engine;
  39298. /**
  39299. * Creates a DynamicTexture
  39300. * @param name defines the name of the texture
  39301. * @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
  39302. * @param scene defines the scene where you want the texture
  39303. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39304. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39305. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39306. */
  39307. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39308. /**
  39309. * Get the current class name of the texture useful for serialization or dynamic coding.
  39310. * @returns "DynamicTexture"
  39311. */
  39312. getClassName(): string;
  39313. /**
  39314. * Gets the current state of canRescale
  39315. */
  39316. readonly canRescale: boolean;
  39317. private _recreate;
  39318. /**
  39319. * Scales the texture
  39320. * @param ratio the scale factor to apply to both width and height
  39321. */
  39322. scale(ratio: number): void;
  39323. /**
  39324. * Resizes the texture
  39325. * @param width the new width
  39326. * @param height the new height
  39327. */
  39328. scaleTo(width: number, height: number): void;
  39329. /**
  39330. * Gets the context of the canvas used by the texture
  39331. * @returns the canvas context of the dynamic texture
  39332. */
  39333. getContext(): CanvasRenderingContext2D;
  39334. /**
  39335. * Clears the texture
  39336. */
  39337. clear(): void;
  39338. /**
  39339. * Updates the texture
  39340. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39341. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39342. */
  39343. update(invertY?: boolean, premulAlpha?: boolean): void;
  39344. /**
  39345. * Draws text onto the texture
  39346. * @param text defines the text to be drawn
  39347. * @param x defines the placement of the text from the left
  39348. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39349. * @param font defines the font to be used with font-style, font-size, font-name
  39350. * @param color defines the color used for the text
  39351. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39352. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39353. * @param update defines whether texture is immediately update (default is true)
  39354. */
  39355. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39356. /**
  39357. * Clones the texture
  39358. * @returns the clone of the texture.
  39359. */
  39360. clone(): DynamicTexture;
  39361. /**
  39362. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39363. * @returns a serialized dynamic texture object
  39364. */
  39365. serialize(): any;
  39366. /** @hidden */
  39367. _rebuild(): void;
  39368. }
  39369. }
  39370. declare module BABYLON {
  39371. /** @hidden */
  39372. export var imageProcessingPixelShader: {
  39373. name: string;
  39374. shader: string;
  39375. };
  39376. }
  39377. declare module BABYLON {
  39378. /**
  39379. * ImageProcessingPostProcess
  39380. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39381. */
  39382. export class ImageProcessingPostProcess extends PostProcess {
  39383. /**
  39384. * Default configuration related to image processing available in the PBR Material.
  39385. */
  39386. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39387. /**
  39388. * Gets the image processing configuration used either in this material.
  39389. */
  39390. /**
  39391. * Sets the Default image processing configuration used either in the this material.
  39392. *
  39393. * If sets to null, the scene one is in use.
  39394. */
  39395. imageProcessingConfiguration: ImageProcessingConfiguration;
  39396. /**
  39397. * Keep track of the image processing observer to allow dispose and replace.
  39398. */
  39399. private _imageProcessingObserver;
  39400. /**
  39401. * Attaches a new image processing configuration to the PBR Material.
  39402. * @param configuration
  39403. */
  39404. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39405. /**
  39406. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39407. */
  39408. /**
  39409. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39410. */
  39411. colorCurves: Nullable<ColorCurves>;
  39412. /**
  39413. * Gets wether the color curves effect is enabled.
  39414. */
  39415. /**
  39416. * Sets wether the color curves effect is enabled.
  39417. */
  39418. colorCurvesEnabled: boolean;
  39419. /**
  39420. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39421. */
  39422. /**
  39423. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39424. */
  39425. colorGradingTexture: Nullable<BaseTexture>;
  39426. /**
  39427. * Gets wether the color grading effect is enabled.
  39428. */
  39429. /**
  39430. * Gets wether the color grading effect is enabled.
  39431. */
  39432. colorGradingEnabled: boolean;
  39433. /**
  39434. * Gets exposure used in the effect.
  39435. */
  39436. /**
  39437. * Sets exposure used in the effect.
  39438. */
  39439. exposure: number;
  39440. /**
  39441. * Gets wether tonemapping is enabled or not.
  39442. */
  39443. /**
  39444. * Sets wether tonemapping is enabled or not
  39445. */
  39446. toneMappingEnabled: boolean;
  39447. /**
  39448. * Gets the type of tone mapping effect.
  39449. */
  39450. /**
  39451. * Sets the type of tone mapping effect.
  39452. */
  39453. toneMappingType: number;
  39454. /**
  39455. * Gets contrast used in the effect.
  39456. */
  39457. /**
  39458. * Sets contrast used in the effect.
  39459. */
  39460. contrast: number;
  39461. /**
  39462. * Gets Vignette stretch size.
  39463. */
  39464. /**
  39465. * Sets Vignette stretch size.
  39466. */
  39467. vignetteStretch: number;
  39468. /**
  39469. * Gets Vignette centre X Offset.
  39470. */
  39471. /**
  39472. * Sets Vignette centre X Offset.
  39473. */
  39474. vignetteCentreX: number;
  39475. /**
  39476. * Gets Vignette centre Y Offset.
  39477. */
  39478. /**
  39479. * Sets Vignette centre Y Offset.
  39480. */
  39481. vignetteCentreY: number;
  39482. /**
  39483. * Gets Vignette weight or intensity of the vignette effect.
  39484. */
  39485. /**
  39486. * Sets Vignette weight or intensity of the vignette effect.
  39487. */
  39488. vignetteWeight: number;
  39489. /**
  39490. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39491. * if vignetteEnabled is set to true.
  39492. */
  39493. /**
  39494. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39495. * if vignetteEnabled is set to true.
  39496. */
  39497. vignetteColor: Color4;
  39498. /**
  39499. * Gets Camera field of view used by the Vignette effect.
  39500. */
  39501. /**
  39502. * Sets Camera field of view used by the Vignette effect.
  39503. */
  39504. vignetteCameraFov: number;
  39505. /**
  39506. * Gets the vignette blend mode allowing different kind of effect.
  39507. */
  39508. /**
  39509. * Sets the vignette blend mode allowing different kind of effect.
  39510. */
  39511. vignetteBlendMode: number;
  39512. /**
  39513. * Gets wether the vignette effect is enabled.
  39514. */
  39515. /**
  39516. * Sets wether the vignette effect is enabled.
  39517. */
  39518. vignetteEnabled: boolean;
  39519. private _fromLinearSpace;
  39520. /**
  39521. * Gets wether the input of the processing is in Gamma or Linear Space.
  39522. */
  39523. /**
  39524. * Sets wether the input of the processing is in Gamma or Linear Space.
  39525. */
  39526. fromLinearSpace: boolean;
  39527. /**
  39528. * Defines cache preventing GC.
  39529. */
  39530. private _defines;
  39531. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39532. /**
  39533. * "ImageProcessingPostProcess"
  39534. * @returns "ImageProcessingPostProcess"
  39535. */
  39536. getClassName(): string;
  39537. protected _updateParameters(): void;
  39538. dispose(camera?: Camera): void;
  39539. }
  39540. }
  39541. declare module BABYLON {
  39542. /**
  39543. * Class containing static functions to help procedurally build meshes
  39544. */
  39545. export class GroundBuilder {
  39546. /**
  39547. * Creates a ground mesh
  39548. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39549. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39551. * @param name defines the name of the mesh
  39552. * @param options defines the options used to create the mesh
  39553. * @param scene defines the hosting scene
  39554. * @returns the ground mesh
  39555. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39556. */
  39557. static CreateGround(name: string, options: {
  39558. width?: number;
  39559. height?: number;
  39560. subdivisions?: number;
  39561. subdivisionsX?: number;
  39562. subdivisionsY?: number;
  39563. updatable?: boolean;
  39564. }, scene: any): Mesh;
  39565. /**
  39566. * Creates a tiled ground mesh
  39567. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39568. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39569. * * 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
  39570. * * 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
  39571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39572. * @param name defines the name of the mesh
  39573. * @param options defines the options used to create the mesh
  39574. * @param scene defines the hosting scene
  39575. * @returns the tiled ground mesh
  39576. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39577. */
  39578. static CreateTiledGround(name: string, options: {
  39579. xmin: number;
  39580. zmin: number;
  39581. xmax: number;
  39582. zmax: number;
  39583. subdivisions?: {
  39584. w: number;
  39585. h: number;
  39586. };
  39587. precision?: {
  39588. w: number;
  39589. h: number;
  39590. };
  39591. updatable?: boolean;
  39592. }, scene?: Nullable<Scene>): Mesh;
  39593. /**
  39594. * Creates a ground mesh from a height map
  39595. * * The parameter `url` sets the URL of the height map image resource.
  39596. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39597. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39598. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39599. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39600. * * 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.
  39601. * * 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).
  39602. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39604. * @param name defines the name of the mesh
  39605. * @param url defines the url to the height map
  39606. * @param options defines the options used to create the mesh
  39607. * @param scene defines the hosting scene
  39608. * @returns the ground mesh
  39609. * @see https://doc.babylonjs.com/babylon101/height_map
  39610. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39611. */
  39612. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39613. width?: number;
  39614. height?: number;
  39615. subdivisions?: number;
  39616. minHeight?: number;
  39617. maxHeight?: number;
  39618. colorFilter?: Color3;
  39619. alphaFilter?: number;
  39620. updatable?: boolean;
  39621. onReady?: (mesh: GroundMesh) => void;
  39622. }, scene?: Nullable<Scene>): GroundMesh;
  39623. }
  39624. }
  39625. declare module BABYLON {
  39626. /**
  39627. * Class containing static functions to help procedurally build meshes
  39628. */
  39629. export class TorusBuilder {
  39630. /**
  39631. * Creates a torus mesh
  39632. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39633. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39634. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39635. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39636. * * 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
  39637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39638. * @param name defines the name of the mesh
  39639. * @param options defines the options used to create the mesh
  39640. * @param scene defines the hosting scene
  39641. * @returns the torus mesh
  39642. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39643. */
  39644. static CreateTorus(name: string, options: {
  39645. diameter?: number;
  39646. thickness?: number;
  39647. tessellation?: number;
  39648. updatable?: boolean;
  39649. sideOrientation?: number;
  39650. frontUVs?: Vector4;
  39651. backUVs?: Vector4;
  39652. }, scene: any): Mesh;
  39653. }
  39654. }
  39655. declare module BABYLON {
  39656. /**
  39657. * Class containing static functions to help procedurally build meshes
  39658. */
  39659. export class CylinderBuilder {
  39660. /**
  39661. * Creates a cylinder or a cone mesh
  39662. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39663. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39664. * * 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.
  39665. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39666. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39667. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39668. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39669. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39670. * * 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).
  39671. * * 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
  39672. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39673. * * 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
  39674. * * 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.
  39675. * * If `enclose` is false, a ring surface is one element.
  39676. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39677. * * 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
  39678. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39679. * * 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
  39680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39681. * @param name defines the name of the mesh
  39682. * @param options defines the options used to create the mesh
  39683. * @param scene defines the hosting scene
  39684. * @returns the cylinder mesh
  39685. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39686. */
  39687. static CreateCylinder(name: string, options: {
  39688. height?: number;
  39689. diameterTop?: number;
  39690. diameterBottom?: number;
  39691. diameter?: number;
  39692. tessellation?: number;
  39693. subdivisions?: number;
  39694. arc?: number;
  39695. faceColors?: Color4[];
  39696. faceUV?: Vector4[];
  39697. updatable?: boolean;
  39698. hasRings?: boolean;
  39699. enclose?: boolean;
  39700. sideOrientation?: number;
  39701. frontUVs?: Vector4;
  39702. backUVs?: Vector4;
  39703. }, scene: any): Mesh;
  39704. }
  39705. }
  39706. declare module BABYLON {
  39707. /**
  39708. * Options to modify the vr teleportation behavior.
  39709. */
  39710. export interface VRTeleportationOptions {
  39711. /**
  39712. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39713. */
  39714. floorMeshName?: string;
  39715. /**
  39716. * A list of meshes to be used as the teleportation floor. (default: empty)
  39717. */
  39718. floorMeshes?: Mesh[];
  39719. }
  39720. /**
  39721. * Options to modify the vr experience helper's behavior.
  39722. */
  39723. export interface VRExperienceHelperOptions extends WebVROptions {
  39724. /**
  39725. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39726. */
  39727. createDeviceOrientationCamera?: boolean;
  39728. /**
  39729. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39730. */
  39731. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39732. /**
  39733. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39734. */
  39735. laserToggle?: boolean;
  39736. /**
  39737. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39738. */
  39739. floorMeshes?: Mesh[];
  39740. /**
  39741. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39742. */
  39743. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39744. }
  39745. /**
  39746. * Event containing information after VR has been entered
  39747. */
  39748. export class OnAfterEnteringVRObservableEvent {
  39749. /**
  39750. * If entering vr was successful
  39751. */
  39752. success: boolean;
  39753. }
  39754. /**
  39755. * Helps to quickly add VR support to an existing scene.
  39756. * See http://doc.babylonjs.com/how_to/webvr_helper
  39757. */
  39758. export class VRExperienceHelper {
  39759. /** Options to modify the vr experience helper's behavior. */
  39760. webVROptions: VRExperienceHelperOptions;
  39761. private _scene;
  39762. private _position;
  39763. private _btnVR;
  39764. private _btnVRDisplayed;
  39765. private _webVRsupported;
  39766. private _webVRready;
  39767. private _webVRrequesting;
  39768. private _webVRpresenting;
  39769. private _hasEnteredVR;
  39770. private _fullscreenVRpresenting;
  39771. private _canvas;
  39772. private _webVRCamera;
  39773. private _vrDeviceOrientationCamera;
  39774. private _deviceOrientationCamera;
  39775. private _existingCamera;
  39776. private _onKeyDown;
  39777. private _onVrDisplayPresentChange;
  39778. private _onVRDisplayChanged;
  39779. private _onVRRequestPresentStart;
  39780. private _onVRRequestPresentComplete;
  39781. /**
  39782. * Observable raised right before entering VR.
  39783. */
  39784. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39785. /**
  39786. * Observable raised when entering VR has completed.
  39787. */
  39788. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39789. /**
  39790. * Observable raised when exiting VR.
  39791. */
  39792. onExitingVRObservable: Observable<VRExperienceHelper>;
  39793. /**
  39794. * Observable raised when controller mesh is loaded.
  39795. */
  39796. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39797. /** Return this.onEnteringVRObservable
  39798. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39799. */
  39800. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39801. /** Return this.onExitingVRObservable
  39802. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39803. */
  39804. readonly onExitingVR: Observable<VRExperienceHelper>;
  39805. /** Return this.onControllerMeshLoadedObservable
  39806. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39807. */
  39808. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39809. private _rayLength;
  39810. private _useCustomVRButton;
  39811. private _teleportationRequested;
  39812. private _teleportActive;
  39813. private _floorMeshName;
  39814. private _floorMeshesCollection;
  39815. private _rotationAllowed;
  39816. private _teleportBackwardsVector;
  39817. private _teleportationTarget;
  39818. private _isDefaultTeleportationTarget;
  39819. private _postProcessMove;
  39820. private _teleportationFillColor;
  39821. private _teleportationBorderColor;
  39822. private _rotationAngle;
  39823. private _haloCenter;
  39824. private _cameraGazer;
  39825. private _padSensibilityUp;
  39826. private _padSensibilityDown;
  39827. private _leftController;
  39828. private _rightController;
  39829. /**
  39830. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39831. */
  39832. onNewMeshSelected: Observable<AbstractMesh>;
  39833. /**
  39834. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39835. */
  39836. onNewMeshPicked: Observable<PickingInfo>;
  39837. private _circleEase;
  39838. /**
  39839. * Observable raised before camera teleportation
  39840. */
  39841. onBeforeCameraTeleport: Observable<Vector3>;
  39842. /**
  39843. * Observable raised after camera teleportation
  39844. */
  39845. onAfterCameraTeleport: Observable<Vector3>;
  39846. /**
  39847. * Observable raised when current selected mesh gets unselected
  39848. */
  39849. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39850. private _raySelectionPredicate;
  39851. /**
  39852. * To be optionaly changed by user to define custom ray selection
  39853. */
  39854. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39855. /**
  39856. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39857. */
  39858. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39859. /**
  39860. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39861. */
  39862. teleportationEnabled: boolean;
  39863. private _defaultHeight;
  39864. private _teleportationInitialized;
  39865. private _interactionsEnabled;
  39866. private _interactionsRequested;
  39867. private _displayGaze;
  39868. private _displayLaserPointer;
  39869. /**
  39870. * The mesh used to display where the user is going to teleport.
  39871. */
  39872. /**
  39873. * Sets the mesh to be used to display where the user is going to teleport.
  39874. */
  39875. teleportationTarget: Mesh;
  39876. /**
  39877. * 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
  39878. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39879. * See http://doc.babylonjs.com/resources/baking_transformations
  39880. */
  39881. gazeTrackerMesh: Mesh;
  39882. /**
  39883. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39884. */
  39885. updateGazeTrackerScale: boolean;
  39886. /**
  39887. * If the gaze trackers color should be updated when selecting meshes
  39888. */
  39889. updateGazeTrackerColor: boolean;
  39890. /**
  39891. * The gaze tracking mesh corresponding to the left controller
  39892. */
  39893. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39894. /**
  39895. * The gaze tracking mesh corresponding to the right controller
  39896. */
  39897. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39898. /**
  39899. * If the ray of the gaze should be displayed.
  39900. */
  39901. /**
  39902. * Sets if the ray of the gaze should be displayed.
  39903. */
  39904. displayGaze: boolean;
  39905. /**
  39906. * If the ray of the LaserPointer should be displayed.
  39907. */
  39908. /**
  39909. * Sets if the ray of the LaserPointer should be displayed.
  39910. */
  39911. displayLaserPointer: boolean;
  39912. /**
  39913. * The deviceOrientationCamera used as the camera when not in VR.
  39914. */
  39915. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39916. /**
  39917. * Based on the current WebVR support, returns the current VR camera used.
  39918. */
  39919. readonly currentVRCamera: Nullable<Camera>;
  39920. /**
  39921. * The webVRCamera which is used when in VR.
  39922. */
  39923. readonly webVRCamera: WebVRFreeCamera;
  39924. /**
  39925. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39926. */
  39927. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39928. private readonly _teleportationRequestInitiated;
  39929. /**
  39930. * Defines wether or not Pointer lock should be requested when switching to
  39931. * full screen.
  39932. */
  39933. requestPointerLockOnFullScreen: boolean;
  39934. /**
  39935. * Instantiates a VRExperienceHelper.
  39936. * Helps to quickly add VR support to an existing scene.
  39937. * @param scene The scene the VRExperienceHelper belongs to.
  39938. * @param webVROptions Options to modify the vr experience helper's behavior.
  39939. */
  39940. constructor(scene: Scene,
  39941. /** Options to modify the vr experience helper's behavior. */
  39942. webVROptions?: VRExperienceHelperOptions);
  39943. private _onDefaultMeshLoaded;
  39944. private _onResize;
  39945. private _onFullscreenChange;
  39946. /**
  39947. * Gets a value indicating if we are currently in VR mode.
  39948. */
  39949. readonly isInVRMode: boolean;
  39950. private onVrDisplayPresentChange;
  39951. private onVRDisplayChanged;
  39952. private moveButtonToBottomRight;
  39953. private displayVRButton;
  39954. private updateButtonVisibility;
  39955. private _cachedAngularSensibility;
  39956. /**
  39957. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39958. * Otherwise, will use the fullscreen API.
  39959. */
  39960. enterVR(): void;
  39961. /**
  39962. * Attempt to exit VR, or fullscreen.
  39963. */
  39964. exitVR(): void;
  39965. /**
  39966. * The position of the vr experience helper.
  39967. */
  39968. /**
  39969. * Sets the position of the vr experience helper.
  39970. */
  39971. position: Vector3;
  39972. /**
  39973. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39974. */
  39975. enableInteractions(): void;
  39976. private readonly _noControllerIsActive;
  39977. private beforeRender;
  39978. private _isTeleportationFloor;
  39979. /**
  39980. * Adds a floor mesh to be used for teleportation.
  39981. * @param floorMesh the mesh to be used for teleportation.
  39982. */
  39983. addFloorMesh(floorMesh: Mesh): void;
  39984. /**
  39985. * Removes a floor mesh from being used for teleportation.
  39986. * @param floorMesh the mesh to be removed.
  39987. */
  39988. removeFloorMesh(floorMesh: Mesh): void;
  39989. /**
  39990. * Enables interactions and teleportation using the VR controllers and gaze.
  39991. * @param vrTeleportationOptions options to modify teleportation behavior.
  39992. */
  39993. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39994. private _onNewGamepadConnected;
  39995. private _tryEnableInteractionOnController;
  39996. private _onNewGamepadDisconnected;
  39997. private _enableInteractionOnController;
  39998. private _checkTeleportWithRay;
  39999. private _checkRotate;
  40000. private _checkTeleportBackwards;
  40001. private _enableTeleportationOnController;
  40002. private _createTeleportationCircles;
  40003. private _displayTeleportationTarget;
  40004. private _hideTeleportationTarget;
  40005. private _rotateCamera;
  40006. private _moveTeleportationSelectorTo;
  40007. private _workingVector;
  40008. private _workingQuaternion;
  40009. private _workingMatrix;
  40010. /**
  40011. * Teleports the users feet to the desired location
  40012. * @param location The location where the user's feet should be placed
  40013. */
  40014. teleportCamera(location: Vector3): void;
  40015. private _convertNormalToDirectionOfRay;
  40016. private _castRayAndSelectObject;
  40017. private _notifySelectedMeshUnselected;
  40018. /**
  40019. * Sets the color of the laser ray from the vr controllers.
  40020. * @param color new color for the ray.
  40021. */
  40022. changeLaserColor(color: Color3): void;
  40023. /**
  40024. * Sets the color of the ray from the vr headsets gaze.
  40025. * @param color new color for the ray.
  40026. */
  40027. changeGazeColor(color: Color3): void;
  40028. /**
  40029. * Exits VR and disposes of the vr experience helper
  40030. */
  40031. dispose(): void;
  40032. /**
  40033. * Gets the name of the VRExperienceHelper class
  40034. * @returns "VRExperienceHelper"
  40035. */
  40036. getClassName(): string;
  40037. }
  40038. }
  40039. declare module BABYLON {
  40040. /**
  40041. * Manages an XRSession
  40042. * @see https://doc.babylonjs.com/how_to/webxr
  40043. */
  40044. export class WebXRSessionManager implements IDisposable {
  40045. private scene;
  40046. /**
  40047. * Fires every time a new xrFrame arrives which can be used to update the camera
  40048. */
  40049. onXRFrameObservable: Observable<any>;
  40050. /**
  40051. * Fires when the xr session is ended either by the device or manually done
  40052. */
  40053. onXRSessionEnded: Observable<any>;
  40054. /** @hidden */
  40055. _xrSession: XRSession;
  40056. /** @hidden */
  40057. _frameOfReference: XRFrameOfReference;
  40058. /** @hidden */
  40059. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40060. /** @hidden */
  40061. _currentXRFrame: Nullable<XRFrame>;
  40062. private _xrNavigator;
  40063. private _xrDevice;
  40064. private _tmpMatrix;
  40065. /**
  40066. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40067. * @param scene The scene which the session should be created for
  40068. */
  40069. constructor(scene: Scene);
  40070. /**
  40071. * Initializes the manager
  40072. * After initialization enterXR can be called to start an XR session
  40073. * @returns Promise which resolves after it is initialized
  40074. */
  40075. initializeAsync(): Promise<void>;
  40076. /**
  40077. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40078. * @param sessionCreationOptions xr options to create the session with
  40079. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40080. * @returns Promise which resolves after it enters XR
  40081. */
  40082. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40083. /**
  40084. * Stops the xrSession and restores the renderloop
  40085. * @returns Promise which resolves after it exits XR
  40086. */
  40087. exitXRAsync(): Promise<void>;
  40088. /**
  40089. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40090. * @param ray ray to cast into the environment
  40091. * @returns Promise which resolves with a collision point in the environment if it exists
  40092. */
  40093. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40094. /**
  40095. * Checks if a session would be supported for the creation options specified
  40096. * @param options creation options to check if they are supported
  40097. * @returns true if supported
  40098. */
  40099. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40100. /**
  40101. * @hidden
  40102. * Converts the render layer of xrSession to a render target
  40103. * @param session session to create render target for
  40104. * @param scene scene the new render target should be created for
  40105. */
  40106. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40107. /**
  40108. * Disposes of the session manager
  40109. */
  40110. dispose(): void;
  40111. }
  40112. }
  40113. declare module BABYLON {
  40114. /**
  40115. * WebXR Camera which holds the views for the xrSession
  40116. * @see https://doc.babylonjs.com/how_to/webxr
  40117. */
  40118. export class WebXRCamera extends FreeCamera {
  40119. private static _TmpMatrix;
  40120. /**
  40121. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40122. * @param name the name of the camera
  40123. * @param scene the scene to add the camera to
  40124. */
  40125. constructor(name: string, scene: Scene);
  40126. private _updateNumberOfRigCameras;
  40127. /** @hidden */
  40128. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40129. /**
  40130. * Updates the cameras position from the current pose information of the XR session
  40131. * @param xrSessionManager the session containing pose information
  40132. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40133. */
  40134. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40135. }
  40136. }
  40137. declare module BABYLON {
  40138. /**
  40139. * States of the webXR experience
  40140. */
  40141. export enum WebXRState {
  40142. /**
  40143. * Transitioning to being in XR mode
  40144. */
  40145. ENTERING_XR = 0,
  40146. /**
  40147. * Transitioning to non XR mode
  40148. */
  40149. EXITING_XR = 1,
  40150. /**
  40151. * In XR mode and presenting
  40152. */
  40153. IN_XR = 2,
  40154. /**
  40155. * Not entered XR mode
  40156. */
  40157. NOT_IN_XR = 3
  40158. }
  40159. /**
  40160. * Helper class used to enable XR
  40161. * @see https://doc.babylonjs.com/how_to/webxr
  40162. */
  40163. export class WebXRExperienceHelper implements IDisposable {
  40164. private scene;
  40165. /**
  40166. * 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
  40167. */
  40168. container: AbstractMesh;
  40169. /**
  40170. * Camera used to render xr content
  40171. */
  40172. camera: WebXRCamera;
  40173. /**
  40174. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40175. */
  40176. state: WebXRState;
  40177. private _setState;
  40178. private static _TmpVector;
  40179. /**
  40180. * Fires when the state of the experience helper has changed
  40181. */
  40182. onStateChangedObservable: Observable<WebXRState>;
  40183. /** @hidden */
  40184. _sessionManager: WebXRSessionManager;
  40185. private _nonVRCamera;
  40186. private _originalSceneAutoClear;
  40187. private _supported;
  40188. /**
  40189. * Creates the experience helper
  40190. * @param scene the scene to attach the experience helper to
  40191. * @returns a promise for the experience helper
  40192. */
  40193. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40194. /**
  40195. * Creates a WebXRExperienceHelper
  40196. * @param scene The scene the helper should be created in
  40197. */
  40198. private constructor();
  40199. /**
  40200. * Exits XR mode and returns the scene to its original state
  40201. * @returns promise that resolves after xr mode has exited
  40202. */
  40203. exitXRAsync(): Promise<void>;
  40204. /**
  40205. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40206. * @param sessionCreationOptions options for the XR session
  40207. * @param frameOfReference frame of reference of the XR session
  40208. * @returns promise that resolves after xr mode has entered
  40209. */
  40210. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40211. /**
  40212. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40213. * @param ray ray to cast into the environment
  40214. * @returns Promise which resolves with a collision point in the environment if it exists
  40215. */
  40216. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40217. /**
  40218. * Updates the global position of the camera by moving the camera's container
  40219. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40220. * @param position The desired global position of the camera
  40221. */
  40222. setPositionOfCameraUsingContainer(position: Vector3): void;
  40223. /**
  40224. * Rotates the xr camera by rotating the camera's container around the camera's position
  40225. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40226. * @param rotation the desired quaternion rotation to apply to the camera
  40227. */
  40228. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40229. /**
  40230. * Checks if the creation options are supported by the xr session
  40231. * @param options creation options
  40232. * @returns true if supported
  40233. */
  40234. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40235. /**
  40236. * Disposes of the experience helper
  40237. */
  40238. dispose(): void;
  40239. }
  40240. }
  40241. declare module BABYLON {
  40242. /**
  40243. * Button which can be used to enter a different mode of XR
  40244. */
  40245. export class WebXREnterExitUIButton {
  40246. /** button element */
  40247. element: HTMLElement;
  40248. /** XR initialization options for the button */
  40249. initializationOptions: XRSessionCreationOptions;
  40250. /**
  40251. * Creates a WebXREnterExitUIButton
  40252. * @param element button element
  40253. * @param initializationOptions XR initialization options for the button
  40254. */
  40255. constructor(
  40256. /** button element */
  40257. element: HTMLElement,
  40258. /** XR initialization options for the button */
  40259. initializationOptions: XRSessionCreationOptions);
  40260. /**
  40261. * Overwritable function which can be used to update the button's visuals when the state changes
  40262. * @param activeButton the current active button in the UI
  40263. */
  40264. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40265. }
  40266. /**
  40267. * Options to create the webXR UI
  40268. */
  40269. export class WebXREnterExitUIOptions {
  40270. /**
  40271. * Context to enter xr with
  40272. */
  40273. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40274. /**
  40275. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40276. */
  40277. customButtons?: Array<WebXREnterExitUIButton>;
  40278. }
  40279. /**
  40280. * UI to allow the user to enter/exit XR mode
  40281. */
  40282. export class WebXREnterExitUI implements IDisposable {
  40283. private scene;
  40284. private _overlay;
  40285. private _buttons;
  40286. private _activeButton;
  40287. /**
  40288. * Fired every time the active button is changed.
  40289. *
  40290. * When xr is entered via a button that launches xr that button will be the callback parameter
  40291. *
  40292. * When exiting xr the callback parameter will be null)
  40293. */
  40294. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40295. /**
  40296. * Creates UI to allow the user to enter/exit XR mode
  40297. * @param scene the scene to add the ui to
  40298. * @param helper the xr experience helper to enter/exit xr with
  40299. * @param options options to configure the UI
  40300. * @returns the created ui
  40301. */
  40302. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40303. private constructor();
  40304. private _updateButtons;
  40305. /**
  40306. * Disposes of the object
  40307. */
  40308. dispose(): void;
  40309. }
  40310. }
  40311. declare module BABYLON {
  40312. /**
  40313. * Represents an XR input
  40314. */
  40315. export class WebXRController {
  40316. /**
  40317. * 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
  40318. */
  40319. grip?: AbstractMesh;
  40320. /**
  40321. * Pointer which can be used to select objects or attach a visible laser to
  40322. */
  40323. pointer: AbstractMesh;
  40324. /**
  40325. * Creates the controller
  40326. * @see https://doc.babylonjs.com/how_to/webxr
  40327. * @param scene the scene which the controller should be associated to
  40328. */
  40329. constructor(scene: Scene);
  40330. /**
  40331. * Disposes of the object
  40332. */
  40333. dispose(): void;
  40334. }
  40335. /**
  40336. * XR input used to track XR inputs such as controllers/rays
  40337. */
  40338. export class WebXRInput implements IDisposable {
  40339. private helper;
  40340. /**
  40341. * XR controllers being tracked
  40342. */
  40343. controllers: Array<WebXRController>;
  40344. private _tmpMatrix;
  40345. private _frameObserver;
  40346. /**
  40347. * Initializes the WebXRInput
  40348. * @param helper experience helper which the input should be created for
  40349. */
  40350. constructor(helper: WebXRExperienceHelper);
  40351. /**
  40352. * Disposes of the object
  40353. */
  40354. dispose(): void;
  40355. }
  40356. }
  40357. declare module BABYLON {
  40358. /**
  40359. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40360. */
  40361. export class WebXRManagedOutputCanvas implements IDisposable {
  40362. private _canvas;
  40363. /**
  40364. * xrpresent context of the canvas which can be used to display/mirror xr content
  40365. */
  40366. canvasContext: Nullable<WebGLRenderingContext>;
  40367. /**
  40368. * Initializes the canvas to be added/removed upon entering/exiting xr
  40369. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40370. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40371. */
  40372. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40373. /**
  40374. * Disposes of the object
  40375. */
  40376. dispose(): void;
  40377. private _setManagedOutputCanvas;
  40378. private _addCanvas;
  40379. private _removeCanvas;
  40380. }
  40381. }
  40382. declare module BABYLON {
  40383. /**
  40384. * Contains an array of blocks representing the octree
  40385. */
  40386. export interface IOctreeContainer<T> {
  40387. /**
  40388. * Blocks within the octree
  40389. */
  40390. blocks: Array<OctreeBlock<T>>;
  40391. }
  40392. /**
  40393. * Class used to store a cell in an octree
  40394. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40395. */
  40396. export class OctreeBlock<T> {
  40397. /**
  40398. * Gets the content of the current block
  40399. */
  40400. entries: T[];
  40401. /**
  40402. * Gets the list of block children
  40403. */
  40404. blocks: Array<OctreeBlock<T>>;
  40405. private _depth;
  40406. private _maxDepth;
  40407. private _capacity;
  40408. private _minPoint;
  40409. private _maxPoint;
  40410. private _boundingVectors;
  40411. private _creationFunc;
  40412. /**
  40413. * Creates a new block
  40414. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40415. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40416. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40417. * @param depth defines the current depth of this block in the octree
  40418. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40419. * @param creationFunc defines a callback to call when an element is added to the block
  40420. */
  40421. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40422. /**
  40423. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40424. */
  40425. readonly capacity: number;
  40426. /**
  40427. * Gets the minimum vector (in world space) of the block's bounding box
  40428. */
  40429. readonly minPoint: Vector3;
  40430. /**
  40431. * Gets the maximum vector (in world space) of the block's bounding box
  40432. */
  40433. readonly maxPoint: Vector3;
  40434. /**
  40435. * Add a new element to this block
  40436. * @param entry defines the element to add
  40437. */
  40438. addEntry(entry: T): void;
  40439. /**
  40440. * Remove an element from this block
  40441. * @param entry defines the element to remove
  40442. */
  40443. removeEntry(entry: T): void;
  40444. /**
  40445. * Add an array of elements to this block
  40446. * @param entries defines the array of elements to add
  40447. */
  40448. addEntries(entries: T[]): void;
  40449. /**
  40450. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40451. * @param frustumPlanes defines the frustum planes to test
  40452. * @param selection defines the array to store current content if selection is positive
  40453. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40454. */
  40455. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40456. /**
  40457. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40458. * @param sphereCenter defines the bounding sphere center
  40459. * @param sphereRadius defines the bounding sphere radius
  40460. * @param selection defines the array to store current content if selection is positive
  40461. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40462. */
  40463. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40464. /**
  40465. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40466. * @param ray defines the ray to test with
  40467. * @param selection defines the array to store current content if selection is positive
  40468. */
  40469. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40470. /**
  40471. * Subdivide the content into child blocks (this block will then be empty)
  40472. */
  40473. createInnerBlocks(): void;
  40474. /**
  40475. * @hidden
  40476. */
  40477. 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;
  40478. }
  40479. }
  40480. declare module BABYLON {
  40481. /**
  40482. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40483. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40484. */
  40485. export class Octree<T> {
  40486. /** 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.) */
  40487. maxDepth: number;
  40488. /**
  40489. * Blocks within the octree containing objects
  40490. */
  40491. blocks: Array<OctreeBlock<T>>;
  40492. /**
  40493. * Content stored in the octree
  40494. */
  40495. dynamicContent: T[];
  40496. private _maxBlockCapacity;
  40497. private _selectionContent;
  40498. private _creationFunc;
  40499. /**
  40500. * Creates a octree
  40501. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40502. * @param creationFunc function to be used to instatiate the octree
  40503. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40504. * @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.)
  40505. */
  40506. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40507. /** 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.) */
  40508. maxDepth?: number);
  40509. /**
  40510. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40511. * @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);
  40512. * @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);
  40513. * @param entries meshes to be added to the octree blocks
  40514. */
  40515. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40516. /**
  40517. * Adds a mesh to the octree
  40518. * @param entry Mesh to add to the octree
  40519. */
  40520. addMesh(entry: T): void;
  40521. /**
  40522. * Remove an element from the octree
  40523. * @param entry defines the element to remove
  40524. */
  40525. removeMesh(entry: T): void;
  40526. /**
  40527. * Selects an array of meshes within the frustum
  40528. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40529. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40530. * @returns array of meshes within the frustum
  40531. */
  40532. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40533. /**
  40534. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40535. * @param sphereCenter defines the bounding sphere center
  40536. * @param sphereRadius defines the bounding sphere radius
  40537. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40538. * @returns an array of objects that intersect the sphere
  40539. */
  40540. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40541. /**
  40542. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40543. * @param ray defines the ray to test with
  40544. * @returns array of intersected objects
  40545. */
  40546. intersectsRay(ray: Ray): SmartArray<T>;
  40547. /**
  40548. * Adds a mesh into the octree block if it intersects the block
  40549. */
  40550. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40551. /**
  40552. * Adds a submesh into the octree block if it intersects the block
  40553. */
  40554. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40555. }
  40556. }
  40557. declare module BABYLON {
  40558. interface Scene {
  40559. /**
  40560. * @hidden
  40561. * Backing Filed
  40562. */
  40563. _selectionOctree: Octree<AbstractMesh>;
  40564. /**
  40565. * Gets the octree used to boost mesh selection (picking)
  40566. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40567. */
  40568. selectionOctree: Octree<AbstractMesh>;
  40569. /**
  40570. * Creates or updates the octree used to boost selection (picking)
  40571. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40572. * @param maxCapacity defines the maximum capacity per leaf
  40573. * @param maxDepth defines the maximum depth of the octree
  40574. * @returns an octree of AbstractMesh
  40575. */
  40576. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40577. }
  40578. interface AbstractMesh {
  40579. /**
  40580. * @hidden
  40581. * Backing Field
  40582. */
  40583. _submeshesOctree: Octree<SubMesh>;
  40584. /**
  40585. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40586. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40587. * @param maxCapacity defines the maximum size of each block (64 by default)
  40588. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40589. * @returns the new octree
  40590. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40591. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40592. */
  40593. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40594. }
  40595. /**
  40596. * Defines the octree scene component responsible to manage any octrees
  40597. * in a given scene.
  40598. */
  40599. export class OctreeSceneComponent {
  40600. /**
  40601. * The component name help to identify the component in the list of scene components.
  40602. */
  40603. readonly name: string;
  40604. /**
  40605. * The scene the component belongs to.
  40606. */
  40607. scene: Scene;
  40608. /**
  40609. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40610. */
  40611. readonly checksIsEnabled: boolean;
  40612. /**
  40613. * Creates a new instance of the component for the given scene
  40614. * @param scene Defines the scene to register the component in
  40615. */
  40616. constructor(scene: Scene);
  40617. /**
  40618. * Registers the component in a given scene
  40619. */
  40620. register(): void;
  40621. /**
  40622. * Return the list of active meshes
  40623. * @returns the list of active meshes
  40624. */
  40625. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40626. /**
  40627. * Return the list of active sub meshes
  40628. * @param mesh The mesh to get the candidates sub meshes from
  40629. * @returns the list of active sub meshes
  40630. */
  40631. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40632. private _tempRay;
  40633. /**
  40634. * Return the list of sub meshes intersecting with a given local ray
  40635. * @param mesh defines the mesh to find the submesh for
  40636. * @param localRay defines the ray in local space
  40637. * @returns the list of intersecting sub meshes
  40638. */
  40639. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40640. /**
  40641. * Return the list of sub meshes colliding with a collider
  40642. * @param mesh defines the mesh to find the submesh for
  40643. * @param collider defines the collider to evaluate the collision against
  40644. * @returns the list of colliding sub meshes
  40645. */
  40646. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40647. /**
  40648. * Rebuilds the elements related to this component in case of
  40649. * context lost for instance.
  40650. */
  40651. rebuild(): void;
  40652. /**
  40653. * Disposes the component and the associated ressources.
  40654. */
  40655. dispose(): void;
  40656. }
  40657. }
  40658. declare module BABYLON {
  40659. /**
  40660. * Renders a layer on top of an existing scene
  40661. */
  40662. export class UtilityLayerRenderer implements IDisposable {
  40663. /** the original scene that will be rendered on top of */
  40664. originalScene: Scene;
  40665. private _pointerCaptures;
  40666. private _lastPointerEvents;
  40667. private static _DefaultUtilityLayer;
  40668. private static _DefaultKeepDepthUtilityLayer;
  40669. private _sharedGizmoLight;
  40670. /**
  40671. * @hidden
  40672. * Light which used by gizmos to get light shading
  40673. */
  40674. _getSharedGizmoLight(): HemisphericLight;
  40675. /**
  40676. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40677. */
  40678. pickUtilitySceneFirst: boolean;
  40679. /**
  40680. * 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)
  40681. */
  40682. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40683. /**
  40684. * 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)
  40685. */
  40686. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40687. /**
  40688. * The scene that is rendered on top of the original scene
  40689. */
  40690. utilityLayerScene: Scene;
  40691. /**
  40692. * If the utility layer should automatically be rendered on top of existing scene
  40693. */
  40694. shouldRender: boolean;
  40695. /**
  40696. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40697. */
  40698. onlyCheckPointerDownEvents: boolean;
  40699. /**
  40700. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40701. */
  40702. processAllEvents: boolean;
  40703. /**
  40704. * Observable raised when the pointer move from the utility layer scene to the main scene
  40705. */
  40706. onPointerOutObservable: Observable<number>;
  40707. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40708. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40709. private _afterRenderObserver;
  40710. private _sceneDisposeObserver;
  40711. private _originalPointerObserver;
  40712. /**
  40713. * Instantiates a UtilityLayerRenderer
  40714. * @param originalScene the original scene that will be rendered on top of
  40715. * @param handleEvents boolean indicating if the utility layer should handle events
  40716. */
  40717. constructor(
  40718. /** the original scene that will be rendered on top of */
  40719. originalScene: Scene, handleEvents?: boolean);
  40720. private _notifyObservers;
  40721. /**
  40722. * Renders the utility layers scene on top of the original scene
  40723. */
  40724. render(): void;
  40725. /**
  40726. * Disposes of the renderer
  40727. */
  40728. dispose(): void;
  40729. private _updateCamera;
  40730. }
  40731. }
  40732. declare module BABYLON {
  40733. /**
  40734. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40735. */
  40736. export class Gizmo implements IDisposable {
  40737. /** The utility layer the gizmo will be added to */
  40738. gizmoLayer: UtilityLayerRenderer;
  40739. /**
  40740. * The root mesh of the gizmo
  40741. */
  40742. _rootMesh: Mesh;
  40743. private _attachedMesh;
  40744. /**
  40745. * Ratio for the scale of the gizmo (Default: 1)
  40746. */
  40747. scaleRatio: number;
  40748. /**
  40749. * If a custom mesh has been set (Default: false)
  40750. */
  40751. protected _customMeshSet: boolean;
  40752. /**
  40753. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40754. * * When set, interactions will be enabled
  40755. */
  40756. attachedMesh: Nullable<AbstractMesh>;
  40757. /**
  40758. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40759. * @param mesh The mesh to replace the default mesh of the gizmo
  40760. */
  40761. setCustomMesh(mesh: Mesh): void;
  40762. /**
  40763. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40764. */
  40765. updateGizmoRotationToMatchAttachedMesh: boolean;
  40766. /**
  40767. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40768. */
  40769. updateGizmoPositionToMatchAttachedMesh: boolean;
  40770. /**
  40771. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40772. */
  40773. protected _updateScale: boolean;
  40774. protected _interactionsEnabled: boolean;
  40775. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40776. private _beforeRenderObserver;
  40777. private _tempVector;
  40778. /**
  40779. * Creates a gizmo
  40780. * @param gizmoLayer The utility layer the gizmo will be added to
  40781. */
  40782. constructor(
  40783. /** The utility layer the gizmo will be added to */
  40784. gizmoLayer?: UtilityLayerRenderer);
  40785. /**
  40786. * Updates the gizmo to match the attached mesh's position/rotation
  40787. */
  40788. protected _update(): void;
  40789. /**
  40790. * Disposes of the gizmo
  40791. */
  40792. dispose(): void;
  40793. }
  40794. }
  40795. declare module BABYLON {
  40796. /**
  40797. * Single axis drag gizmo
  40798. */
  40799. export class AxisDragGizmo extends Gizmo {
  40800. /**
  40801. * Drag behavior responsible for the gizmos dragging interactions
  40802. */
  40803. dragBehavior: PointerDragBehavior;
  40804. private _pointerObserver;
  40805. /**
  40806. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40807. */
  40808. snapDistance: number;
  40809. /**
  40810. * Event that fires each time the gizmo snaps to a new location.
  40811. * * snapDistance is the the change in distance
  40812. */
  40813. onSnapObservable: Observable<{
  40814. snapDistance: number;
  40815. }>;
  40816. /** @hidden */
  40817. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40818. /** @hidden */
  40819. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40820. /**
  40821. * Creates an AxisDragGizmo
  40822. * @param gizmoLayer The utility layer the gizmo will be added to
  40823. * @param dragAxis The axis which the gizmo will be able to drag on
  40824. * @param color The color of the gizmo
  40825. */
  40826. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40827. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40828. /**
  40829. * Disposes of the gizmo
  40830. */
  40831. dispose(): void;
  40832. }
  40833. }
  40834. declare module BABYLON.Debug {
  40835. /**
  40836. * The Axes viewer will show 3 axes in a specific point in space
  40837. */
  40838. export class AxesViewer {
  40839. private _xAxis;
  40840. private _yAxis;
  40841. private _zAxis;
  40842. private _scaleLinesFactor;
  40843. private _instanced;
  40844. /**
  40845. * Gets the hosting scene
  40846. */
  40847. scene: Scene;
  40848. /**
  40849. * Gets or sets a number used to scale line length
  40850. */
  40851. scaleLines: number;
  40852. /** Gets the node hierarchy used to render x-axis */
  40853. readonly xAxis: TransformNode;
  40854. /** Gets the node hierarchy used to render y-axis */
  40855. readonly yAxis: TransformNode;
  40856. /** Gets the node hierarchy used to render z-axis */
  40857. readonly zAxis: TransformNode;
  40858. /**
  40859. * Creates a new AxesViewer
  40860. * @param scene defines the hosting scene
  40861. * @param scaleLines defines a number used to scale line length (1 by default)
  40862. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40863. * @param xAxis defines the node hierarchy used to render the x-axis
  40864. * @param yAxis defines the node hierarchy used to render the y-axis
  40865. * @param zAxis defines the node hierarchy used to render the z-axis
  40866. */
  40867. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40868. /**
  40869. * Force the viewer to update
  40870. * @param position defines the position of the viewer
  40871. * @param xaxis defines the x axis of the viewer
  40872. * @param yaxis defines the y axis of the viewer
  40873. * @param zaxis defines the z axis of the viewer
  40874. */
  40875. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40876. /**
  40877. * Creates an instance of this axes viewer.
  40878. * @returns a new axes viewer with instanced meshes
  40879. */
  40880. createInstance(): AxesViewer;
  40881. /** Releases resources */
  40882. dispose(): void;
  40883. private static _SetRenderingGroupId;
  40884. }
  40885. }
  40886. declare module BABYLON.Debug {
  40887. /**
  40888. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40889. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40890. */
  40891. export class BoneAxesViewer extends AxesViewer {
  40892. /**
  40893. * Gets or sets the target mesh where to display the axes viewer
  40894. */
  40895. mesh: Nullable<Mesh>;
  40896. /**
  40897. * Gets or sets the target bone where to display the axes viewer
  40898. */
  40899. bone: Nullable<Bone>;
  40900. /** Gets current position */
  40901. pos: Vector3;
  40902. /** Gets direction of X axis */
  40903. xaxis: Vector3;
  40904. /** Gets direction of Y axis */
  40905. yaxis: Vector3;
  40906. /** Gets direction of Z axis */
  40907. zaxis: Vector3;
  40908. /**
  40909. * Creates a new BoneAxesViewer
  40910. * @param scene defines the hosting scene
  40911. * @param bone defines the target bone
  40912. * @param mesh defines the target mesh
  40913. * @param scaleLines defines a scaling factor for line length (1 by default)
  40914. */
  40915. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40916. /**
  40917. * Force the viewer to update
  40918. */
  40919. update(): void;
  40920. /** Releases resources */
  40921. dispose(): void;
  40922. }
  40923. }
  40924. declare module BABYLON {
  40925. /**
  40926. * Interface used to define scene explorer extensibility option
  40927. */
  40928. export interface IExplorerExtensibilityOption {
  40929. /**
  40930. * Define the option label
  40931. */
  40932. label: string;
  40933. /**
  40934. * Defines the action to execute on click
  40935. */
  40936. action: (entity: any) => void;
  40937. }
  40938. /**
  40939. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40940. */
  40941. export interface IExplorerExtensibilityGroup {
  40942. /**
  40943. * Defines a predicate to test if a given type mut be extended
  40944. */
  40945. predicate: (entity: any) => boolean;
  40946. /**
  40947. * Gets the list of options added to a type
  40948. */
  40949. entries: IExplorerExtensibilityOption[];
  40950. }
  40951. /**
  40952. * Interface used to define the options to use to create the Inspector
  40953. */
  40954. export interface IInspectorOptions {
  40955. /**
  40956. * Display in overlay mode (default: false)
  40957. */
  40958. overlay?: boolean;
  40959. /**
  40960. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40961. */
  40962. globalRoot?: HTMLElement;
  40963. /**
  40964. * Display the Scene explorer
  40965. */
  40966. showExplorer?: boolean;
  40967. /**
  40968. * Display the property inspector
  40969. */
  40970. showInspector?: boolean;
  40971. /**
  40972. * Display in embed mode (both panes on the right)
  40973. */
  40974. embedMode?: boolean;
  40975. /**
  40976. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40977. */
  40978. handleResize?: boolean;
  40979. /**
  40980. * Allow the panes to popup (default: true)
  40981. */
  40982. enablePopup?: boolean;
  40983. /**
  40984. * Allow the panes to be closed by users (default: true)
  40985. */
  40986. enableClose?: boolean;
  40987. /**
  40988. * Optional list of extensibility entries
  40989. */
  40990. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40991. /**
  40992. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40993. */
  40994. inspectorURL?: string;
  40995. }
  40996. interface Scene {
  40997. /**
  40998. * @hidden
  40999. * Backing field
  41000. */
  41001. _debugLayer: DebugLayer;
  41002. /**
  41003. * Gets the debug layer (aka Inspector) associated with the scene
  41004. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41005. */
  41006. debugLayer: DebugLayer;
  41007. }
  41008. /**
  41009. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41010. * what is happening in your scene
  41011. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41012. */
  41013. export class DebugLayer {
  41014. /**
  41015. * Define the url to get the inspector script from.
  41016. * By default it uses the babylonjs CDN.
  41017. * @ignoreNaming
  41018. */
  41019. static InspectorURL: string;
  41020. private _scene;
  41021. private BJSINSPECTOR;
  41022. /**
  41023. * Observable triggered when a property is changed through the inspector.
  41024. */
  41025. onPropertyChangedObservable: Observable<{
  41026. object: any;
  41027. property: string;
  41028. value: any;
  41029. initialValue: any;
  41030. }>;
  41031. /**
  41032. * Instantiates a new debug layer.
  41033. * The debug layer (aka Inspector) is the go to tool in order to better understand
  41034. * what is happening in your scene
  41035. * @see http://doc.babylonjs.com/features/playground_debuglayer
  41036. * @param scene Defines the scene to inspect
  41037. */
  41038. constructor(scene: Scene);
  41039. /** Creates the inspector window. */
  41040. private _createInspector;
  41041. /**
  41042. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  41043. * @param entity defines the entity to select
  41044. * @param lineContainerTitle defines the specific block to highlight
  41045. */
  41046. select(entity: any, lineContainerTitle?: string): void;
  41047. /** Get the inspector from bundle or global */
  41048. private _getGlobalInspector;
  41049. /**
  41050. * Get if the inspector is visible or not.
  41051. * @returns true if visible otherwise, false
  41052. */
  41053. isVisible(): boolean;
  41054. /**
  41055. * Hide the inspector and close its window.
  41056. */
  41057. hide(): void;
  41058. /**
  41059. * Launch the debugLayer.
  41060. * @param config Define the configuration of the inspector
  41061. * @return a promise fulfilled when the debug layer is visible
  41062. */
  41063. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41064. }
  41065. }
  41066. declare module BABYLON {
  41067. /**
  41068. * Class containing static functions to help procedurally build meshes
  41069. */
  41070. export class BoxBuilder {
  41071. /**
  41072. * Creates a box mesh
  41073. * * The parameter `size` sets the size (float) of each box side (default 1)
  41074. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41075. * * 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)
  41076. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41078. * * 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
  41079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41080. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41081. * @param name defines the name of the mesh
  41082. * @param options defines the options used to create the mesh
  41083. * @param scene defines the hosting scene
  41084. * @returns the box mesh
  41085. */
  41086. static CreateBox(name: string, options: {
  41087. size?: number;
  41088. width?: number;
  41089. height?: number;
  41090. depth?: number;
  41091. faceUV?: Vector4[];
  41092. faceColors?: Color4[];
  41093. sideOrientation?: number;
  41094. frontUVs?: Vector4;
  41095. backUVs?: Vector4;
  41096. wrap?: boolean;
  41097. topBaseAt?: number;
  41098. bottomBaseAt?: number;
  41099. updatable?: boolean;
  41100. }, scene?: Nullable<Scene>): Mesh;
  41101. }
  41102. }
  41103. declare module BABYLON {
  41104. /**
  41105. * Class containing static functions to help procedurally build meshes
  41106. */
  41107. export class SphereBuilder {
  41108. /**
  41109. * Creates a sphere mesh
  41110. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41111. * * 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`)
  41112. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41113. * * 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
  41114. * * 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)
  41115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41116. * * 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
  41117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41118. * @param name defines the name of the mesh
  41119. * @param options defines the options used to create the mesh
  41120. * @param scene defines the hosting scene
  41121. * @returns the sphere mesh
  41122. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41123. */
  41124. static CreateSphere(name: string, options: {
  41125. segments?: number;
  41126. diameter?: number;
  41127. diameterX?: number;
  41128. diameterY?: number;
  41129. diameterZ?: number;
  41130. arc?: number;
  41131. slice?: number;
  41132. sideOrientation?: number;
  41133. frontUVs?: Vector4;
  41134. backUVs?: Vector4;
  41135. updatable?: boolean;
  41136. }, scene: any): Mesh;
  41137. }
  41138. }
  41139. declare module BABYLON.Debug {
  41140. /**
  41141. * Used to show the physics impostor around the specific mesh
  41142. */
  41143. export class PhysicsViewer {
  41144. /** @hidden */
  41145. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41146. /** @hidden */
  41147. protected _meshes: Array<Nullable<AbstractMesh>>;
  41148. /** @hidden */
  41149. protected _scene: Nullable<Scene>;
  41150. /** @hidden */
  41151. protected _numMeshes: number;
  41152. /** @hidden */
  41153. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41154. private _renderFunction;
  41155. private _utilityLayer;
  41156. private _debugBoxMesh;
  41157. private _debugSphereMesh;
  41158. private _debugCylinderMesh;
  41159. private _debugMaterial;
  41160. private _debugMeshMeshes;
  41161. /**
  41162. * Creates a new PhysicsViewer
  41163. * @param scene defines the hosting scene
  41164. */
  41165. constructor(scene: Scene);
  41166. /** @hidden */
  41167. protected _updateDebugMeshes(): void;
  41168. /**
  41169. * Renders a specified physic impostor
  41170. * @param impostor defines the impostor to render
  41171. * @param targetMesh defines the mesh represented by the impostor
  41172. * @returns the new debug mesh used to render the impostor
  41173. */
  41174. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41175. /**
  41176. * Hides a specified physic impostor
  41177. * @param impostor defines the impostor to hide
  41178. */
  41179. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41180. private _getDebugMaterial;
  41181. private _getDebugBoxMesh;
  41182. private _getDebugSphereMesh;
  41183. private _getDebugCylinderMesh;
  41184. private _getDebugMeshMesh;
  41185. private _getDebugMesh;
  41186. /** Releases all resources */
  41187. dispose(): void;
  41188. }
  41189. }
  41190. declare module BABYLON {
  41191. /**
  41192. * Class containing static functions to help procedurally build meshes
  41193. */
  41194. export class LinesBuilder {
  41195. /**
  41196. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41197. * * 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
  41198. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41199. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41200. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41201. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41202. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41203. * * 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
  41204. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41206. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41207. * @param name defines the name of the new line system
  41208. * @param options defines the options used to create the line system
  41209. * @param scene defines the hosting scene
  41210. * @returns a new line system mesh
  41211. */
  41212. static CreateLineSystem(name: string, options: {
  41213. lines: Vector3[][];
  41214. updatable?: boolean;
  41215. instance?: Nullable<LinesMesh>;
  41216. colors?: Nullable<Color4[][]>;
  41217. useVertexAlpha?: boolean;
  41218. }, scene: Nullable<Scene>): LinesMesh;
  41219. /**
  41220. * Creates a line mesh
  41221. * 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
  41222. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41223. * * The parameter `points` is an array successive Vector3
  41224. * * 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
  41225. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41226. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41227. * * When updating an instance, remember that only point positions can change, not the number of points
  41228. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41229. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41230. * @param name defines the name of the new line system
  41231. * @param options defines the options used to create the line system
  41232. * @param scene defines the hosting scene
  41233. * @returns a new line mesh
  41234. */
  41235. static CreateLines(name: string, options: {
  41236. points: Vector3[];
  41237. updatable?: boolean;
  41238. instance?: Nullable<LinesMesh>;
  41239. colors?: Color4[];
  41240. useVertexAlpha?: boolean;
  41241. }, scene?: Nullable<Scene>): LinesMesh;
  41242. /**
  41243. * Creates a dashed line mesh
  41244. * * 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
  41245. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41246. * * The parameter `points` is an array successive Vector3
  41247. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41248. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41249. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41250. * * 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
  41251. * * When updating an instance, remember that only point positions can change, not the number of points
  41252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41253. * @param name defines the name of the mesh
  41254. * @param options defines the options used to create the mesh
  41255. * @param scene defines the hosting scene
  41256. * @returns the dashed line mesh
  41257. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41258. */
  41259. static CreateDashedLines(name: string, options: {
  41260. points: Vector3[];
  41261. dashSize?: number;
  41262. gapSize?: number;
  41263. dashNb?: number;
  41264. updatable?: boolean;
  41265. instance?: LinesMesh;
  41266. }, scene?: Nullable<Scene>): LinesMesh;
  41267. }
  41268. }
  41269. declare module BABYLON {
  41270. /**
  41271. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41272. * in order to better appreciate the issue one might have.
  41273. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41274. */
  41275. export class RayHelper {
  41276. /**
  41277. * Defines the ray we are currently tryin to visualize.
  41278. */
  41279. ray: Nullable<Ray>;
  41280. private _renderPoints;
  41281. private _renderLine;
  41282. private _renderFunction;
  41283. private _scene;
  41284. private _updateToMeshFunction;
  41285. private _attachedToMesh;
  41286. private _meshSpaceDirection;
  41287. private _meshSpaceOrigin;
  41288. /**
  41289. * Helper function to create a colored helper in a scene in one line.
  41290. * @param ray Defines the ray we are currently tryin to visualize
  41291. * @param scene Defines the scene the ray is used in
  41292. * @param color Defines the color we want to see the ray in
  41293. * @returns The newly created ray helper.
  41294. */
  41295. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41296. /**
  41297. * Instantiate a new ray helper.
  41298. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41299. * in order to better appreciate the issue one might have.
  41300. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41301. * @param ray Defines the ray we are currently tryin to visualize
  41302. */
  41303. constructor(ray: Ray);
  41304. /**
  41305. * Shows the ray we are willing to debug.
  41306. * @param scene Defines the scene the ray needs to be rendered in
  41307. * @param color Defines the color the ray needs to be rendered in
  41308. */
  41309. show(scene: Scene, color?: Color3): void;
  41310. /**
  41311. * Hides the ray we are debugging.
  41312. */
  41313. hide(): void;
  41314. private _render;
  41315. /**
  41316. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41317. * @param mesh Defines the mesh we want the helper attached to
  41318. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41319. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41320. * @param length Defines the length of the ray
  41321. */
  41322. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41323. /**
  41324. * Detach the ray helper from the mesh it has previously been attached to.
  41325. */
  41326. detachFromMesh(): void;
  41327. private _updateToMesh;
  41328. /**
  41329. * Dispose the helper and release its associated resources.
  41330. */
  41331. dispose(): void;
  41332. }
  41333. }
  41334. declare module BABYLON.Debug {
  41335. /**
  41336. * Class used to render a debug view of a given skeleton
  41337. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41338. */
  41339. export class SkeletonViewer {
  41340. /** defines the skeleton to render */
  41341. skeleton: Skeleton;
  41342. /** defines the mesh attached to the skeleton */
  41343. mesh: AbstractMesh;
  41344. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41345. autoUpdateBonesMatrices: boolean;
  41346. /** defines the rendering group id to use with the viewer */
  41347. renderingGroupId: number;
  41348. /** Gets or sets the color used to render the skeleton */
  41349. color: Color3;
  41350. private _scene;
  41351. private _debugLines;
  41352. private _debugMesh;
  41353. private _isEnabled;
  41354. private _renderFunction;
  41355. private _utilityLayer;
  41356. /**
  41357. * Returns the mesh used to render the bones
  41358. */
  41359. readonly debugMesh: Nullable<LinesMesh>;
  41360. /**
  41361. * Creates a new SkeletonViewer
  41362. * @param skeleton defines the skeleton to render
  41363. * @param mesh defines the mesh attached to the skeleton
  41364. * @param scene defines the hosting scene
  41365. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41366. * @param renderingGroupId defines the rendering group id to use with the viewer
  41367. */
  41368. constructor(
  41369. /** defines the skeleton to render */
  41370. skeleton: Skeleton,
  41371. /** defines the mesh attached to the skeleton */
  41372. mesh: AbstractMesh, scene: Scene,
  41373. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41374. autoUpdateBonesMatrices?: boolean,
  41375. /** defines the rendering group id to use with the viewer */
  41376. renderingGroupId?: number);
  41377. /** Gets or sets a boolean indicating if the viewer is enabled */
  41378. isEnabled: boolean;
  41379. private _getBonePosition;
  41380. private _getLinesForBonesWithLength;
  41381. private _getLinesForBonesNoLength;
  41382. /** Update the viewer to sync with current skeleton state */
  41383. update(): void;
  41384. /** Release associated resources */
  41385. dispose(): void;
  41386. }
  41387. }
  41388. declare module BABYLON {
  41389. /**
  41390. * Options to create the null engine
  41391. */
  41392. export class NullEngineOptions {
  41393. /**
  41394. * Render width (Default: 512)
  41395. */
  41396. renderWidth: number;
  41397. /**
  41398. * Render height (Default: 256)
  41399. */
  41400. renderHeight: number;
  41401. /**
  41402. * Texture size (Default: 512)
  41403. */
  41404. textureSize: number;
  41405. /**
  41406. * If delta time between frames should be constant
  41407. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41408. */
  41409. deterministicLockstep: boolean;
  41410. /**
  41411. * Maximum about of steps between frames (Default: 4)
  41412. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41413. */
  41414. lockstepMaxSteps: number;
  41415. }
  41416. /**
  41417. * The null engine class provides support for headless version of babylon.js.
  41418. * This can be used in server side scenario or for testing purposes
  41419. */
  41420. export class NullEngine extends Engine {
  41421. private _options;
  41422. /**
  41423. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41424. */
  41425. isDeterministicLockStep(): boolean;
  41426. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41427. getLockstepMaxSteps(): number;
  41428. /**
  41429. * Sets hardware scaling, used to save performance if needed
  41430. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41431. */
  41432. getHardwareScalingLevel(): number;
  41433. constructor(options?: NullEngineOptions);
  41434. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41435. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41436. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41437. getRenderWidth(useScreen?: boolean): number;
  41438. getRenderHeight(useScreen?: boolean): number;
  41439. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41440. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41441. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41442. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41443. bindSamplers(effect: Effect): void;
  41444. enableEffect(effect: Effect): void;
  41445. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41446. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41447. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41448. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41449. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41450. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41451. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41452. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41453. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41454. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41455. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41456. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41457. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41458. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41459. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41460. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41461. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41462. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41463. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41464. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41465. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41466. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41467. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41468. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41469. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41470. bindBuffers(vertexBuffers: {
  41471. [key: string]: VertexBuffer;
  41472. }, indexBuffer: DataBuffer, effect: Effect): void;
  41473. wipeCaches(bruteForce?: boolean): void;
  41474. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41475. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41476. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41477. /** @hidden */
  41478. _createTexture(): WebGLTexture;
  41479. /** @hidden */
  41480. _releaseTexture(texture: InternalTexture): void;
  41481. 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;
  41482. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41483. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41484. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41485. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41486. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  41487. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41488. areAllEffectsReady(): boolean;
  41489. /**
  41490. * @hidden
  41491. * Get the current error code of the webGL context
  41492. * @returns the error code
  41493. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41494. */
  41495. getError(): number;
  41496. /** @hidden */
  41497. _getUnpackAlignement(): number;
  41498. /** @hidden */
  41499. _unpackFlipY(value: boolean): void;
  41500. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41501. /**
  41502. * Updates a dynamic vertex buffer.
  41503. * @param vertexBuffer the vertex buffer to update
  41504. * @param data the data used to update the vertex buffer
  41505. * @param byteOffset the byte offset of the data (optional)
  41506. * @param byteLength the byte length of the data (optional)
  41507. */
  41508. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41509. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41510. /** @hidden */
  41511. _bindTexture(channel: number, texture: InternalTexture): void;
  41512. /** @hidden */
  41513. _releaseBuffer(buffer: DataBuffer): boolean;
  41514. releaseEffects(): void;
  41515. displayLoadingUI(): void;
  41516. hideLoadingUI(): void;
  41517. /** @hidden */
  41518. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41519. /** @hidden */
  41520. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41521. /** @hidden */
  41522. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41523. /** @hidden */
  41524. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41525. }
  41526. }
  41527. declare module BABYLON {
  41528. /** @hidden */
  41529. export class _OcclusionDataStorage {
  41530. /** @hidden */
  41531. occlusionInternalRetryCounter: number;
  41532. /** @hidden */
  41533. isOcclusionQueryInProgress: boolean;
  41534. /** @hidden */
  41535. isOccluded: boolean;
  41536. /** @hidden */
  41537. occlusionRetryCount: number;
  41538. /** @hidden */
  41539. occlusionType: number;
  41540. /** @hidden */
  41541. occlusionQueryAlgorithmType: number;
  41542. }
  41543. interface Engine {
  41544. /**
  41545. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41546. * @return the new query
  41547. */
  41548. createQuery(): WebGLQuery;
  41549. /**
  41550. * Delete and release a webGL query
  41551. * @param query defines the query to delete
  41552. * @return the current engine
  41553. */
  41554. deleteQuery(query: WebGLQuery): Engine;
  41555. /**
  41556. * Check if a given query has resolved and got its value
  41557. * @param query defines the query to check
  41558. * @returns true if the query got its value
  41559. */
  41560. isQueryResultAvailable(query: WebGLQuery): boolean;
  41561. /**
  41562. * Gets the value of a given query
  41563. * @param query defines the query to check
  41564. * @returns the value of the query
  41565. */
  41566. getQueryResult(query: WebGLQuery): number;
  41567. /**
  41568. * Initiates an occlusion query
  41569. * @param algorithmType defines the algorithm to use
  41570. * @param query defines the query to use
  41571. * @returns the current engine
  41572. * @see http://doc.babylonjs.com/features/occlusionquery
  41573. */
  41574. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41575. /**
  41576. * Ends an occlusion query
  41577. * @see http://doc.babylonjs.com/features/occlusionquery
  41578. * @param algorithmType defines the algorithm to use
  41579. * @returns the current engine
  41580. */
  41581. endOcclusionQuery(algorithmType: number): Engine;
  41582. /**
  41583. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41584. * Please note that only one query can be issued at a time
  41585. * @returns a time token used to track the time span
  41586. */
  41587. startTimeQuery(): Nullable<_TimeToken>;
  41588. /**
  41589. * Ends a time query
  41590. * @param token defines the token used to measure the time span
  41591. * @returns the time spent (in ns)
  41592. */
  41593. endTimeQuery(token: _TimeToken): int;
  41594. /** @hidden */
  41595. _currentNonTimestampToken: Nullable<_TimeToken>;
  41596. /** @hidden */
  41597. _createTimeQuery(): WebGLQuery;
  41598. /** @hidden */
  41599. _deleteTimeQuery(query: WebGLQuery): void;
  41600. /** @hidden */
  41601. _getGlAlgorithmType(algorithmType: number): number;
  41602. /** @hidden */
  41603. _getTimeQueryResult(query: WebGLQuery): any;
  41604. /** @hidden */
  41605. _getTimeQueryAvailability(query: WebGLQuery): any;
  41606. }
  41607. interface AbstractMesh {
  41608. /**
  41609. * Backing filed
  41610. * @hidden
  41611. */
  41612. __occlusionDataStorage: _OcclusionDataStorage;
  41613. /**
  41614. * Access property
  41615. * @hidden
  41616. */
  41617. _occlusionDataStorage: _OcclusionDataStorage;
  41618. /**
  41619. * 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.
  41620. * The default value is -1 which means don't break the query and wait till the result
  41621. * @see http://doc.babylonjs.com/features/occlusionquery
  41622. */
  41623. occlusionRetryCount: number;
  41624. /**
  41625. * 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:
  41626. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41627. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41628. * * 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.
  41629. * @see http://doc.babylonjs.com/features/occlusionquery
  41630. */
  41631. occlusionType: number;
  41632. /**
  41633. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41634. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41635. * * 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.
  41636. * @see http://doc.babylonjs.com/features/occlusionquery
  41637. */
  41638. occlusionQueryAlgorithmType: number;
  41639. /**
  41640. * 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
  41641. * @see http://doc.babylonjs.com/features/occlusionquery
  41642. */
  41643. isOccluded: boolean;
  41644. /**
  41645. * Flag to check the progress status of the query
  41646. * @see http://doc.babylonjs.com/features/occlusionquery
  41647. */
  41648. isOcclusionQueryInProgress: boolean;
  41649. }
  41650. }
  41651. declare module BABYLON {
  41652. /** @hidden */
  41653. export var _forceTransformFeedbackToBundle: boolean;
  41654. interface Engine {
  41655. /**
  41656. * Creates a webGL transform feedback object
  41657. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41658. * @returns the webGL transform feedback object
  41659. */
  41660. createTransformFeedback(): WebGLTransformFeedback;
  41661. /**
  41662. * Delete a webGL transform feedback object
  41663. * @param value defines the webGL transform feedback object to delete
  41664. */
  41665. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41666. /**
  41667. * Bind a webGL transform feedback object to the webgl context
  41668. * @param value defines the webGL transform feedback object to bind
  41669. */
  41670. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41671. /**
  41672. * Begins a transform feedback operation
  41673. * @param usePoints defines if points or triangles must be used
  41674. */
  41675. beginTransformFeedback(usePoints: boolean): void;
  41676. /**
  41677. * Ends a transform feedback operation
  41678. */
  41679. endTransformFeedback(): void;
  41680. /**
  41681. * Specify the varyings to use with transform feedback
  41682. * @param program defines the associated webGL program
  41683. * @param value defines the list of strings representing the varying names
  41684. */
  41685. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41686. /**
  41687. * Bind a webGL buffer for a transform feedback operation
  41688. * @param value defines the webGL buffer to bind
  41689. */
  41690. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  41691. }
  41692. }
  41693. declare module BABYLON {
  41694. /**
  41695. * Creation options of the multi render target texture.
  41696. */
  41697. export interface IMultiRenderTargetOptions {
  41698. /**
  41699. * Define if the texture needs to create mip maps after render.
  41700. */
  41701. generateMipMaps?: boolean;
  41702. /**
  41703. * Define the types of all the draw buffers we want to create
  41704. */
  41705. types?: number[];
  41706. /**
  41707. * Define the sampling modes of all the draw buffers we want to create
  41708. */
  41709. samplingModes?: number[];
  41710. /**
  41711. * Define if a depth buffer is required
  41712. */
  41713. generateDepthBuffer?: boolean;
  41714. /**
  41715. * Define if a stencil buffer is required
  41716. */
  41717. generateStencilBuffer?: boolean;
  41718. /**
  41719. * Define if a depth texture is required instead of a depth buffer
  41720. */
  41721. generateDepthTexture?: boolean;
  41722. /**
  41723. * Define the number of desired draw buffers
  41724. */
  41725. textureCount?: number;
  41726. /**
  41727. * Define if aspect ratio should be adapted to the texture or stay the scene one
  41728. */
  41729. doNotChangeAspectRatio?: boolean;
  41730. /**
  41731. * Define the default type of the buffers we are creating
  41732. */
  41733. defaultType?: number;
  41734. }
  41735. /**
  41736. * A multi render target, like a render target provides the ability to render to a texture.
  41737. * Unlike the render target, it can render to several draw buffers in one draw.
  41738. * This is specially interesting in deferred rendering or for any effects requiring more than
  41739. * just one color from a single pass.
  41740. */
  41741. export class MultiRenderTarget extends RenderTargetTexture {
  41742. private _internalTextures;
  41743. private _textures;
  41744. private _multiRenderTargetOptions;
  41745. /**
  41746. * Get if draw buffers are currently supported by the used hardware and browser.
  41747. */
  41748. readonly isSupported: boolean;
  41749. /**
  41750. * Get the list of textures generated by the multi render target.
  41751. */
  41752. readonly textures: Texture[];
  41753. /**
  41754. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  41755. */
  41756. readonly depthTexture: Texture;
  41757. /**
  41758. * Set the wrapping mode on U of all the textures we are rendering to.
  41759. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41760. */
  41761. wrapU: number;
  41762. /**
  41763. * Set the wrapping mode on V of all the textures we are rendering to.
  41764. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41765. */
  41766. wrapV: number;
  41767. /**
  41768. * Instantiate a new multi render target texture.
  41769. * A multi render target, like a render target provides the ability to render to a texture.
  41770. * Unlike the render target, it can render to several draw buffers in one draw.
  41771. * This is specially interesting in deferred rendering or for any effects requiring more than
  41772. * just one color from a single pass.
  41773. * @param name Define the name of the texture
  41774. * @param size Define the size of the buffers to render to
  41775. * @param count Define the number of target we are rendering into
  41776. * @param scene Define the scene the texture belongs to
  41777. * @param options Define the options used to create the multi render target
  41778. */
  41779. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  41780. /** @hidden */
  41781. _rebuild(): void;
  41782. private _createInternalTextures;
  41783. private _createTextures;
  41784. /**
  41785. * Define the number of samples used if MSAA is enabled.
  41786. */
  41787. samples: number;
  41788. /**
  41789. * Resize all the textures in the multi render target.
  41790. * Be carrefull as it will recreate all the data in the new texture.
  41791. * @param size Define the new size
  41792. */
  41793. resize(size: any): void;
  41794. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41795. /**
  41796. * Dispose the render targets and their associated resources
  41797. */
  41798. dispose(): void;
  41799. /**
  41800. * Release all the underlying texture used as draw buffers.
  41801. */
  41802. releaseInternalTextures(): void;
  41803. }
  41804. }
  41805. declare module BABYLON {
  41806. interface Engine {
  41807. /**
  41808. * Unbind a list of render target textures from the webGL context
  41809. * This is used only when drawBuffer extension or webGL2 are active
  41810. * @param textures defines the render target textures to unbind
  41811. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41812. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41813. */
  41814. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41815. /**
  41816. * Create a multi render target texture
  41817. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41818. * @param size defines the size of the texture
  41819. * @param options defines the creation options
  41820. * @returns the cube texture as an InternalTexture
  41821. */
  41822. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41823. /**
  41824. * Update the sample count for a given multiple render target texture
  41825. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41826. * @param textures defines the textures to update
  41827. * @param samples defines the sample count to set
  41828. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41829. */
  41830. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41831. }
  41832. }
  41833. declare module BABYLON {
  41834. /**
  41835. * Gather the list of clipboard event types as constants.
  41836. */
  41837. export class ClipboardEventTypes {
  41838. /**
  41839. * The clipboard event is fired when a copy command is active (pressed).
  41840. */
  41841. static readonly COPY: number;
  41842. /**
  41843. * The clipboard event is fired when a cut command is active (pressed).
  41844. */
  41845. static readonly CUT: number;
  41846. /**
  41847. * The clipboard event is fired when a paste command is active (pressed).
  41848. */
  41849. static readonly PASTE: number;
  41850. }
  41851. /**
  41852. * This class is used to store clipboard related info for the onClipboardObservable event.
  41853. */
  41854. export class ClipboardInfo {
  41855. /**
  41856. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41857. */
  41858. type: number;
  41859. /**
  41860. * Defines the related dom event
  41861. */
  41862. event: ClipboardEvent;
  41863. /**
  41864. *Creates an instance of ClipboardInfo.
  41865. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41866. * @param event Defines the related dom event
  41867. */
  41868. constructor(
  41869. /**
  41870. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41871. */
  41872. type: number,
  41873. /**
  41874. * Defines the related dom event
  41875. */
  41876. event: ClipboardEvent);
  41877. /**
  41878. * Get the clipboard event's type from the keycode.
  41879. * @param keyCode Defines the keyCode for the current keyboard event.
  41880. * @return {number}
  41881. */
  41882. static GetTypeFromCharacter(keyCode: number): number;
  41883. }
  41884. }
  41885. declare module BABYLON {
  41886. /**
  41887. * Class used to represent data loading progression
  41888. */
  41889. export class SceneLoaderProgressEvent {
  41890. /** defines if data length to load can be evaluated */
  41891. readonly lengthComputable: boolean;
  41892. /** defines the loaded data length */
  41893. readonly loaded: number;
  41894. /** defines the data length to load */
  41895. readonly total: number;
  41896. /**
  41897. * Create a new progress event
  41898. * @param lengthComputable defines if data length to load can be evaluated
  41899. * @param loaded defines the loaded data length
  41900. * @param total defines the data length to load
  41901. */
  41902. constructor(
  41903. /** defines if data length to load can be evaluated */
  41904. lengthComputable: boolean,
  41905. /** defines the loaded data length */
  41906. loaded: number,
  41907. /** defines the data length to load */
  41908. total: number);
  41909. /**
  41910. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41911. * @param event defines the source event
  41912. * @returns a new SceneLoaderProgressEvent
  41913. */
  41914. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41915. }
  41916. /**
  41917. * Interface used by SceneLoader plugins to define supported file extensions
  41918. */
  41919. export interface ISceneLoaderPluginExtensions {
  41920. /**
  41921. * Defines the list of supported extensions
  41922. */
  41923. [extension: string]: {
  41924. isBinary: boolean;
  41925. };
  41926. }
  41927. /**
  41928. * Interface used by SceneLoader plugin factory
  41929. */
  41930. export interface ISceneLoaderPluginFactory {
  41931. /**
  41932. * Defines the name of the factory
  41933. */
  41934. name: string;
  41935. /**
  41936. * Function called to create a new plugin
  41937. * @return the new plugin
  41938. */
  41939. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41940. /**
  41941. * Boolean indicating if the plugin can direct load specific data
  41942. */
  41943. canDirectLoad?: (data: string) => boolean;
  41944. }
  41945. /**
  41946. * Interface used to define a SceneLoader plugin
  41947. */
  41948. export interface ISceneLoaderPlugin {
  41949. /**
  41950. * The friendly name of this plugin.
  41951. */
  41952. name: string;
  41953. /**
  41954. * The file extensions supported by this plugin.
  41955. */
  41956. extensions: string | ISceneLoaderPluginExtensions;
  41957. /**
  41958. * Import meshes into a scene.
  41959. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41960. * @param scene The scene to import into
  41961. * @param data The data to import
  41962. * @param rootUrl The root url for scene and resources
  41963. * @param meshes The meshes array to import into
  41964. * @param particleSystems The particle systems array to import into
  41965. * @param skeletons The skeletons array to import into
  41966. * @param onError The callback when import fails
  41967. * @returns True if successful or false otherwise
  41968. */
  41969. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41970. /**
  41971. * Load into a scene.
  41972. * @param scene The scene to load into
  41973. * @param data The data to import
  41974. * @param rootUrl The root url for scene and resources
  41975. * @param onError The callback when import fails
  41976. * @returns true if successful or false otherwise
  41977. */
  41978. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41979. /**
  41980. * The callback that returns true if the data can be directly loaded.
  41981. */
  41982. canDirectLoad?: (data: string) => boolean;
  41983. /**
  41984. * The callback that allows custom handling of the root url based on the response url.
  41985. */
  41986. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41987. /**
  41988. * Load into an asset container.
  41989. * @param scene The scene to load into
  41990. * @param data The data to import
  41991. * @param rootUrl The root url for scene and resources
  41992. * @param onError The callback when import fails
  41993. * @returns The loaded asset container
  41994. */
  41995. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41996. }
  41997. /**
  41998. * Interface used to define an async SceneLoader plugin
  41999. */
  42000. export interface ISceneLoaderPluginAsync {
  42001. /**
  42002. * The friendly name of this plugin.
  42003. */
  42004. name: string;
  42005. /**
  42006. * The file extensions supported by this plugin.
  42007. */
  42008. extensions: string | ISceneLoaderPluginExtensions;
  42009. /**
  42010. * Import meshes into a scene.
  42011. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42012. * @param scene The scene to import into
  42013. * @param data The data to import
  42014. * @param rootUrl The root url for scene and resources
  42015. * @param onProgress The callback when the load progresses
  42016. * @param fileName Defines the name of the file to load
  42017. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42018. */
  42019. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42020. meshes: AbstractMesh[];
  42021. particleSystems: IParticleSystem[];
  42022. skeletons: Skeleton[];
  42023. animationGroups: AnimationGroup[];
  42024. }>;
  42025. /**
  42026. * Load into a scene.
  42027. * @param scene The scene to load into
  42028. * @param data The data to import
  42029. * @param rootUrl The root url for scene and resources
  42030. * @param onProgress The callback when the load progresses
  42031. * @param fileName Defines the name of the file to load
  42032. * @returns Nothing
  42033. */
  42034. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42035. /**
  42036. * The callback that returns true if the data can be directly loaded.
  42037. */
  42038. canDirectLoad?: (data: string) => boolean;
  42039. /**
  42040. * The callback that allows custom handling of the root url based on the response url.
  42041. */
  42042. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42043. /**
  42044. * Load into an asset container.
  42045. * @param scene The scene to load into
  42046. * @param data The data to import
  42047. * @param rootUrl The root url for scene and resources
  42048. * @param onProgress The callback when the load progresses
  42049. * @param fileName Defines the name of the file to load
  42050. * @returns The loaded asset container
  42051. */
  42052. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42053. }
  42054. /**
  42055. * Class used to load scene from various file formats using registered plugins
  42056. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42057. */
  42058. export class SceneLoader {
  42059. /**
  42060. * No logging while loading
  42061. */
  42062. static readonly NO_LOGGING: number;
  42063. /**
  42064. * Minimal logging while loading
  42065. */
  42066. static readonly MINIMAL_LOGGING: number;
  42067. /**
  42068. * Summary logging while loading
  42069. */
  42070. static readonly SUMMARY_LOGGING: number;
  42071. /**
  42072. * Detailled logging while loading
  42073. */
  42074. static readonly DETAILED_LOGGING: number;
  42075. /**
  42076. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42077. */
  42078. static ForceFullSceneLoadingForIncremental: boolean;
  42079. /**
  42080. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42081. */
  42082. static ShowLoadingScreen: boolean;
  42083. /**
  42084. * Defines the current logging level (while loading the scene)
  42085. * @ignorenaming
  42086. */
  42087. static loggingLevel: number;
  42088. /**
  42089. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42090. */
  42091. static CleanBoneMatrixWeights: boolean;
  42092. /**
  42093. * Event raised when a plugin is used to load a scene
  42094. */
  42095. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42096. private static _registeredPlugins;
  42097. private static _getDefaultPlugin;
  42098. private static _getPluginForExtension;
  42099. private static _getPluginForDirectLoad;
  42100. private static _getPluginForFilename;
  42101. private static _getDirectLoad;
  42102. private static _loadData;
  42103. private static _getFileInfo;
  42104. /**
  42105. * Gets a plugin that can load the given extension
  42106. * @param extension defines the extension to load
  42107. * @returns a plugin or null if none works
  42108. */
  42109. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42110. /**
  42111. * Gets a boolean indicating that the given extension can be loaded
  42112. * @param extension defines the extension to load
  42113. * @returns true if the extension is supported
  42114. */
  42115. static IsPluginForExtensionAvailable(extension: string): boolean;
  42116. /**
  42117. * Adds a new plugin to the list of registered plugins
  42118. * @param plugin defines the plugin to add
  42119. */
  42120. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42121. /**
  42122. * Import meshes into a scene
  42123. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42124. * @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)
  42125. * @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)
  42126. * @param scene the instance of BABYLON.Scene to append to
  42127. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42128. * @param onProgress a callback with a progress event for each file being loaded
  42129. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42130. * @param pluginExtension the extension used to determine the plugin
  42131. * @returns The loaded plugin
  42132. */
  42133. 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>;
  42134. /**
  42135. * Import meshes into a scene
  42136. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42137. * @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)
  42138. * @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)
  42139. * @param scene the instance of BABYLON.Scene to append to
  42140. * @param onProgress a callback with a progress event for each file being loaded
  42141. * @param pluginExtension the extension used to determine the plugin
  42142. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42143. */
  42144. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42145. meshes: AbstractMesh[];
  42146. particleSystems: IParticleSystem[];
  42147. skeletons: Skeleton[];
  42148. animationGroups: AnimationGroup[];
  42149. }>;
  42150. /**
  42151. * Load a scene
  42152. * @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)
  42153. * @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)
  42154. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42155. * @param onSuccess a callback with the scene when import succeeds
  42156. * @param onProgress a callback with a progress event for each file being loaded
  42157. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42158. * @param pluginExtension the extension used to determine the plugin
  42159. * @returns The loaded plugin
  42160. */
  42161. 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>;
  42162. /**
  42163. * Load a scene
  42164. * @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)
  42165. * @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)
  42166. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42167. * @param onProgress a callback with a progress event for each file being loaded
  42168. * @param pluginExtension the extension used to determine the plugin
  42169. * @returns The loaded scene
  42170. */
  42171. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42172. /**
  42173. * Append a scene
  42174. * @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)
  42175. * @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)
  42176. * @param scene is the instance of BABYLON.Scene to append to
  42177. * @param onSuccess a callback with the scene when import succeeds
  42178. * @param onProgress a callback with a progress event for each file being loaded
  42179. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42180. * @param pluginExtension the extension used to determine the plugin
  42181. * @returns The loaded plugin
  42182. */
  42183. 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>;
  42184. /**
  42185. * Append a scene
  42186. * @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)
  42187. * @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)
  42188. * @param scene is the instance of BABYLON.Scene to append to
  42189. * @param onProgress a callback with a progress event for each file being loaded
  42190. * @param pluginExtension the extension used to determine the plugin
  42191. * @returns The given scene
  42192. */
  42193. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42194. /**
  42195. * Load a scene into an asset container
  42196. * @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)
  42197. * @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)
  42198. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42199. * @param onSuccess a callback with the scene when import succeeds
  42200. * @param onProgress a callback with a progress event for each file being loaded
  42201. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42202. * @param pluginExtension the extension used to determine the plugin
  42203. * @returns The loaded plugin
  42204. */
  42205. 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>;
  42206. /**
  42207. * Load a scene into an asset container
  42208. * @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)
  42209. * @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)
  42210. * @param scene is the instance of Scene to append to
  42211. * @param onProgress a callback with a progress event for each file being loaded
  42212. * @param pluginExtension the extension used to determine the plugin
  42213. * @returns The loaded asset container
  42214. */
  42215. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42216. }
  42217. }
  42218. declare module BABYLON {
  42219. /**
  42220. * Google Daydream controller
  42221. */
  42222. export class DaydreamController extends WebVRController {
  42223. /**
  42224. * Base Url for the controller model.
  42225. */
  42226. static MODEL_BASE_URL: string;
  42227. /**
  42228. * File name for the controller model.
  42229. */
  42230. static MODEL_FILENAME: string;
  42231. /**
  42232. * Gamepad Id prefix used to identify Daydream Controller.
  42233. */
  42234. static readonly GAMEPAD_ID_PREFIX: string;
  42235. /**
  42236. * Creates a new DaydreamController from a gamepad
  42237. * @param vrGamepad the gamepad that the controller should be created from
  42238. */
  42239. constructor(vrGamepad: any);
  42240. /**
  42241. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42242. * @param scene scene in which to add meshes
  42243. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42244. */
  42245. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42246. /**
  42247. * Called once for each button that changed state since the last frame
  42248. * @param buttonIdx Which button index changed
  42249. * @param state New state of the button
  42250. * @param changes Which properties on the state changed since last frame
  42251. */
  42252. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42253. }
  42254. }
  42255. declare module BABYLON {
  42256. /**
  42257. * Gear VR Controller
  42258. */
  42259. export class GearVRController extends WebVRController {
  42260. /**
  42261. * Base Url for the controller model.
  42262. */
  42263. static MODEL_BASE_URL: string;
  42264. /**
  42265. * File name for the controller model.
  42266. */
  42267. static MODEL_FILENAME: string;
  42268. /**
  42269. * Gamepad Id prefix used to identify this controller.
  42270. */
  42271. static readonly GAMEPAD_ID_PREFIX: string;
  42272. private readonly _buttonIndexToObservableNameMap;
  42273. /**
  42274. * Creates a new GearVRController from a gamepad
  42275. * @param vrGamepad the gamepad that the controller should be created from
  42276. */
  42277. constructor(vrGamepad: any);
  42278. /**
  42279. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42280. * @param scene scene in which to add meshes
  42281. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42282. */
  42283. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42284. /**
  42285. * Called once for each button that changed state since the last frame
  42286. * @param buttonIdx Which button index changed
  42287. * @param state New state of the button
  42288. * @param changes Which properties on the state changed since last frame
  42289. */
  42290. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42291. }
  42292. }
  42293. declare module BABYLON {
  42294. /**
  42295. * Generic Controller
  42296. */
  42297. export class GenericController extends WebVRController {
  42298. /**
  42299. * Base Url for the controller model.
  42300. */
  42301. static readonly MODEL_BASE_URL: string;
  42302. /**
  42303. * File name for the controller model.
  42304. */
  42305. static readonly MODEL_FILENAME: string;
  42306. /**
  42307. * Creates a new GenericController from a gamepad
  42308. * @param vrGamepad the gamepad that the controller should be created from
  42309. */
  42310. constructor(vrGamepad: any);
  42311. /**
  42312. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42313. * @param scene scene in which to add meshes
  42314. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42315. */
  42316. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42317. /**
  42318. * Called once for each button that changed state since the last frame
  42319. * @param buttonIdx Which button index changed
  42320. * @param state New state of the button
  42321. * @param changes Which properties on the state changed since last frame
  42322. */
  42323. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42324. }
  42325. }
  42326. declare module BABYLON {
  42327. /**
  42328. * Oculus Touch Controller
  42329. */
  42330. export class OculusTouchController extends WebVRController {
  42331. /**
  42332. * Base Url for the controller model.
  42333. */
  42334. static MODEL_BASE_URL: string;
  42335. /**
  42336. * File name for the left controller model.
  42337. */
  42338. static MODEL_LEFT_FILENAME: string;
  42339. /**
  42340. * File name for the right controller model.
  42341. */
  42342. static MODEL_RIGHT_FILENAME: string;
  42343. /**
  42344. * Fired when the secondary trigger on this controller is modified
  42345. */
  42346. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42347. /**
  42348. * Fired when the thumb rest on this controller is modified
  42349. */
  42350. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42351. /**
  42352. * Creates a new OculusTouchController from a gamepad
  42353. * @param vrGamepad the gamepad that the controller should be created from
  42354. */
  42355. constructor(vrGamepad: any);
  42356. /**
  42357. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42358. * @param scene scene in which to add meshes
  42359. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42360. */
  42361. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42362. /**
  42363. * Fired when the A button on this controller is modified
  42364. */
  42365. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42366. /**
  42367. * Fired when the B button on this controller is modified
  42368. */
  42369. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42370. /**
  42371. * Fired when the X button on this controller is modified
  42372. */
  42373. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42374. /**
  42375. * Fired when the Y button on this controller is modified
  42376. */
  42377. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42378. /**
  42379. * Called once for each button that changed state since the last frame
  42380. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42381. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42382. * 2) secondary trigger (same)
  42383. * 3) A (right) X (left), touch, pressed = value
  42384. * 4) B / Y
  42385. * 5) thumb rest
  42386. * @param buttonIdx Which button index changed
  42387. * @param state New state of the button
  42388. * @param changes Which properties on the state changed since last frame
  42389. */
  42390. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42391. }
  42392. }
  42393. declare module BABYLON {
  42394. /**
  42395. * Vive Controller
  42396. */
  42397. export class ViveController extends WebVRController {
  42398. /**
  42399. * Base Url for the controller model.
  42400. */
  42401. static MODEL_BASE_URL: string;
  42402. /**
  42403. * File name for the controller model.
  42404. */
  42405. static MODEL_FILENAME: string;
  42406. /**
  42407. * Creates a new ViveController from a gamepad
  42408. * @param vrGamepad the gamepad that the controller should be created from
  42409. */
  42410. constructor(vrGamepad: any);
  42411. /**
  42412. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42413. * @param scene scene in which to add meshes
  42414. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42415. */
  42416. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42417. /**
  42418. * Fired when the left button on this controller is modified
  42419. */
  42420. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42421. /**
  42422. * Fired when the right button on this controller is modified
  42423. */
  42424. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42425. /**
  42426. * Fired when the menu button on this controller is modified
  42427. */
  42428. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42429. /**
  42430. * Called once for each button that changed state since the last frame
  42431. * Vive mapping:
  42432. * 0: touchpad
  42433. * 1: trigger
  42434. * 2: left AND right buttons
  42435. * 3: menu button
  42436. * @param buttonIdx Which button index changed
  42437. * @param state New state of the button
  42438. * @param changes Which properties on the state changed since last frame
  42439. */
  42440. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42441. }
  42442. }
  42443. declare module BABYLON {
  42444. /**
  42445. * Defines the WindowsMotionController object that the state of the windows motion controller
  42446. */
  42447. export class WindowsMotionController extends WebVRController {
  42448. /**
  42449. * The base url used to load the left and right controller models
  42450. */
  42451. static MODEL_BASE_URL: string;
  42452. /**
  42453. * The name of the left controller model file
  42454. */
  42455. static MODEL_LEFT_FILENAME: string;
  42456. /**
  42457. * The name of the right controller model file
  42458. */
  42459. static MODEL_RIGHT_FILENAME: string;
  42460. /**
  42461. * The controller name prefix for this controller type
  42462. */
  42463. static readonly GAMEPAD_ID_PREFIX: string;
  42464. /**
  42465. * The controller id pattern for this controller type
  42466. */
  42467. private static readonly GAMEPAD_ID_PATTERN;
  42468. private _loadedMeshInfo;
  42469. private readonly _mapping;
  42470. /**
  42471. * Fired when the trackpad on this controller is clicked
  42472. */
  42473. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42474. /**
  42475. * Fired when the trackpad on this controller is modified
  42476. */
  42477. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42478. /**
  42479. * The current x and y values of this controller's trackpad
  42480. */
  42481. trackpad: StickValues;
  42482. /**
  42483. * Creates a new WindowsMotionController from a gamepad
  42484. * @param vrGamepad the gamepad that the controller should be created from
  42485. */
  42486. constructor(vrGamepad: any);
  42487. /**
  42488. * Fired when the trigger on this controller is modified
  42489. */
  42490. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42491. /**
  42492. * Fired when the menu button on this controller is modified
  42493. */
  42494. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42495. /**
  42496. * Fired when the grip button on this controller is modified
  42497. */
  42498. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42499. /**
  42500. * Fired when the thumbstick button on this controller is modified
  42501. */
  42502. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42503. /**
  42504. * Fired when the touchpad button on this controller is modified
  42505. */
  42506. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42507. /**
  42508. * Fired when the touchpad values on this controller are modified
  42509. */
  42510. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42511. private _updateTrackpad;
  42512. /**
  42513. * Called once per frame by the engine.
  42514. */
  42515. update(): void;
  42516. /**
  42517. * Called once for each button that changed state since the last frame
  42518. * @param buttonIdx Which button index changed
  42519. * @param state New state of the button
  42520. * @param changes Which properties on the state changed since last frame
  42521. */
  42522. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42523. /**
  42524. * Moves the buttons on the controller mesh based on their current state
  42525. * @param buttonName the name of the button to move
  42526. * @param buttonValue the value of the button which determines the buttons new position
  42527. */
  42528. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42529. /**
  42530. * Moves the axis on the controller mesh based on its current state
  42531. * @param axis the index of the axis
  42532. * @param axisValue the value of the axis which determines the meshes new position
  42533. * @hidden
  42534. */
  42535. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42536. /**
  42537. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42538. * @param scene scene in which to add meshes
  42539. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42540. */
  42541. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42542. /**
  42543. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42544. * can be transformed by button presses and axes values, based on this._mapping.
  42545. *
  42546. * @param scene scene in which the meshes exist
  42547. * @param meshes list of meshes that make up the controller model to process
  42548. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42549. */
  42550. private processModel;
  42551. private createMeshInfo;
  42552. /**
  42553. * Gets the ray of the controller in the direction the controller is pointing
  42554. * @param length the length the resulting ray should be
  42555. * @returns a ray in the direction the controller is pointing
  42556. */
  42557. getForwardRay(length?: number): Ray;
  42558. /**
  42559. * Disposes of the controller
  42560. */
  42561. dispose(): void;
  42562. }
  42563. }
  42564. declare module BABYLON {
  42565. /**
  42566. * Single axis scale gizmo
  42567. */
  42568. export class AxisScaleGizmo extends Gizmo {
  42569. private _coloredMaterial;
  42570. /**
  42571. * Drag behavior responsible for the gizmos dragging interactions
  42572. */
  42573. dragBehavior: PointerDragBehavior;
  42574. private _pointerObserver;
  42575. /**
  42576. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42577. */
  42578. snapDistance: number;
  42579. /**
  42580. * Event that fires each time the gizmo snaps to a new location.
  42581. * * snapDistance is the the change in distance
  42582. */
  42583. onSnapObservable: Observable<{
  42584. snapDistance: number;
  42585. }>;
  42586. /**
  42587. * If the scaling operation should be done on all axis (default: false)
  42588. */
  42589. uniformScaling: boolean;
  42590. /**
  42591. * Creates an AxisScaleGizmo
  42592. * @param gizmoLayer The utility layer the gizmo will be added to
  42593. * @param dragAxis The axis which the gizmo will be able to scale on
  42594. * @param color The color of the gizmo
  42595. */
  42596. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42597. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42598. /**
  42599. * Disposes of the gizmo
  42600. */
  42601. dispose(): void;
  42602. /**
  42603. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42604. * @param mesh The mesh to replace the default mesh of the gizmo
  42605. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42606. */
  42607. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42608. }
  42609. }
  42610. declare module BABYLON {
  42611. /**
  42612. * Bounding box gizmo
  42613. */
  42614. export class BoundingBoxGizmo extends Gizmo {
  42615. private _lineBoundingBox;
  42616. private _rotateSpheresParent;
  42617. private _scaleBoxesParent;
  42618. private _boundingDimensions;
  42619. private _renderObserver;
  42620. private _pointerObserver;
  42621. private _scaleDragSpeed;
  42622. private _tmpQuaternion;
  42623. private _tmpVector;
  42624. private _tmpRotationMatrix;
  42625. /**
  42626. * 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)
  42627. */
  42628. ignoreChildren: boolean;
  42629. /**
  42630. * 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)
  42631. */
  42632. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42633. /**
  42634. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42635. */
  42636. rotationSphereSize: number;
  42637. /**
  42638. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42639. */
  42640. scaleBoxSize: number;
  42641. /**
  42642. * 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)
  42643. */
  42644. fixedDragMeshScreenSize: boolean;
  42645. /**
  42646. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42647. */
  42648. fixedDragMeshScreenSizeDistanceFactor: number;
  42649. /**
  42650. * Fired when a rotation sphere or scale box is dragged
  42651. */
  42652. onDragStartObservable: Observable<{}>;
  42653. /**
  42654. * Fired when a scale box is dragged
  42655. */
  42656. onScaleBoxDragObservable: Observable<{}>;
  42657. /**
  42658. * Fired when a scale box drag is ended
  42659. */
  42660. onScaleBoxDragEndObservable: Observable<{}>;
  42661. /**
  42662. * Fired when a rotation sphere is dragged
  42663. */
  42664. onRotationSphereDragObservable: Observable<{}>;
  42665. /**
  42666. * Fired when a rotation sphere drag is ended
  42667. */
  42668. onRotationSphereDragEndObservable: Observable<{}>;
  42669. /**
  42670. * 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)
  42671. */
  42672. scalePivot: Nullable<Vector3>;
  42673. /**
  42674. * Mesh used as a pivot to rotate the attached mesh
  42675. */
  42676. private _anchorMesh;
  42677. private _existingMeshScale;
  42678. private _dragMesh;
  42679. private pointerDragBehavior;
  42680. private coloredMaterial;
  42681. private hoverColoredMaterial;
  42682. /**
  42683. * Sets the color of the bounding box gizmo
  42684. * @param color the color to set
  42685. */
  42686. setColor(color: Color3): void;
  42687. /**
  42688. * Creates an BoundingBoxGizmo
  42689. * @param gizmoLayer The utility layer the gizmo will be added to
  42690. * @param color The color of the gizmo
  42691. */
  42692. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42693. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42694. private _selectNode;
  42695. /**
  42696. * Updates the bounding box information for the Gizmo
  42697. */
  42698. updateBoundingBox(): void;
  42699. private _updateRotationSpheres;
  42700. private _updateScaleBoxes;
  42701. /**
  42702. * Enables rotation on the specified axis and disables rotation on the others
  42703. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42704. */
  42705. setEnabledRotationAxis(axis: string): void;
  42706. /**
  42707. * Enables/disables scaling
  42708. * @param enable if scaling should be enabled
  42709. */
  42710. setEnabledScaling(enable: boolean): void;
  42711. private _updateDummy;
  42712. /**
  42713. * Enables a pointer drag behavior on the bounding box of the gizmo
  42714. */
  42715. enableDragBehavior(): void;
  42716. /**
  42717. * Disposes of the gizmo
  42718. */
  42719. dispose(): void;
  42720. /**
  42721. * 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)
  42722. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42723. * @returns the bounding box mesh with the passed in mesh as a child
  42724. */
  42725. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42726. /**
  42727. * CustomMeshes are not supported by this gizmo
  42728. * @param mesh The mesh to replace the default mesh of the gizmo
  42729. */
  42730. setCustomMesh(mesh: Mesh): void;
  42731. }
  42732. }
  42733. declare module BABYLON {
  42734. /**
  42735. * Single plane rotation gizmo
  42736. */
  42737. export class PlaneRotationGizmo extends Gizmo {
  42738. /**
  42739. * Drag behavior responsible for the gizmos dragging interactions
  42740. */
  42741. dragBehavior: PointerDragBehavior;
  42742. private _pointerObserver;
  42743. /**
  42744. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42745. */
  42746. snapDistance: number;
  42747. /**
  42748. * Event that fires each time the gizmo snaps to a new location.
  42749. * * snapDistance is the the change in distance
  42750. */
  42751. onSnapObservable: Observable<{
  42752. snapDistance: number;
  42753. }>;
  42754. /**
  42755. * Creates a PlaneRotationGizmo
  42756. * @param gizmoLayer The utility layer the gizmo will be added to
  42757. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42758. * @param color The color of the gizmo
  42759. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42760. */
  42761. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42762. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42763. /**
  42764. * Disposes of the gizmo
  42765. */
  42766. dispose(): void;
  42767. }
  42768. }
  42769. declare module BABYLON {
  42770. /**
  42771. * Gizmo that enables rotating a mesh along 3 axis
  42772. */
  42773. export class RotationGizmo extends Gizmo {
  42774. /**
  42775. * Internal gizmo used for interactions on the x axis
  42776. */
  42777. xGizmo: PlaneRotationGizmo;
  42778. /**
  42779. * Internal gizmo used for interactions on the y axis
  42780. */
  42781. yGizmo: PlaneRotationGizmo;
  42782. /**
  42783. * Internal gizmo used for interactions on the z axis
  42784. */
  42785. zGizmo: PlaneRotationGizmo;
  42786. /** Fires an event when any of it's sub gizmos are dragged */
  42787. onDragStartObservable: Observable<{}>;
  42788. /** Fires an event when any of it's sub gizmos are released from dragging */
  42789. onDragEndObservable: Observable<{}>;
  42790. attachedMesh: Nullable<AbstractMesh>;
  42791. /**
  42792. * Creates a RotationGizmo
  42793. * @param gizmoLayer The utility layer the gizmo will be added to
  42794. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42795. */
  42796. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42797. updateGizmoRotationToMatchAttachedMesh: boolean;
  42798. /**
  42799. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42800. */
  42801. snapDistance: number;
  42802. /**
  42803. * Ratio for the scale of the gizmo (Default: 1)
  42804. */
  42805. scaleRatio: number;
  42806. /**
  42807. * Disposes of the gizmo
  42808. */
  42809. dispose(): void;
  42810. /**
  42811. * CustomMeshes are not supported by this gizmo
  42812. * @param mesh The mesh to replace the default mesh of the gizmo
  42813. */
  42814. setCustomMesh(mesh: Mesh): void;
  42815. }
  42816. }
  42817. declare module BABYLON {
  42818. /**
  42819. * Gizmo that enables dragging a mesh along 3 axis
  42820. */
  42821. export class PositionGizmo extends Gizmo {
  42822. /**
  42823. * Internal gizmo used for interactions on the x axis
  42824. */
  42825. xGizmo: AxisDragGizmo;
  42826. /**
  42827. * Internal gizmo used for interactions on the y axis
  42828. */
  42829. yGizmo: AxisDragGizmo;
  42830. /**
  42831. * Internal gizmo used for interactions on the z axis
  42832. */
  42833. zGizmo: AxisDragGizmo;
  42834. /** Fires an event when any of it's sub gizmos are dragged */
  42835. onDragStartObservable: Observable<{}>;
  42836. /** Fires an event when any of it's sub gizmos are released from dragging */
  42837. onDragEndObservable: Observable<{}>;
  42838. attachedMesh: Nullable<AbstractMesh>;
  42839. /**
  42840. * Creates a PositionGizmo
  42841. * @param gizmoLayer The utility layer the gizmo will be added to
  42842. */
  42843. constructor(gizmoLayer?: UtilityLayerRenderer);
  42844. updateGizmoRotationToMatchAttachedMesh: boolean;
  42845. /**
  42846. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42847. */
  42848. snapDistance: number;
  42849. /**
  42850. * Ratio for the scale of the gizmo (Default: 1)
  42851. */
  42852. scaleRatio: number;
  42853. /**
  42854. * Disposes of the gizmo
  42855. */
  42856. dispose(): void;
  42857. /**
  42858. * CustomMeshes are not supported by this gizmo
  42859. * @param mesh The mesh to replace the default mesh of the gizmo
  42860. */
  42861. setCustomMesh(mesh: Mesh): void;
  42862. }
  42863. }
  42864. declare module BABYLON {
  42865. /**
  42866. * Class containing static functions to help procedurally build meshes
  42867. */
  42868. export class PolyhedronBuilder {
  42869. /**
  42870. * Creates a polyhedron mesh
  42871. * * 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
  42872. * * The parameter `size` (positive float, default 1) sets the polygon size
  42873. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42874. * * 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`
  42875. * * 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
  42876. * * 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)`)
  42877. * * 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
  42878. * * 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
  42879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42880. * * 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
  42881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42882. * @param name defines the name of the mesh
  42883. * @param options defines the options used to create the mesh
  42884. * @param scene defines the hosting scene
  42885. * @returns the polyhedron mesh
  42886. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42887. */
  42888. static CreatePolyhedron(name: string, options: {
  42889. type?: number;
  42890. size?: number;
  42891. sizeX?: number;
  42892. sizeY?: number;
  42893. sizeZ?: number;
  42894. custom?: any;
  42895. faceUV?: Vector4[];
  42896. faceColors?: Color4[];
  42897. flat?: boolean;
  42898. updatable?: boolean;
  42899. sideOrientation?: number;
  42900. frontUVs?: Vector4;
  42901. backUVs?: Vector4;
  42902. }, scene?: Nullable<Scene>): Mesh;
  42903. }
  42904. }
  42905. declare module BABYLON {
  42906. /**
  42907. * Gizmo that enables scaling a mesh along 3 axis
  42908. */
  42909. export class ScaleGizmo extends Gizmo {
  42910. /**
  42911. * Internal gizmo used for interactions on the x axis
  42912. */
  42913. xGizmo: AxisScaleGizmo;
  42914. /**
  42915. * Internal gizmo used for interactions on the y axis
  42916. */
  42917. yGizmo: AxisScaleGizmo;
  42918. /**
  42919. * Internal gizmo used for interactions on the z axis
  42920. */
  42921. zGizmo: AxisScaleGizmo;
  42922. /**
  42923. * Internal gizmo used to scale all axis equally
  42924. */
  42925. uniformScaleGizmo: AxisScaleGizmo;
  42926. /** Fires an event when any of it's sub gizmos are dragged */
  42927. onDragStartObservable: Observable<{}>;
  42928. /** Fires an event when any of it's sub gizmos are released from dragging */
  42929. onDragEndObservable: Observable<{}>;
  42930. attachedMesh: Nullable<AbstractMesh>;
  42931. /**
  42932. * Creates a ScaleGizmo
  42933. * @param gizmoLayer The utility layer the gizmo will be added to
  42934. */
  42935. constructor(gizmoLayer?: UtilityLayerRenderer);
  42936. updateGizmoRotationToMatchAttachedMesh: boolean;
  42937. /**
  42938. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42939. */
  42940. snapDistance: number;
  42941. /**
  42942. * Ratio for the scale of the gizmo (Default: 1)
  42943. */
  42944. scaleRatio: number;
  42945. /**
  42946. * Disposes of the gizmo
  42947. */
  42948. dispose(): void;
  42949. }
  42950. }
  42951. declare module BABYLON {
  42952. /**
  42953. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42954. */
  42955. export class GizmoManager implements IDisposable {
  42956. private scene;
  42957. /**
  42958. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42959. */
  42960. gizmos: {
  42961. positionGizmo: Nullable<PositionGizmo>;
  42962. rotationGizmo: Nullable<RotationGizmo>;
  42963. scaleGizmo: Nullable<ScaleGizmo>;
  42964. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42965. };
  42966. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42967. clearGizmoOnEmptyPointerEvent: boolean;
  42968. /** Fires an event when the manager is attached to a mesh */
  42969. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42970. private _gizmosEnabled;
  42971. private _pointerObserver;
  42972. private _attachedMesh;
  42973. private _boundingBoxColor;
  42974. private _defaultUtilityLayer;
  42975. private _defaultKeepDepthUtilityLayer;
  42976. /**
  42977. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42978. */
  42979. boundingBoxDragBehavior: SixDofDragBehavior;
  42980. /**
  42981. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42982. */
  42983. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42984. /**
  42985. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42986. */
  42987. usePointerToAttachGizmos: boolean;
  42988. /**
  42989. * Instatiates a gizmo manager
  42990. * @param scene the scene to overlay the gizmos on top of
  42991. */
  42992. constructor(scene: Scene);
  42993. /**
  42994. * Attaches a set of gizmos to the specified mesh
  42995. * @param mesh The mesh the gizmo's should be attached to
  42996. */
  42997. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42998. /**
  42999. * If the position gizmo is enabled
  43000. */
  43001. positionGizmoEnabled: boolean;
  43002. /**
  43003. * If the rotation gizmo is enabled
  43004. */
  43005. rotationGizmoEnabled: boolean;
  43006. /**
  43007. * If the scale gizmo is enabled
  43008. */
  43009. scaleGizmoEnabled: boolean;
  43010. /**
  43011. * If the boundingBox gizmo is enabled
  43012. */
  43013. boundingBoxGizmoEnabled: boolean;
  43014. /**
  43015. * Disposes of the gizmo manager
  43016. */
  43017. dispose(): void;
  43018. }
  43019. }
  43020. declare module BABYLON {
  43021. /**
  43022. * A directional light is defined by a direction (what a surprise!).
  43023. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43024. * 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.
  43025. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43026. */
  43027. export class DirectionalLight extends ShadowLight {
  43028. private _shadowFrustumSize;
  43029. /**
  43030. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43031. */
  43032. /**
  43033. * Specifies a fix frustum size for the shadow generation.
  43034. */
  43035. shadowFrustumSize: number;
  43036. private _shadowOrthoScale;
  43037. /**
  43038. * Gets the shadow projection scale against the optimal computed one.
  43039. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43040. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43041. */
  43042. /**
  43043. * Sets the shadow projection scale against the optimal computed one.
  43044. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43045. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43046. */
  43047. shadowOrthoScale: number;
  43048. /**
  43049. * Automatically compute the projection matrix to best fit (including all the casters)
  43050. * on each frame.
  43051. */
  43052. autoUpdateExtends: boolean;
  43053. private _orthoLeft;
  43054. private _orthoRight;
  43055. private _orthoTop;
  43056. private _orthoBottom;
  43057. /**
  43058. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43059. * The directional light is emitted from everywhere in the given direction.
  43060. * It can cast shadows.
  43061. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43062. * @param name The friendly name of the light
  43063. * @param direction The direction of the light
  43064. * @param scene The scene the light belongs to
  43065. */
  43066. constructor(name: string, direction: Vector3, scene: Scene);
  43067. /**
  43068. * Returns the string "DirectionalLight".
  43069. * @return The class name
  43070. */
  43071. getClassName(): string;
  43072. /**
  43073. * Returns the integer 1.
  43074. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43075. */
  43076. getTypeID(): number;
  43077. /**
  43078. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43079. * Returns the DirectionalLight Shadow projection matrix.
  43080. */
  43081. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43082. /**
  43083. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43084. * Returns the DirectionalLight Shadow projection matrix.
  43085. */
  43086. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43087. /**
  43088. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43089. * Returns the DirectionalLight Shadow projection matrix.
  43090. */
  43091. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43092. protected _buildUniformLayout(): void;
  43093. /**
  43094. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43095. * @param effect The effect to update
  43096. * @param lightIndex The index of the light in the effect to update
  43097. * @returns The directional light
  43098. */
  43099. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43100. /**
  43101. * Gets the minZ used for shadow according to both the scene and the light.
  43102. *
  43103. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43104. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43105. * @param activeCamera The camera we are returning the min for
  43106. * @returns the depth min z
  43107. */
  43108. getDepthMinZ(activeCamera: Camera): number;
  43109. /**
  43110. * Gets the maxZ used for shadow according to both the scene and the light.
  43111. *
  43112. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43113. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43114. * @param activeCamera The camera we are returning the max for
  43115. * @returns the depth max z
  43116. */
  43117. getDepthMaxZ(activeCamera: Camera): number;
  43118. /**
  43119. * Prepares the list of defines specific to the light type.
  43120. * @param defines the list of defines
  43121. * @param lightIndex defines the index of the light for the effect
  43122. */
  43123. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43124. }
  43125. }
  43126. declare module BABYLON {
  43127. /**
  43128. * Class containing static functions to help procedurally build meshes
  43129. */
  43130. export class HemisphereBuilder {
  43131. /**
  43132. * Creates a hemisphere mesh
  43133. * @param name defines the name of the mesh
  43134. * @param options defines the options used to create the mesh
  43135. * @param scene defines the hosting scene
  43136. * @returns the hemisphere mesh
  43137. */
  43138. static CreateHemisphere(name: string, options: {
  43139. segments?: number;
  43140. diameter?: number;
  43141. sideOrientation?: number;
  43142. }, scene: any): Mesh;
  43143. }
  43144. }
  43145. declare module BABYLON {
  43146. /**
  43147. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43148. * These values define a cone of light starting from the position, emitting toward the direction.
  43149. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43150. * and the exponent defines the speed of the decay of the light with distance (reach).
  43151. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43152. */
  43153. export class SpotLight extends ShadowLight {
  43154. private _angle;
  43155. private _innerAngle;
  43156. private _cosHalfAngle;
  43157. private _lightAngleScale;
  43158. private _lightAngleOffset;
  43159. /**
  43160. * Gets the cone angle of the spot light in Radians.
  43161. */
  43162. /**
  43163. * Sets the cone angle of the spot light in Radians.
  43164. */
  43165. angle: number;
  43166. /**
  43167. * Only used in gltf falloff mode, this defines the angle where
  43168. * the directional falloff will start before cutting at angle which could be seen
  43169. * as outer angle.
  43170. */
  43171. /**
  43172. * Only used in gltf falloff mode, this defines the angle where
  43173. * the directional falloff will start before cutting at angle which could be seen
  43174. * as outer angle.
  43175. */
  43176. innerAngle: number;
  43177. private _shadowAngleScale;
  43178. /**
  43179. * Allows scaling the angle of the light for shadow generation only.
  43180. */
  43181. /**
  43182. * Allows scaling the angle of the light for shadow generation only.
  43183. */
  43184. shadowAngleScale: number;
  43185. /**
  43186. * The light decay speed with the distance from the emission spot.
  43187. */
  43188. exponent: number;
  43189. private _projectionTextureMatrix;
  43190. /**
  43191. * Allows reading the projecton texture
  43192. */
  43193. readonly projectionTextureMatrix: Matrix;
  43194. protected _projectionTextureLightNear: number;
  43195. /**
  43196. * Gets the near clip of the Spotlight for texture projection.
  43197. */
  43198. /**
  43199. * Sets the near clip of the Spotlight for texture projection.
  43200. */
  43201. projectionTextureLightNear: number;
  43202. protected _projectionTextureLightFar: number;
  43203. /**
  43204. * Gets the far clip of the Spotlight for texture projection.
  43205. */
  43206. /**
  43207. * Sets the far clip of the Spotlight for texture projection.
  43208. */
  43209. projectionTextureLightFar: number;
  43210. protected _projectionTextureUpDirection: Vector3;
  43211. /**
  43212. * Gets the Up vector of the Spotlight for texture projection.
  43213. */
  43214. /**
  43215. * Sets the Up vector of the Spotlight for texture projection.
  43216. */
  43217. projectionTextureUpDirection: Vector3;
  43218. private _projectionTexture;
  43219. /**
  43220. * Gets the projection texture of the light.
  43221. */
  43222. /**
  43223. * Sets the projection texture of the light.
  43224. */
  43225. projectionTexture: Nullable<BaseTexture>;
  43226. private _projectionTextureViewLightDirty;
  43227. private _projectionTextureProjectionLightDirty;
  43228. private _projectionTextureDirty;
  43229. private _projectionTextureViewTargetVector;
  43230. private _projectionTextureViewLightMatrix;
  43231. private _projectionTextureProjectionLightMatrix;
  43232. private _projectionTextureScalingMatrix;
  43233. /**
  43234. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43235. * It can cast shadows.
  43236. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43237. * @param name The light friendly name
  43238. * @param position The position of the spot light in the scene
  43239. * @param direction The direction of the light in the scene
  43240. * @param angle The cone angle of the light in Radians
  43241. * @param exponent The light decay speed with the distance from the emission spot
  43242. * @param scene The scene the lights belongs to
  43243. */
  43244. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43245. /**
  43246. * Returns the string "SpotLight".
  43247. * @returns the class name
  43248. */
  43249. getClassName(): string;
  43250. /**
  43251. * Returns the integer 2.
  43252. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43253. */
  43254. getTypeID(): number;
  43255. /**
  43256. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43257. */
  43258. protected _setDirection(value: Vector3): void;
  43259. /**
  43260. * Overrides the position setter to recompute the projection texture view light Matrix.
  43261. */
  43262. protected _setPosition(value: Vector3): void;
  43263. /**
  43264. * 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.
  43265. * Returns the SpotLight.
  43266. */
  43267. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43268. protected _computeProjectionTextureViewLightMatrix(): void;
  43269. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43270. /**
  43271. * Main function for light texture projection matrix computing.
  43272. */
  43273. protected _computeProjectionTextureMatrix(): void;
  43274. protected _buildUniformLayout(): void;
  43275. private _computeAngleValues;
  43276. /**
  43277. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43278. * @param effect The effect to update
  43279. * @param lightIndex The index of the light in the effect to update
  43280. * @returns The spot light
  43281. */
  43282. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43283. /**
  43284. * Disposes the light and the associated resources.
  43285. */
  43286. dispose(): void;
  43287. /**
  43288. * Prepares the list of defines specific to the light type.
  43289. * @param defines the list of defines
  43290. * @param lightIndex defines the index of the light for the effect
  43291. */
  43292. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43293. }
  43294. }
  43295. declare module BABYLON {
  43296. /**
  43297. * Gizmo that enables viewing a light
  43298. */
  43299. export class LightGizmo extends Gizmo {
  43300. private _lightMesh;
  43301. private _material;
  43302. private cachedPosition;
  43303. private cachedForward;
  43304. /**
  43305. * Creates a LightGizmo
  43306. * @param gizmoLayer The utility layer the gizmo will be added to
  43307. */
  43308. constructor(gizmoLayer?: UtilityLayerRenderer);
  43309. private _light;
  43310. /**
  43311. * The light that the gizmo is attached to
  43312. */
  43313. light: Nullable<Light>;
  43314. /**
  43315. * @hidden
  43316. * Updates the gizmo to match the attached mesh's position/rotation
  43317. */
  43318. protected _update(): void;
  43319. private static _Scale;
  43320. /**
  43321. * Creates the lines for a light mesh
  43322. */
  43323. private static _createLightLines;
  43324. /**
  43325. * Disposes of the light gizmo
  43326. */
  43327. dispose(): void;
  43328. private static _CreateHemisphericLightMesh;
  43329. private static _CreatePointLightMesh;
  43330. private static _CreateSpotLightMesh;
  43331. private static _CreateDirectionalLightMesh;
  43332. }
  43333. }
  43334. declare module BABYLON {
  43335. /** @hidden */
  43336. export var backgroundFragmentDeclaration: {
  43337. name: string;
  43338. shader: string;
  43339. };
  43340. }
  43341. declare module BABYLON {
  43342. /** @hidden */
  43343. export var backgroundUboDeclaration: {
  43344. name: string;
  43345. shader: string;
  43346. };
  43347. }
  43348. declare module BABYLON {
  43349. /** @hidden */
  43350. export var backgroundPixelShader: {
  43351. name: string;
  43352. shader: string;
  43353. };
  43354. }
  43355. declare module BABYLON {
  43356. /** @hidden */
  43357. export var backgroundVertexDeclaration: {
  43358. name: string;
  43359. shader: string;
  43360. };
  43361. }
  43362. declare module BABYLON {
  43363. /** @hidden */
  43364. export var backgroundVertexShader: {
  43365. name: string;
  43366. shader: string;
  43367. };
  43368. }
  43369. declare module BABYLON {
  43370. /**
  43371. * Background material used to create an efficient environement around your scene.
  43372. */
  43373. export class BackgroundMaterial extends PushMaterial {
  43374. /**
  43375. * Standard reflectance value at parallel view angle.
  43376. */
  43377. static StandardReflectance0: number;
  43378. /**
  43379. * Standard reflectance value at grazing angle.
  43380. */
  43381. static StandardReflectance90: number;
  43382. protected _primaryColor: Color3;
  43383. /**
  43384. * Key light Color (multiply against the environement texture)
  43385. */
  43386. primaryColor: Color3;
  43387. protected __perceptualColor: Nullable<Color3>;
  43388. /**
  43389. * Experimental Internal Use Only.
  43390. *
  43391. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43392. * This acts as a helper to set the primary color to a more "human friendly" value.
  43393. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43394. * output color as close as possible from the chosen value.
  43395. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43396. * part of lighting setup.)
  43397. */
  43398. _perceptualColor: Nullable<Color3>;
  43399. protected _primaryColorShadowLevel: float;
  43400. /**
  43401. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43402. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43403. */
  43404. primaryColorShadowLevel: float;
  43405. protected _primaryColorHighlightLevel: float;
  43406. /**
  43407. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43408. * The primary color is used at the level chosen to define what the white area would look.
  43409. */
  43410. primaryColorHighlightLevel: float;
  43411. protected _reflectionTexture: Nullable<BaseTexture>;
  43412. /**
  43413. * Reflection Texture used in the material.
  43414. * Should be author in a specific way for the best result (refer to the documentation).
  43415. */
  43416. reflectionTexture: Nullable<BaseTexture>;
  43417. protected _reflectionBlur: float;
  43418. /**
  43419. * Reflection Texture level of blur.
  43420. *
  43421. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43422. * texture twice.
  43423. */
  43424. reflectionBlur: float;
  43425. protected _diffuseTexture: Nullable<BaseTexture>;
  43426. /**
  43427. * Diffuse Texture used in the material.
  43428. * Should be author in a specific way for the best result (refer to the documentation).
  43429. */
  43430. diffuseTexture: Nullable<BaseTexture>;
  43431. protected _shadowLights: Nullable<IShadowLight[]>;
  43432. /**
  43433. * Specify the list of lights casting shadow on the material.
  43434. * All scene shadow lights will be included if null.
  43435. */
  43436. shadowLights: Nullable<IShadowLight[]>;
  43437. protected _shadowLevel: float;
  43438. /**
  43439. * Helps adjusting the shadow to a softer level if required.
  43440. * 0 means black shadows and 1 means no shadows.
  43441. */
  43442. shadowLevel: float;
  43443. protected _sceneCenter: Vector3;
  43444. /**
  43445. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43446. * It is usually zero but might be interesting to modify according to your setup.
  43447. */
  43448. sceneCenter: Vector3;
  43449. protected _opacityFresnel: boolean;
  43450. /**
  43451. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43452. * This helps ensuring a nice transition when the camera goes under the ground.
  43453. */
  43454. opacityFresnel: boolean;
  43455. protected _reflectionFresnel: boolean;
  43456. /**
  43457. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43458. * This helps adding a mirror texture on the ground.
  43459. */
  43460. reflectionFresnel: boolean;
  43461. protected _reflectionFalloffDistance: number;
  43462. /**
  43463. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43464. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43465. */
  43466. reflectionFalloffDistance: number;
  43467. protected _reflectionAmount: number;
  43468. /**
  43469. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43470. */
  43471. reflectionAmount: number;
  43472. protected _reflectionReflectance0: number;
  43473. /**
  43474. * This specifies the weight of the reflection at grazing angle.
  43475. */
  43476. reflectionReflectance0: number;
  43477. protected _reflectionReflectance90: number;
  43478. /**
  43479. * This specifies the weight of the reflection at a perpendicular point of view.
  43480. */
  43481. reflectionReflectance90: number;
  43482. /**
  43483. * Sets the reflection reflectance fresnel values according to the default standard
  43484. * empirically know to work well :-)
  43485. */
  43486. reflectionStandardFresnelWeight: number;
  43487. protected _useRGBColor: boolean;
  43488. /**
  43489. * Helps to directly use the maps channels instead of their level.
  43490. */
  43491. useRGBColor: boolean;
  43492. protected _enableNoise: boolean;
  43493. /**
  43494. * This helps reducing the banding effect that could occur on the background.
  43495. */
  43496. enableNoise: boolean;
  43497. /**
  43498. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43499. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43500. * Recommended to be keep at 1.0 except for special cases.
  43501. */
  43502. fovMultiplier: number;
  43503. private _fovMultiplier;
  43504. /**
  43505. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43506. */
  43507. useEquirectangularFOV: boolean;
  43508. private _maxSimultaneousLights;
  43509. /**
  43510. * Number of Simultaneous lights allowed on the material.
  43511. */
  43512. maxSimultaneousLights: int;
  43513. /**
  43514. * Default configuration related to image processing available in the Background Material.
  43515. */
  43516. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43517. /**
  43518. * Keep track of the image processing observer to allow dispose and replace.
  43519. */
  43520. private _imageProcessingObserver;
  43521. /**
  43522. * Attaches a new image processing configuration to the PBR Material.
  43523. * @param configuration (if null the scene configuration will be use)
  43524. */
  43525. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43526. /**
  43527. * Gets the image processing configuration used either in this material.
  43528. */
  43529. /**
  43530. * Sets the Default image processing configuration used either in the this material.
  43531. *
  43532. * If sets to null, the scene one is in use.
  43533. */
  43534. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43535. /**
  43536. * Gets wether the color curves effect is enabled.
  43537. */
  43538. /**
  43539. * Sets wether the color curves effect is enabled.
  43540. */
  43541. cameraColorCurvesEnabled: boolean;
  43542. /**
  43543. * Gets wether the color grading effect is enabled.
  43544. */
  43545. /**
  43546. * Gets wether the color grading effect is enabled.
  43547. */
  43548. cameraColorGradingEnabled: boolean;
  43549. /**
  43550. * Gets wether tonemapping is enabled or not.
  43551. */
  43552. /**
  43553. * Sets wether tonemapping is enabled or not
  43554. */
  43555. cameraToneMappingEnabled: boolean;
  43556. /**
  43557. * The camera exposure used on this material.
  43558. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43559. * This corresponds to a photographic exposure.
  43560. */
  43561. /**
  43562. * The camera exposure used on this material.
  43563. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43564. * This corresponds to a photographic exposure.
  43565. */
  43566. cameraExposure: float;
  43567. /**
  43568. * Gets The camera contrast used on this material.
  43569. */
  43570. /**
  43571. * Sets The camera contrast used on this material.
  43572. */
  43573. cameraContrast: float;
  43574. /**
  43575. * Gets the Color Grading 2D Lookup Texture.
  43576. */
  43577. /**
  43578. * Sets the Color Grading 2D Lookup Texture.
  43579. */
  43580. cameraColorGradingTexture: Nullable<BaseTexture>;
  43581. /**
  43582. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43583. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43584. * 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;
  43585. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43586. */
  43587. /**
  43588. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43589. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43590. * 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;
  43591. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43592. */
  43593. cameraColorCurves: Nullable<ColorCurves>;
  43594. /**
  43595. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43596. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43597. */
  43598. switchToBGR: boolean;
  43599. private _renderTargets;
  43600. private _reflectionControls;
  43601. private _white;
  43602. private _primaryShadowColor;
  43603. private _primaryHighlightColor;
  43604. /**
  43605. * Instantiates a Background Material in the given scene
  43606. * @param name The friendly name of the material
  43607. * @param scene The scene to add the material to
  43608. */
  43609. constructor(name: string, scene: Scene);
  43610. /**
  43611. * Gets a boolean indicating that current material needs to register RTT
  43612. */
  43613. readonly hasRenderTargetTextures: boolean;
  43614. /**
  43615. * The entire material has been created in order to prevent overdraw.
  43616. * @returns false
  43617. */
  43618. needAlphaTesting(): boolean;
  43619. /**
  43620. * The entire material has been created in order to prevent overdraw.
  43621. * @returns true if blending is enable
  43622. */
  43623. needAlphaBlending(): boolean;
  43624. /**
  43625. * Checks wether the material is ready to be rendered for a given mesh.
  43626. * @param mesh The mesh to render
  43627. * @param subMesh The submesh to check against
  43628. * @param useInstances Specify wether or not the material is used with instances
  43629. * @returns true if all the dependencies are ready (Textures, Effects...)
  43630. */
  43631. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43632. /**
  43633. * Compute the primary color according to the chosen perceptual color.
  43634. */
  43635. private _computePrimaryColorFromPerceptualColor;
  43636. /**
  43637. * Compute the highlights and shadow colors according to their chosen levels.
  43638. */
  43639. private _computePrimaryColors;
  43640. /**
  43641. * Build the uniform buffer used in the material.
  43642. */
  43643. buildUniformLayout(): void;
  43644. /**
  43645. * Unbind the material.
  43646. */
  43647. unbind(): void;
  43648. /**
  43649. * Bind only the world matrix to the material.
  43650. * @param world The world matrix to bind.
  43651. */
  43652. bindOnlyWorldMatrix(world: Matrix): void;
  43653. /**
  43654. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43655. * @param world The world matrix to bind.
  43656. * @param subMesh The submesh to bind for.
  43657. */
  43658. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43659. /**
  43660. * Dispose the material.
  43661. * @param forceDisposeEffect Force disposal of the associated effect.
  43662. * @param forceDisposeTextures Force disposal of the associated textures.
  43663. */
  43664. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43665. /**
  43666. * Clones the material.
  43667. * @param name The cloned name.
  43668. * @returns The cloned material.
  43669. */
  43670. clone(name: string): BackgroundMaterial;
  43671. /**
  43672. * Serializes the current material to its JSON representation.
  43673. * @returns The JSON representation.
  43674. */
  43675. serialize(): any;
  43676. /**
  43677. * Gets the class name of the material
  43678. * @returns "BackgroundMaterial"
  43679. */
  43680. getClassName(): string;
  43681. /**
  43682. * Parse a JSON input to create back a background material.
  43683. * @param source The JSON data to parse
  43684. * @param scene The scene to create the parsed material in
  43685. * @param rootUrl The root url of the assets the material depends upon
  43686. * @returns the instantiated BackgroundMaterial.
  43687. */
  43688. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43689. }
  43690. }
  43691. declare module BABYLON {
  43692. /**
  43693. * Represents the different options available during the creation of
  43694. * a Environment helper.
  43695. *
  43696. * This can control the default ground, skybox and image processing setup of your scene.
  43697. */
  43698. export interface IEnvironmentHelperOptions {
  43699. /**
  43700. * Specifies wether or not to create a ground.
  43701. * True by default.
  43702. */
  43703. createGround: boolean;
  43704. /**
  43705. * Specifies the ground size.
  43706. * 15 by default.
  43707. */
  43708. groundSize: number;
  43709. /**
  43710. * The texture used on the ground for the main color.
  43711. * Comes from the BabylonJS CDN by default.
  43712. *
  43713. * Remarks: Can be either a texture or a url.
  43714. */
  43715. groundTexture: string | BaseTexture;
  43716. /**
  43717. * The color mixed in the ground texture by default.
  43718. * BabylonJS clearColor by default.
  43719. */
  43720. groundColor: Color3;
  43721. /**
  43722. * Specifies the ground opacity.
  43723. * 1 by default.
  43724. */
  43725. groundOpacity: number;
  43726. /**
  43727. * Enables the ground to receive shadows.
  43728. * True by default.
  43729. */
  43730. enableGroundShadow: boolean;
  43731. /**
  43732. * Helps preventing the shadow to be fully black on the ground.
  43733. * 0.5 by default.
  43734. */
  43735. groundShadowLevel: number;
  43736. /**
  43737. * Creates a mirror texture attach to the ground.
  43738. * false by default.
  43739. */
  43740. enableGroundMirror: boolean;
  43741. /**
  43742. * Specifies the ground mirror size ratio.
  43743. * 0.3 by default as the default kernel is 64.
  43744. */
  43745. groundMirrorSizeRatio: number;
  43746. /**
  43747. * Specifies the ground mirror blur kernel size.
  43748. * 64 by default.
  43749. */
  43750. groundMirrorBlurKernel: number;
  43751. /**
  43752. * Specifies the ground mirror visibility amount.
  43753. * 1 by default
  43754. */
  43755. groundMirrorAmount: number;
  43756. /**
  43757. * Specifies the ground mirror reflectance weight.
  43758. * This uses the standard weight of the background material to setup the fresnel effect
  43759. * of the mirror.
  43760. * 1 by default.
  43761. */
  43762. groundMirrorFresnelWeight: number;
  43763. /**
  43764. * Specifies the ground mirror Falloff distance.
  43765. * This can helps reducing the size of the reflection.
  43766. * 0 by Default.
  43767. */
  43768. groundMirrorFallOffDistance: number;
  43769. /**
  43770. * Specifies the ground mirror texture type.
  43771. * Unsigned Int by Default.
  43772. */
  43773. groundMirrorTextureType: number;
  43774. /**
  43775. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43776. * the shown objects.
  43777. */
  43778. groundYBias: number;
  43779. /**
  43780. * Specifies wether or not to create a skybox.
  43781. * True by default.
  43782. */
  43783. createSkybox: boolean;
  43784. /**
  43785. * Specifies the skybox size.
  43786. * 20 by default.
  43787. */
  43788. skyboxSize: number;
  43789. /**
  43790. * The texture used on the skybox for the main color.
  43791. * Comes from the BabylonJS CDN by default.
  43792. *
  43793. * Remarks: Can be either a texture or a url.
  43794. */
  43795. skyboxTexture: string | BaseTexture;
  43796. /**
  43797. * The color mixed in the skybox texture by default.
  43798. * BabylonJS clearColor by default.
  43799. */
  43800. skyboxColor: Color3;
  43801. /**
  43802. * The background rotation around the Y axis of the scene.
  43803. * This helps aligning the key lights of your scene with the background.
  43804. * 0 by default.
  43805. */
  43806. backgroundYRotation: number;
  43807. /**
  43808. * Compute automatically the size of the elements to best fit with the scene.
  43809. */
  43810. sizeAuto: boolean;
  43811. /**
  43812. * Default position of the rootMesh if autoSize is not true.
  43813. */
  43814. rootPosition: Vector3;
  43815. /**
  43816. * Sets up the image processing in the scene.
  43817. * true by default.
  43818. */
  43819. setupImageProcessing: boolean;
  43820. /**
  43821. * The texture used as your environment texture in the scene.
  43822. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43823. *
  43824. * Remarks: Can be either a texture or a url.
  43825. */
  43826. environmentTexture: string | BaseTexture;
  43827. /**
  43828. * The value of the exposure to apply to the scene.
  43829. * 0.6 by default if setupImageProcessing is true.
  43830. */
  43831. cameraExposure: number;
  43832. /**
  43833. * The value of the contrast to apply to the scene.
  43834. * 1.6 by default if setupImageProcessing is true.
  43835. */
  43836. cameraContrast: number;
  43837. /**
  43838. * Specifies wether or not tonemapping should be enabled in the scene.
  43839. * true by default if setupImageProcessing is true.
  43840. */
  43841. toneMappingEnabled: boolean;
  43842. }
  43843. /**
  43844. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43845. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43846. * It also helps with the default setup of your imageProcessing configuration.
  43847. */
  43848. export class EnvironmentHelper {
  43849. /**
  43850. * Default ground texture URL.
  43851. */
  43852. private static _groundTextureCDNUrl;
  43853. /**
  43854. * Default skybox texture URL.
  43855. */
  43856. private static _skyboxTextureCDNUrl;
  43857. /**
  43858. * Default environment texture URL.
  43859. */
  43860. private static _environmentTextureCDNUrl;
  43861. /**
  43862. * Creates the default options for the helper.
  43863. */
  43864. private static _getDefaultOptions;
  43865. private _rootMesh;
  43866. /**
  43867. * Gets the root mesh created by the helper.
  43868. */
  43869. readonly rootMesh: Mesh;
  43870. private _skybox;
  43871. /**
  43872. * Gets the skybox created by the helper.
  43873. */
  43874. readonly skybox: Nullable<Mesh>;
  43875. private _skyboxTexture;
  43876. /**
  43877. * Gets the skybox texture created by the helper.
  43878. */
  43879. readonly skyboxTexture: Nullable<BaseTexture>;
  43880. private _skyboxMaterial;
  43881. /**
  43882. * Gets the skybox material created by the helper.
  43883. */
  43884. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43885. private _ground;
  43886. /**
  43887. * Gets the ground mesh created by the helper.
  43888. */
  43889. readonly ground: Nullable<Mesh>;
  43890. private _groundTexture;
  43891. /**
  43892. * Gets the ground texture created by the helper.
  43893. */
  43894. readonly groundTexture: Nullable<BaseTexture>;
  43895. private _groundMirror;
  43896. /**
  43897. * Gets the ground mirror created by the helper.
  43898. */
  43899. readonly groundMirror: Nullable<MirrorTexture>;
  43900. /**
  43901. * Gets the ground mirror render list to helps pushing the meshes
  43902. * you wish in the ground reflection.
  43903. */
  43904. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43905. private _groundMaterial;
  43906. /**
  43907. * Gets the ground material created by the helper.
  43908. */
  43909. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43910. /**
  43911. * Stores the creation options.
  43912. */
  43913. private readonly _scene;
  43914. private _options;
  43915. /**
  43916. * This observable will be notified with any error during the creation of the environment,
  43917. * mainly texture creation errors.
  43918. */
  43919. onErrorObservable: Observable<{
  43920. message?: string;
  43921. exception?: any;
  43922. }>;
  43923. /**
  43924. * constructor
  43925. * @param options Defines the options we want to customize the helper
  43926. * @param scene The scene to add the material to
  43927. */
  43928. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43929. /**
  43930. * Updates the background according to the new options
  43931. * @param options
  43932. */
  43933. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43934. /**
  43935. * Sets the primary color of all the available elements.
  43936. * @param color the main color to affect to the ground and the background
  43937. */
  43938. setMainColor(color: Color3): void;
  43939. /**
  43940. * Setup the image processing according to the specified options.
  43941. */
  43942. private _setupImageProcessing;
  43943. /**
  43944. * Setup the environment texture according to the specified options.
  43945. */
  43946. private _setupEnvironmentTexture;
  43947. /**
  43948. * Setup the background according to the specified options.
  43949. */
  43950. private _setupBackground;
  43951. /**
  43952. * Get the scene sizes according to the setup.
  43953. */
  43954. private _getSceneSize;
  43955. /**
  43956. * Setup the ground according to the specified options.
  43957. */
  43958. private _setupGround;
  43959. /**
  43960. * Setup the ground material according to the specified options.
  43961. */
  43962. private _setupGroundMaterial;
  43963. /**
  43964. * Setup the ground diffuse texture according to the specified options.
  43965. */
  43966. private _setupGroundDiffuseTexture;
  43967. /**
  43968. * Setup the ground mirror texture according to the specified options.
  43969. */
  43970. private _setupGroundMirrorTexture;
  43971. /**
  43972. * Setup the ground to receive the mirror texture.
  43973. */
  43974. private _setupMirrorInGroundMaterial;
  43975. /**
  43976. * Setup the skybox according to the specified options.
  43977. */
  43978. private _setupSkybox;
  43979. /**
  43980. * Setup the skybox material according to the specified options.
  43981. */
  43982. private _setupSkyboxMaterial;
  43983. /**
  43984. * Setup the skybox reflection texture according to the specified options.
  43985. */
  43986. private _setupSkyboxReflectionTexture;
  43987. private _errorHandler;
  43988. /**
  43989. * Dispose all the elements created by the Helper.
  43990. */
  43991. dispose(): void;
  43992. }
  43993. }
  43994. declare module BABYLON {
  43995. /**
  43996. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43997. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43998. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43999. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44000. */
  44001. export class PhotoDome extends TransformNode {
  44002. private _useDirectMapping;
  44003. /**
  44004. * The texture being displayed on the sphere
  44005. */
  44006. protected _photoTexture: Texture;
  44007. /**
  44008. * Gets or sets the texture being displayed on the sphere
  44009. */
  44010. photoTexture: Texture;
  44011. /**
  44012. * Observable raised when an error occured while loading the 360 image
  44013. */
  44014. onLoadErrorObservable: Observable<string>;
  44015. /**
  44016. * The skybox material
  44017. */
  44018. protected _material: BackgroundMaterial;
  44019. /**
  44020. * The surface used for the skybox
  44021. */
  44022. protected _mesh: Mesh;
  44023. /**
  44024. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44025. * Also see the options.resolution property.
  44026. */
  44027. fovMultiplier: number;
  44028. /**
  44029. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44030. * @param name Element's name, child elements will append suffixes for their own names.
  44031. * @param urlsOfPhoto defines the url of the photo to display
  44032. * @param options defines an object containing optional or exposed sub element properties
  44033. * @param onError defines a callback called when an error occured while loading the texture
  44034. */
  44035. constructor(name: string, urlOfPhoto: string, options: {
  44036. resolution?: number;
  44037. size?: number;
  44038. useDirectMapping?: boolean;
  44039. faceForward?: boolean;
  44040. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44041. /**
  44042. * Releases resources associated with this node.
  44043. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44044. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44045. */
  44046. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44047. }
  44048. }
  44049. declare module BABYLON {
  44050. /** @hidden */
  44051. export var rgbdDecodePixelShader: {
  44052. name: string;
  44053. shader: string;
  44054. };
  44055. }
  44056. declare module BABYLON {
  44057. /**
  44058. * Class used to host texture specific utilities
  44059. */
  44060. export class BRDFTextureTools {
  44061. /**
  44062. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44063. * @param texture the texture to expand.
  44064. */
  44065. private static _ExpandDefaultBRDFTexture;
  44066. /**
  44067. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44068. * @param scene defines the hosting scene
  44069. * @returns the environment BRDF texture
  44070. */
  44071. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44072. private static _environmentBRDFBase64Texture;
  44073. }
  44074. }
  44075. declare module BABYLON {
  44076. /**
  44077. * @hidden
  44078. */
  44079. export interface IMaterialClearCoatDefines {
  44080. CLEARCOAT: boolean;
  44081. CLEARCOAT_DEFAULTIOR: boolean;
  44082. CLEARCOAT_TEXTURE: boolean;
  44083. CLEARCOAT_TEXTUREDIRECTUV: number;
  44084. CLEARCOAT_BUMP: boolean;
  44085. CLEARCOAT_BUMPDIRECTUV: number;
  44086. CLEARCOAT_TINT: boolean;
  44087. CLEARCOAT_TINT_TEXTURE: boolean;
  44088. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44089. /** @hidden */
  44090. _areTexturesDirty: boolean;
  44091. }
  44092. /**
  44093. * Define the code related to the clear coat parameters of the pbr material.
  44094. */
  44095. export class PBRClearCoatConfiguration {
  44096. /**
  44097. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44098. * The default fits with a polyurethane material.
  44099. */
  44100. private static readonly _DefaultIndiceOfRefraction;
  44101. private _isEnabled;
  44102. /**
  44103. * Defines if the clear coat is enabled in the material.
  44104. */
  44105. isEnabled: boolean;
  44106. /**
  44107. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44108. */
  44109. intensity: number;
  44110. /**
  44111. * Defines the clear coat layer roughness.
  44112. */
  44113. roughness: number;
  44114. private _indiceOfRefraction;
  44115. /**
  44116. * Defines the indice of refraction of the clear coat.
  44117. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44118. * The default fits with a polyurethane material.
  44119. * Changing the default value is more performance intensive.
  44120. */
  44121. indiceOfRefraction: number;
  44122. private _texture;
  44123. /**
  44124. * Stores the clear coat values in a texture.
  44125. */
  44126. texture: Nullable<BaseTexture>;
  44127. private _bumpTexture;
  44128. /**
  44129. * Define the clear coat specific bump texture.
  44130. */
  44131. bumpTexture: Nullable<BaseTexture>;
  44132. private _isTintEnabled;
  44133. /**
  44134. * Defines if the clear coat tint is enabled in the material.
  44135. */
  44136. isTintEnabled: boolean;
  44137. /**
  44138. * Defines the clear coat tint of the material.
  44139. * This is only use if tint is enabled
  44140. */
  44141. tintColor: Color3;
  44142. /**
  44143. * Defines the distance at which the tint color should be found in the
  44144. * clear coat media.
  44145. * This is only use if tint is enabled
  44146. */
  44147. tintColorAtDistance: number;
  44148. /**
  44149. * Defines the clear coat layer thickness.
  44150. * This is only use if tint is enabled
  44151. */
  44152. tintThickness: number;
  44153. private _tintTexture;
  44154. /**
  44155. * Stores the clear tint values in a texture.
  44156. * rgb is tint
  44157. * a is a thickness factor
  44158. */
  44159. tintTexture: Nullable<BaseTexture>;
  44160. /** @hidden */
  44161. private _internalMarkAllSubMeshesAsTexturesDirty;
  44162. /** @hidden */
  44163. _markAllSubMeshesAsTexturesDirty(): void;
  44164. /**
  44165. * Instantiate a new istance of clear coat configuration.
  44166. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44167. */
  44168. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44169. /**
  44170. * Gets wehter the submesh is ready to be used or not.
  44171. * @param defines the list of "defines" to update.
  44172. * @param scene defines the scene the material belongs to.
  44173. * @param engine defines the engine the material belongs to.
  44174. * @param disableBumpMap defines wether the material disables bump or not.
  44175. * @returns - boolean indicating that the submesh is ready or not.
  44176. */
  44177. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44178. /**
  44179. * Checks to see if a texture is used in the material.
  44180. * @param defines the list of "defines" to update.
  44181. * @param scene defines the scene to the material belongs to.
  44182. */
  44183. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44184. /**
  44185. * Binds the material data.
  44186. * @param uniformBuffer defines the Uniform buffer to fill in.
  44187. * @param scene defines the scene the material belongs to.
  44188. * @param engine defines the engine the material belongs to.
  44189. * @param disableBumpMap defines wether the material disables bump or not.
  44190. * @param isFrozen defines wether the material is frozen or not.
  44191. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44192. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44193. */
  44194. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44195. /**
  44196. * Checks to see if a texture is used in the material.
  44197. * @param texture - Base texture to use.
  44198. * @returns - Boolean specifying if a texture is used in the material.
  44199. */
  44200. hasTexture(texture: BaseTexture): boolean;
  44201. /**
  44202. * Returns an array of the actively used textures.
  44203. * @param activeTextures Array of BaseTextures
  44204. */
  44205. getActiveTextures(activeTextures: BaseTexture[]): void;
  44206. /**
  44207. * Returns the animatable textures.
  44208. * @param animatables Array of animatable textures.
  44209. */
  44210. getAnimatables(animatables: IAnimatable[]): void;
  44211. /**
  44212. * Disposes the resources of the material.
  44213. * @param forceDisposeTextures - Forces the disposal of all textures.
  44214. */
  44215. dispose(forceDisposeTextures?: boolean): void;
  44216. /**
  44217. * Get the current class name of the texture useful for serialization or dynamic coding.
  44218. * @returns "PBRClearCoatConfiguration"
  44219. */
  44220. getClassName(): string;
  44221. /**
  44222. * Add fallbacks to the effect fallbacks list.
  44223. * @param defines defines the Base texture to use.
  44224. * @param fallbacks defines the current fallback list.
  44225. * @param currentRank defines the current fallback rank.
  44226. * @returns the new fallback rank.
  44227. */
  44228. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44229. /**
  44230. * Add the required uniforms to the current list.
  44231. * @param uniforms defines the current uniform list.
  44232. */
  44233. static AddUniforms(uniforms: string[]): void;
  44234. /**
  44235. * Add the required samplers to the current list.
  44236. * @param samplers defines the current sampler list.
  44237. */
  44238. static AddSamplers(samplers: string[]): void;
  44239. /**
  44240. * Add the required uniforms to the current buffer.
  44241. * @param uniformBuffer defines the current uniform buffer.
  44242. */
  44243. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44244. /**
  44245. * Makes a duplicate of the current configuration into another one.
  44246. * @param clearCoatConfiguration define the config where to copy the info
  44247. */
  44248. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44249. /**
  44250. * Serializes this clear coat configuration.
  44251. * @returns - An object with the serialized config.
  44252. */
  44253. serialize(): any;
  44254. /**
  44255. * Parses a Clear Coat Configuration from a serialized object.
  44256. * @param source - Serialized object.
  44257. */
  44258. parse(source: any): void;
  44259. }
  44260. }
  44261. declare module BABYLON {
  44262. /**
  44263. * @hidden
  44264. */
  44265. export interface IMaterialAnisotropicDefines {
  44266. ANISOTROPIC: boolean;
  44267. ANISOTROPIC_TEXTURE: boolean;
  44268. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44269. MAINUV1: boolean;
  44270. _areTexturesDirty: boolean;
  44271. _needUVs: boolean;
  44272. }
  44273. /**
  44274. * Define the code related to the anisotropic parameters of the pbr material.
  44275. */
  44276. export class PBRAnisotropicConfiguration {
  44277. private _isEnabled;
  44278. /**
  44279. * Defines if the anisotropy is enabled in the material.
  44280. */
  44281. isEnabled: boolean;
  44282. /**
  44283. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44284. */
  44285. intensity: number;
  44286. /**
  44287. * Defines if the effect is along the tangents, bitangents or in between.
  44288. * By default, the effect is "strectching" the highlights along the tangents.
  44289. */
  44290. direction: Vector2;
  44291. private _texture;
  44292. /**
  44293. * Stores the anisotropy values in a texture.
  44294. * rg is direction (like normal from -1 to 1)
  44295. * b is a intensity
  44296. */
  44297. texture: Nullable<BaseTexture>;
  44298. /** @hidden */
  44299. private _internalMarkAllSubMeshesAsTexturesDirty;
  44300. /** @hidden */
  44301. _markAllSubMeshesAsTexturesDirty(): void;
  44302. /**
  44303. * Instantiate a new istance of anisotropy configuration.
  44304. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44305. */
  44306. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44307. /**
  44308. * Specifies that the submesh is ready to be used.
  44309. * @param defines the list of "defines" to update.
  44310. * @param scene defines the scene the material belongs to.
  44311. * @returns - boolean indicating that the submesh is ready or not.
  44312. */
  44313. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44314. /**
  44315. * Checks to see if a texture is used in the material.
  44316. * @param defines the list of "defines" to update.
  44317. * @param mesh the mesh we are preparing the defines for.
  44318. * @param scene defines the scene the material belongs to.
  44319. */
  44320. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44321. /**
  44322. * Binds the material data.
  44323. * @param uniformBuffer defines the Uniform buffer to fill in.
  44324. * @param scene defines the scene the material belongs to.
  44325. * @param isFrozen defines wether the material is frozen or not.
  44326. */
  44327. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44328. /**
  44329. * Checks to see if a texture is used in the material.
  44330. * @param texture - Base texture to use.
  44331. * @returns - Boolean specifying if a texture is used in the material.
  44332. */
  44333. hasTexture(texture: BaseTexture): boolean;
  44334. /**
  44335. * Returns an array of the actively used textures.
  44336. * @param activeTextures Array of BaseTextures
  44337. */
  44338. getActiveTextures(activeTextures: BaseTexture[]): void;
  44339. /**
  44340. * Returns the animatable textures.
  44341. * @param animatables Array of animatable textures.
  44342. */
  44343. getAnimatables(animatables: IAnimatable[]): void;
  44344. /**
  44345. * Disposes the resources of the material.
  44346. * @param forceDisposeTextures - Forces the disposal of all textures.
  44347. */
  44348. dispose(forceDisposeTextures?: boolean): void;
  44349. /**
  44350. * Get the current class name of the texture useful for serialization or dynamic coding.
  44351. * @returns "PBRAnisotropicConfiguration"
  44352. */
  44353. getClassName(): string;
  44354. /**
  44355. * Add fallbacks to the effect fallbacks list.
  44356. * @param defines defines the Base texture to use.
  44357. * @param fallbacks defines the current fallback list.
  44358. * @param currentRank defines the current fallback rank.
  44359. * @returns the new fallback rank.
  44360. */
  44361. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44362. /**
  44363. * Add the required uniforms to the current list.
  44364. * @param uniforms defines the current uniform list.
  44365. */
  44366. static AddUniforms(uniforms: string[]): void;
  44367. /**
  44368. * Add the required uniforms to the current buffer.
  44369. * @param uniformBuffer defines the current uniform buffer.
  44370. */
  44371. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44372. /**
  44373. * Add the required samplers to the current list.
  44374. * @param samplers defines the current sampler list.
  44375. */
  44376. static AddSamplers(samplers: string[]): void;
  44377. /**
  44378. * Makes a duplicate of the current configuration into another one.
  44379. * @param anisotropicConfiguration define the config where to copy the info
  44380. */
  44381. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44382. /**
  44383. * Serializes this anisotropy configuration.
  44384. * @returns - An object with the serialized config.
  44385. */
  44386. serialize(): any;
  44387. /**
  44388. * Parses a anisotropy Configuration from a serialized object.
  44389. * @param source - Serialized object.
  44390. */
  44391. parse(source: any): void;
  44392. }
  44393. }
  44394. declare module BABYLON {
  44395. /**
  44396. * @hidden
  44397. */
  44398. export interface IMaterialBRDFDefines {
  44399. BRDF_V_HEIGHT_CORRELATED: boolean;
  44400. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44401. SPHERICAL_HARMONICS: boolean;
  44402. /** @hidden */
  44403. _areMiscDirty: boolean;
  44404. }
  44405. /**
  44406. * Define the code related to the BRDF parameters of the pbr material.
  44407. */
  44408. export class PBRBRDFConfiguration {
  44409. /**
  44410. * Default value used for the energy conservation.
  44411. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44412. */
  44413. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44414. /**
  44415. * Default value used for the Smith Visibility Height Correlated mode.
  44416. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44417. */
  44418. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44419. /**
  44420. * Default value used for the IBL diffuse part.
  44421. * This can help switching back to the polynomials mode globally which is a tiny bit
  44422. * less GPU intensive at the drawback of a lower quality.
  44423. */
  44424. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44425. private _useEnergyConservation;
  44426. /**
  44427. * Defines if the material uses energy conservation.
  44428. */
  44429. useEnergyConservation: boolean;
  44430. private _useSmithVisibilityHeightCorrelated;
  44431. /**
  44432. * LEGACY Mode set to false
  44433. * Defines if the material uses height smith correlated visibility term.
  44434. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44435. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44436. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44437. * Not relying on height correlated will also disable energy conservation.
  44438. */
  44439. useSmithVisibilityHeightCorrelated: boolean;
  44440. private _useSphericalHarmonics;
  44441. /**
  44442. * LEGACY Mode set to false
  44443. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  44444. * diffuse part of the IBL.
  44445. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  44446. * to the ground truth.
  44447. */
  44448. useSphericalHarmonics: boolean;
  44449. /** @hidden */
  44450. private _internalMarkAllSubMeshesAsMiscDirty;
  44451. /** @hidden */
  44452. _markAllSubMeshesAsMiscDirty(): void;
  44453. /**
  44454. * Instantiate a new istance of clear coat configuration.
  44455. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44456. */
  44457. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44458. /**
  44459. * Checks to see if a texture is used in the material.
  44460. * @param defines the list of "defines" to update.
  44461. */
  44462. prepareDefines(defines: IMaterialBRDFDefines): void;
  44463. /**
  44464. * Get the current class name of the texture useful for serialization or dynamic coding.
  44465. * @returns "PBRClearCoatConfiguration"
  44466. */
  44467. getClassName(): string;
  44468. /**
  44469. * Makes a duplicate of the current configuration into another one.
  44470. * @param brdfConfiguration define the config where to copy the info
  44471. */
  44472. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44473. /**
  44474. * Serializes this BRDF configuration.
  44475. * @returns - An object with the serialized config.
  44476. */
  44477. serialize(): any;
  44478. /**
  44479. * Parses a BRDF Configuration from a serialized object.
  44480. * @param source - Serialized object.
  44481. */
  44482. parse(source: any): void;
  44483. }
  44484. }
  44485. declare module BABYLON {
  44486. /**
  44487. * @hidden
  44488. */
  44489. export interface IMaterialSheenDefines {
  44490. SHEEN: boolean;
  44491. SHEEN_TEXTURE: boolean;
  44492. SHEEN_TEXTUREDIRECTUV: number;
  44493. SHEEN_LINKWITHALBEDO: boolean;
  44494. /** @hidden */
  44495. _areTexturesDirty: boolean;
  44496. }
  44497. /**
  44498. * Define the code related to the Sheen parameters of the pbr material.
  44499. */
  44500. export class PBRSheenConfiguration {
  44501. private _isEnabled;
  44502. /**
  44503. * Defines if the material uses sheen.
  44504. */
  44505. isEnabled: boolean;
  44506. private _linkSheenWithAlbedo;
  44507. /**
  44508. * Defines if the sheen is linked to the sheen color.
  44509. */
  44510. linkSheenWithAlbedo: boolean;
  44511. /**
  44512. * Defines the sheen intensity.
  44513. */
  44514. intensity: number;
  44515. /**
  44516. * Defines the sheen color.
  44517. */
  44518. color: Color3;
  44519. private _texture;
  44520. /**
  44521. * Stores the sheen tint values in a texture.
  44522. * rgb is tint
  44523. * a is a intensity
  44524. */
  44525. texture: Nullable<BaseTexture>;
  44526. /** @hidden */
  44527. private _internalMarkAllSubMeshesAsTexturesDirty;
  44528. /** @hidden */
  44529. _markAllSubMeshesAsTexturesDirty(): void;
  44530. /**
  44531. * Instantiate a new istance of clear coat configuration.
  44532. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44533. */
  44534. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44535. /**
  44536. * Specifies that the submesh is ready to be used.
  44537. * @param defines the list of "defines" to update.
  44538. * @param scene defines the scene the material belongs to.
  44539. * @returns - boolean indicating that the submesh is ready or not.
  44540. */
  44541. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44542. /**
  44543. * Checks to see if a texture is used in the material.
  44544. * @param defines the list of "defines" to update.
  44545. * @param scene defines the scene the material belongs to.
  44546. */
  44547. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44548. /**
  44549. * Binds the material data.
  44550. * @param uniformBuffer defines the Uniform buffer to fill in.
  44551. * @param scene defines the scene the material belongs to.
  44552. * @param isFrozen defines wether the material is frozen or not.
  44553. */
  44554. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44555. /**
  44556. * Checks to see if a texture is used in the material.
  44557. * @param texture - Base texture to use.
  44558. * @returns - Boolean specifying if a texture is used in the material.
  44559. */
  44560. hasTexture(texture: BaseTexture): boolean;
  44561. /**
  44562. * Returns an array of the actively used textures.
  44563. * @param activeTextures Array of BaseTextures
  44564. */
  44565. getActiveTextures(activeTextures: BaseTexture[]): void;
  44566. /**
  44567. * Returns the animatable textures.
  44568. * @param animatables Array of animatable textures.
  44569. */
  44570. getAnimatables(animatables: IAnimatable[]): void;
  44571. /**
  44572. * Disposes the resources of the material.
  44573. * @param forceDisposeTextures - Forces the disposal of all textures.
  44574. */
  44575. dispose(forceDisposeTextures?: boolean): void;
  44576. /**
  44577. * Get the current class name of the texture useful for serialization or dynamic coding.
  44578. * @returns "PBRSheenConfiguration"
  44579. */
  44580. getClassName(): string;
  44581. /**
  44582. * Add fallbacks to the effect fallbacks list.
  44583. * @param defines defines the Base texture to use.
  44584. * @param fallbacks defines the current fallback list.
  44585. * @param currentRank defines the current fallback rank.
  44586. * @returns the new fallback rank.
  44587. */
  44588. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44589. /**
  44590. * Add the required uniforms to the current list.
  44591. * @param uniforms defines the current uniform list.
  44592. */
  44593. static AddUniforms(uniforms: string[]): void;
  44594. /**
  44595. * Add the required uniforms to the current buffer.
  44596. * @param uniformBuffer defines the current uniform buffer.
  44597. */
  44598. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44599. /**
  44600. * Add the required samplers to the current list.
  44601. * @param samplers defines the current sampler list.
  44602. */
  44603. static AddSamplers(samplers: string[]): void;
  44604. /**
  44605. * Makes a duplicate of the current configuration into another one.
  44606. * @param sheenConfiguration define the config where to copy the info
  44607. */
  44608. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44609. /**
  44610. * Serializes this BRDF configuration.
  44611. * @returns - An object with the serialized config.
  44612. */
  44613. serialize(): any;
  44614. /**
  44615. * Parses a Sheen Configuration from a serialized object.
  44616. * @param source - Serialized object.
  44617. */
  44618. parse(source: any): void;
  44619. }
  44620. }
  44621. declare module BABYLON {
  44622. /**
  44623. * @hidden
  44624. */
  44625. export interface IMaterialSubSurfaceDefines {
  44626. SUBSURFACE: boolean;
  44627. SS_REFRACTION: boolean;
  44628. SS_TRANSLUCENCY: boolean;
  44629. SS_SCATERRING: boolean;
  44630. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44631. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44632. SS_REFRACTIONMAP_3D: boolean;
  44633. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44634. SS_LODINREFRACTIONALPHA: boolean;
  44635. SS_GAMMAREFRACTION: boolean;
  44636. SS_RGBDREFRACTION: boolean;
  44637. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44638. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44639. /** @hidden */
  44640. _areTexturesDirty: boolean;
  44641. }
  44642. /**
  44643. * Define the code related to the sub surface parameters of the pbr material.
  44644. */
  44645. export class PBRSubSurfaceConfiguration {
  44646. private _isRefractionEnabled;
  44647. /**
  44648. * Defines if the refraction is enabled in the material.
  44649. */
  44650. isRefractionEnabled: boolean;
  44651. private _isTranslucencyEnabled;
  44652. /**
  44653. * Defines if the translucency is enabled in the material.
  44654. */
  44655. isTranslucencyEnabled: boolean;
  44656. private _isScatteringEnabled;
  44657. /**
  44658. * Defines the refraction intensity of the material.
  44659. * The refraction when enabled replaces the Diffuse part of the material.
  44660. * The intensity helps transitionning between diffuse and refraction.
  44661. */
  44662. refractionIntensity: number;
  44663. /**
  44664. * Defines the translucency intensity of the material.
  44665. * When translucency has been enabled, this defines how much of the "translucency"
  44666. * is addded to the diffuse part of the material.
  44667. */
  44668. translucencyIntensity: number;
  44669. /**
  44670. * Defines the scattering intensity of the material.
  44671. * When scattering has been enabled, this defines how much of the "scattered light"
  44672. * is addded to the diffuse part of the material.
  44673. */
  44674. scatteringIntensity: number;
  44675. private _thicknessTexture;
  44676. /**
  44677. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  44678. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  44679. * 0 would mean minimumThickness
  44680. * 1 would mean maximumThickness
  44681. * The other channels might be use as a mask to vary the different effects intensity.
  44682. */
  44683. thicknessTexture: Nullable<BaseTexture>;
  44684. private _refractionTexture;
  44685. /**
  44686. * Defines the texture to use for refraction.
  44687. */
  44688. refractionTexture: Nullable<BaseTexture>;
  44689. private _indexOfRefraction;
  44690. /**
  44691. * Defines the indice of refraction used in the material.
  44692. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  44693. */
  44694. indexOfRefraction: number;
  44695. private _invertRefractionY;
  44696. /**
  44697. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44698. */
  44699. invertRefractionY: boolean;
  44700. private _linkRefractionWithTransparency;
  44701. /**
  44702. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44703. * Materials half opaque for instance using refraction could benefit from this control.
  44704. */
  44705. linkRefractionWithTransparency: boolean;
  44706. /**
  44707. * Defines the minimum thickness stored in the thickness map.
  44708. * If no thickness map is defined, this value will be used to simulate thickness.
  44709. */
  44710. minimumThickness: number;
  44711. /**
  44712. * Defines the maximum thickness stored in the thickness map.
  44713. */
  44714. maximumThickness: number;
  44715. /**
  44716. * Defines the volume tint of the material.
  44717. * This is used for both translucency and scattering.
  44718. */
  44719. tintColor: Color3;
  44720. /**
  44721. * Defines the distance at which the tint color should be found in the media.
  44722. * This is used for refraction only.
  44723. */
  44724. tintColorAtDistance: number;
  44725. /**
  44726. * Defines how far each channel transmit through the media.
  44727. * It is defined as a color to simplify it selection.
  44728. */
  44729. diffusionDistance: Color3;
  44730. private _useMaskFromThicknessTexture;
  44731. /**
  44732. * Stores the intensity of the different subsurface effects in the thickness texture.
  44733. * * the green channel is the translucency intensity.
  44734. * * the blue channel is the scattering intensity.
  44735. * * the alpha channel is the refraction intensity.
  44736. */
  44737. useMaskFromThicknessTexture: boolean;
  44738. /** @hidden */
  44739. private _internalMarkAllSubMeshesAsTexturesDirty;
  44740. /** @hidden */
  44741. _markAllSubMeshesAsTexturesDirty(): void;
  44742. /**
  44743. * Instantiate a new istance of sub surface configuration.
  44744. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44745. */
  44746. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44747. /**
  44748. * Gets wehter the submesh is ready to be used or not.
  44749. * @param defines the list of "defines" to update.
  44750. * @param scene defines the scene the material belongs to.
  44751. * @returns - boolean indicating that the submesh is ready or not.
  44752. */
  44753. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  44754. /**
  44755. * Checks to see if a texture is used in the material.
  44756. * @param defines the list of "defines" to update.
  44757. * @param scene defines the scene to the material belongs to.
  44758. */
  44759. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  44760. /**
  44761. * Binds the material data.
  44762. * @param uniformBuffer defines the Uniform buffer to fill in.
  44763. * @param scene defines the scene the material belongs to.
  44764. * @param engine defines the engine the material belongs to.
  44765. * @param isFrozen defines wether the material is frozen or not.
  44766. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  44767. */
  44768. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  44769. /**
  44770. * Unbinds the material from the mesh.
  44771. * @param activeEffect defines the effect that should be unbound from.
  44772. * @returns true if unbound, otherwise false
  44773. */
  44774. unbind(activeEffect: Effect): boolean;
  44775. /**
  44776. * Returns the texture used for refraction or null if none is used.
  44777. * @param scene defines the scene the material belongs to.
  44778. * @returns - Refraction texture if present. If no refraction texture and refraction
  44779. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44780. */
  44781. private _getRefractionTexture;
  44782. /**
  44783. * Returns true if alpha blending should be disabled.
  44784. */
  44785. readonly disableAlphaBlending: boolean;
  44786. /**
  44787. * Fills the list of render target textures.
  44788. * @param renderTargets the list of render targets to update
  44789. */
  44790. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44791. /**
  44792. * Checks to see if a texture is used in the material.
  44793. * @param texture - Base texture to use.
  44794. * @returns - Boolean specifying if a texture is used in the material.
  44795. */
  44796. hasTexture(texture: BaseTexture): boolean;
  44797. /**
  44798. * Gets a boolean indicating that current material needs to register RTT
  44799. * @returns true if this uses a render target otherwise false.
  44800. */
  44801. hasRenderTargetTextures(): boolean;
  44802. /**
  44803. * Returns an array of the actively used textures.
  44804. * @param activeTextures Array of BaseTextures
  44805. */
  44806. getActiveTextures(activeTextures: BaseTexture[]): void;
  44807. /**
  44808. * Returns the animatable textures.
  44809. * @param animatables Array of animatable textures.
  44810. */
  44811. getAnimatables(animatables: IAnimatable[]): void;
  44812. /**
  44813. * Disposes the resources of the material.
  44814. * @param forceDisposeTextures - Forces the disposal of all textures.
  44815. */
  44816. dispose(forceDisposeTextures?: boolean): void;
  44817. /**
  44818. * Get the current class name of the texture useful for serialization or dynamic coding.
  44819. * @returns "PBRSubSurfaceConfiguration"
  44820. */
  44821. getClassName(): string;
  44822. /**
  44823. * Add fallbacks to the effect fallbacks list.
  44824. * @param defines defines the Base texture to use.
  44825. * @param fallbacks defines the current fallback list.
  44826. * @param currentRank defines the current fallback rank.
  44827. * @returns the new fallback rank.
  44828. */
  44829. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44830. /**
  44831. * Add the required uniforms to the current list.
  44832. * @param uniforms defines the current uniform list.
  44833. */
  44834. static AddUniforms(uniforms: string[]): void;
  44835. /**
  44836. * Add the required samplers to the current list.
  44837. * @param samplers defines the current sampler list.
  44838. */
  44839. static AddSamplers(samplers: string[]): void;
  44840. /**
  44841. * Add the required uniforms to the current buffer.
  44842. * @param uniformBuffer defines the current uniform buffer.
  44843. */
  44844. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44845. /**
  44846. * Makes a duplicate of the current configuration into another one.
  44847. * @param configuration define the config where to copy the info
  44848. */
  44849. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44850. /**
  44851. * Serializes this Sub Surface configuration.
  44852. * @returns - An object with the serialized config.
  44853. */
  44854. serialize(): any;
  44855. /**
  44856. * Parses a Sub Surface Configuration from a serialized object.
  44857. * @param source - Serialized object.
  44858. */
  44859. parse(source: any): void;
  44860. }
  44861. }
  44862. declare module BABYLON {
  44863. /** @hidden */
  44864. export var pbrFragmentDeclaration: {
  44865. name: string;
  44866. shader: string;
  44867. };
  44868. }
  44869. declare module BABYLON {
  44870. /** @hidden */
  44871. export var pbrUboDeclaration: {
  44872. name: string;
  44873. shader: string;
  44874. };
  44875. }
  44876. declare module BABYLON {
  44877. /** @hidden */
  44878. export var pbrFragmentExtraDeclaration: {
  44879. name: string;
  44880. shader: string;
  44881. };
  44882. }
  44883. declare module BABYLON {
  44884. /** @hidden */
  44885. export var pbrFragmentSamplersDeclaration: {
  44886. name: string;
  44887. shader: string;
  44888. };
  44889. }
  44890. declare module BABYLON {
  44891. /** @hidden */
  44892. export var pbrHelperFunctions: {
  44893. name: string;
  44894. shader: string;
  44895. };
  44896. }
  44897. declare module BABYLON {
  44898. /** @hidden */
  44899. export var harmonicsFunctions: {
  44900. name: string;
  44901. shader: string;
  44902. };
  44903. }
  44904. declare module BABYLON {
  44905. /** @hidden */
  44906. export var pbrDirectLightingSetupFunctions: {
  44907. name: string;
  44908. shader: string;
  44909. };
  44910. }
  44911. declare module BABYLON {
  44912. /** @hidden */
  44913. export var pbrDirectLightingFalloffFunctions: {
  44914. name: string;
  44915. shader: string;
  44916. };
  44917. }
  44918. declare module BABYLON {
  44919. /** @hidden */
  44920. export var pbrBRDFFunctions: {
  44921. name: string;
  44922. shader: string;
  44923. };
  44924. }
  44925. declare module BABYLON {
  44926. /** @hidden */
  44927. export var pbrDirectLightingFunctions: {
  44928. name: string;
  44929. shader: string;
  44930. };
  44931. }
  44932. declare module BABYLON {
  44933. /** @hidden */
  44934. export var pbrIBLFunctions: {
  44935. name: string;
  44936. shader: string;
  44937. };
  44938. }
  44939. declare module BABYLON {
  44940. /** @hidden */
  44941. export var pbrDebug: {
  44942. name: string;
  44943. shader: string;
  44944. };
  44945. }
  44946. declare module BABYLON {
  44947. /** @hidden */
  44948. export var pbrPixelShader: {
  44949. name: string;
  44950. shader: string;
  44951. };
  44952. }
  44953. declare module BABYLON {
  44954. /** @hidden */
  44955. export var pbrVertexDeclaration: {
  44956. name: string;
  44957. shader: string;
  44958. };
  44959. }
  44960. declare module BABYLON {
  44961. /** @hidden */
  44962. export var pbrVertexShader: {
  44963. name: string;
  44964. shader: string;
  44965. };
  44966. }
  44967. declare module BABYLON {
  44968. /**
  44969. * Manages the defines for the PBR Material.
  44970. * @hidden
  44971. */
  44972. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44973. PBR: boolean;
  44974. MAINUV1: boolean;
  44975. MAINUV2: boolean;
  44976. UV1: boolean;
  44977. UV2: boolean;
  44978. ALBEDO: boolean;
  44979. ALBEDODIRECTUV: number;
  44980. VERTEXCOLOR: boolean;
  44981. AMBIENT: boolean;
  44982. AMBIENTDIRECTUV: number;
  44983. AMBIENTINGRAYSCALE: boolean;
  44984. OPACITY: boolean;
  44985. VERTEXALPHA: boolean;
  44986. OPACITYDIRECTUV: number;
  44987. OPACITYRGB: boolean;
  44988. ALPHATEST: boolean;
  44989. DEPTHPREPASS: boolean;
  44990. ALPHABLEND: boolean;
  44991. ALPHAFROMALBEDO: boolean;
  44992. ALPHATESTVALUE: string;
  44993. SPECULAROVERALPHA: boolean;
  44994. RADIANCEOVERALPHA: boolean;
  44995. ALPHAFRESNEL: boolean;
  44996. LINEARALPHAFRESNEL: boolean;
  44997. PREMULTIPLYALPHA: boolean;
  44998. EMISSIVE: boolean;
  44999. EMISSIVEDIRECTUV: number;
  45000. REFLECTIVITY: boolean;
  45001. REFLECTIVITYDIRECTUV: number;
  45002. SPECULARTERM: boolean;
  45003. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45004. MICROSURFACEAUTOMATIC: boolean;
  45005. LODBASEDMICROSFURACE: boolean;
  45006. MICROSURFACEMAP: boolean;
  45007. MICROSURFACEMAPDIRECTUV: number;
  45008. METALLICWORKFLOW: boolean;
  45009. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45010. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45011. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45012. AOSTOREINMETALMAPRED: boolean;
  45013. ENVIRONMENTBRDF: boolean;
  45014. ENVIRONMENTBRDF_RGBD: boolean;
  45015. NORMAL: boolean;
  45016. TANGENT: boolean;
  45017. BUMP: boolean;
  45018. BUMPDIRECTUV: number;
  45019. OBJECTSPACE_NORMALMAP: boolean;
  45020. PARALLAX: boolean;
  45021. PARALLAXOCCLUSION: boolean;
  45022. NORMALXYSCALE: boolean;
  45023. LIGHTMAP: boolean;
  45024. LIGHTMAPDIRECTUV: number;
  45025. USELIGHTMAPASSHADOWMAP: boolean;
  45026. GAMMALIGHTMAP: boolean;
  45027. REFLECTION: boolean;
  45028. REFLECTIONMAP_3D: boolean;
  45029. REFLECTIONMAP_SPHERICAL: boolean;
  45030. REFLECTIONMAP_PLANAR: boolean;
  45031. REFLECTIONMAP_CUBIC: boolean;
  45032. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45033. REFLECTIONMAP_PROJECTION: boolean;
  45034. REFLECTIONMAP_SKYBOX: boolean;
  45035. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45036. REFLECTIONMAP_EXPLICIT: boolean;
  45037. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45038. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45039. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45040. INVERTCUBICMAP: boolean;
  45041. USESPHERICALFROMREFLECTIONMAP: boolean;
  45042. SPHERICAL_HARMONICS: boolean;
  45043. USESPHERICALINVERTEX: boolean;
  45044. REFLECTIONMAP_OPPOSITEZ: boolean;
  45045. LODINREFLECTIONALPHA: boolean;
  45046. GAMMAREFLECTION: boolean;
  45047. RGBDREFLECTION: boolean;
  45048. RADIANCEOCCLUSION: boolean;
  45049. HORIZONOCCLUSION: boolean;
  45050. INSTANCES: boolean;
  45051. NUM_BONE_INFLUENCERS: number;
  45052. BonesPerMesh: number;
  45053. BONETEXTURE: boolean;
  45054. NONUNIFORMSCALING: boolean;
  45055. MORPHTARGETS: boolean;
  45056. MORPHTARGETS_NORMAL: boolean;
  45057. MORPHTARGETS_TANGENT: boolean;
  45058. NUM_MORPH_INFLUENCERS: number;
  45059. IMAGEPROCESSING: boolean;
  45060. VIGNETTE: boolean;
  45061. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45062. VIGNETTEBLENDMODEOPAQUE: boolean;
  45063. TONEMAPPING: boolean;
  45064. TONEMAPPING_ACES: boolean;
  45065. CONTRAST: boolean;
  45066. COLORCURVES: boolean;
  45067. COLORGRADING: boolean;
  45068. COLORGRADING3D: boolean;
  45069. SAMPLER3DGREENDEPTH: boolean;
  45070. SAMPLER3DBGRMAP: boolean;
  45071. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45072. EXPOSURE: boolean;
  45073. MULTIVIEW: boolean;
  45074. USEPHYSICALLIGHTFALLOFF: boolean;
  45075. USEGLTFLIGHTFALLOFF: boolean;
  45076. TWOSIDEDLIGHTING: boolean;
  45077. SHADOWFLOAT: boolean;
  45078. CLIPPLANE: boolean;
  45079. CLIPPLANE2: boolean;
  45080. CLIPPLANE3: boolean;
  45081. CLIPPLANE4: boolean;
  45082. POINTSIZE: boolean;
  45083. FOG: boolean;
  45084. LOGARITHMICDEPTH: boolean;
  45085. FORCENORMALFORWARD: boolean;
  45086. SPECULARAA: boolean;
  45087. CLEARCOAT: boolean;
  45088. CLEARCOAT_DEFAULTIOR: boolean;
  45089. CLEARCOAT_TEXTURE: boolean;
  45090. CLEARCOAT_TEXTUREDIRECTUV: number;
  45091. CLEARCOAT_BUMP: boolean;
  45092. CLEARCOAT_BUMPDIRECTUV: number;
  45093. CLEARCOAT_TINT: boolean;
  45094. CLEARCOAT_TINT_TEXTURE: boolean;
  45095. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45096. ANISOTROPIC: boolean;
  45097. ANISOTROPIC_TEXTURE: boolean;
  45098. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45099. BRDF_V_HEIGHT_CORRELATED: boolean;
  45100. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45101. SHEEN: boolean;
  45102. SHEEN_TEXTURE: boolean;
  45103. SHEEN_TEXTUREDIRECTUV: number;
  45104. SHEEN_LINKWITHALBEDO: boolean;
  45105. SUBSURFACE: boolean;
  45106. SS_REFRACTION: boolean;
  45107. SS_TRANSLUCENCY: boolean;
  45108. SS_SCATERRING: boolean;
  45109. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45110. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45111. SS_REFRACTIONMAP_3D: boolean;
  45112. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45113. SS_LODINREFRACTIONALPHA: boolean;
  45114. SS_GAMMAREFRACTION: boolean;
  45115. SS_RGBDREFRACTION: boolean;
  45116. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45117. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45118. UNLIT: boolean;
  45119. DEBUGMODE: number;
  45120. /**
  45121. * Initializes the PBR Material defines.
  45122. */
  45123. constructor();
  45124. /**
  45125. * Resets the PBR Material defines.
  45126. */
  45127. reset(): void;
  45128. }
  45129. /**
  45130. * The Physically based material base class of BJS.
  45131. *
  45132. * This offers the main features of a standard PBR material.
  45133. * For more information, please refer to the documentation :
  45134. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45135. */
  45136. export abstract class PBRBaseMaterial extends PushMaterial {
  45137. /**
  45138. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45139. */
  45140. static readonly PBRMATERIAL_OPAQUE: number;
  45141. /**
  45142. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45143. */
  45144. static readonly PBRMATERIAL_ALPHATEST: number;
  45145. /**
  45146. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45147. */
  45148. static readonly PBRMATERIAL_ALPHABLEND: number;
  45149. /**
  45150. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45151. * They are also discarded below the alpha cutoff threshold to improve performances.
  45152. */
  45153. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45154. /**
  45155. * Defines the default value of how much AO map is occluding the analytical lights
  45156. * (point spot...).
  45157. */
  45158. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45159. /**
  45160. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45161. */
  45162. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45163. /**
  45164. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45165. * to enhance interoperability with other engines.
  45166. */
  45167. static readonly LIGHTFALLOFF_GLTF: number;
  45168. /**
  45169. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45170. * to enhance interoperability with other materials.
  45171. */
  45172. static readonly LIGHTFALLOFF_STANDARD: number;
  45173. /**
  45174. * Intensity of the direct lights e.g. the four lights available in your scene.
  45175. * This impacts both the direct diffuse and specular highlights.
  45176. */
  45177. protected _directIntensity: number;
  45178. /**
  45179. * Intensity of the emissive part of the material.
  45180. * This helps controlling the emissive effect without modifying the emissive color.
  45181. */
  45182. protected _emissiveIntensity: number;
  45183. /**
  45184. * Intensity of the environment e.g. how much the environment will light the object
  45185. * either through harmonics for rough material or through the refelction for shiny ones.
  45186. */
  45187. protected _environmentIntensity: number;
  45188. /**
  45189. * This is a special control allowing the reduction of the specular highlights coming from the
  45190. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45191. */
  45192. protected _specularIntensity: number;
  45193. /**
  45194. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45195. */
  45196. private _lightingInfos;
  45197. /**
  45198. * Debug Control allowing disabling the bump map on this material.
  45199. */
  45200. protected _disableBumpMap: boolean;
  45201. /**
  45202. * AKA Diffuse Texture in standard nomenclature.
  45203. */
  45204. protected _albedoTexture: Nullable<BaseTexture>;
  45205. /**
  45206. * AKA Occlusion Texture in other nomenclature.
  45207. */
  45208. protected _ambientTexture: Nullable<BaseTexture>;
  45209. /**
  45210. * AKA Occlusion Texture Intensity in other nomenclature.
  45211. */
  45212. protected _ambientTextureStrength: number;
  45213. /**
  45214. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45215. * 1 means it completely occludes it
  45216. * 0 mean it has no impact
  45217. */
  45218. protected _ambientTextureImpactOnAnalyticalLights: number;
  45219. /**
  45220. * Stores the alpha values in a texture.
  45221. */
  45222. protected _opacityTexture: Nullable<BaseTexture>;
  45223. /**
  45224. * Stores the reflection values in a texture.
  45225. */
  45226. protected _reflectionTexture: Nullable<BaseTexture>;
  45227. /**
  45228. * Stores the emissive values in a texture.
  45229. */
  45230. protected _emissiveTexture: Nullable<BaseTexture>;
  45231. /**
  45232. * AKA Specular texture in other nomenclature.
  45233. */
  45234. protected _reflectivityTexture: Nullable<BaseTexture>;
  45235. /**
  45236. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45237. */
  45238. protected _metallicTexture: Nullable<BaseTexture>;
  45239. /**
  45240. * Specifies the metallic scalar of the metallic/roughness workflow.
  45241. * Can also be used to scale the metalness values of the metallic texture.
  45242. */
  45243. protected _metallic: Nullable<number>;
  45244. /**
  45245. * Specifies the roughness scalar of the metallic/roughness workflow.
  45246. * Can also be used to scale the roughness values of the metallic texture.
  45247. */
  45248. protected _roughness: Nullable<number>;
  45249. /**
  45250. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45251. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45252. */
  45253. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45254. /**
  45255. * Stores surface normal data used to displace a mesh in a texture.
  45256. */
  45257. protected _bumpTexture: Nullable<BaseTexture>;
  45258. /**
  45259. * Stores the pre-calculated light information of a mesh in a texture.
  45260. */
  45261. protected _lightmapTexture: Nullable<BaseTexture>;
  45262. /**
  45263. * The color of a material in ambient lighting.
  45264. */
  45265. protected _ambientColor: Color3;
  45266. /**
  45267. * AKA Diffuse Color in other nomenclature.
  45268. */
  45269. protected _albedoColor: Color3;
  45270. /**
  45271. * AKA Specular Color in other nomenclature.
  45272. */
  45273. protected _reflectivityColor: Color3;
  45274. /**
  45275. * The color applied when light is reflected from a material.
  45276. */
  45277. protected _reflectionColor: Color3;
  45278. /**
  45279. * The color applied when light is emitted from a material.
  45280. */
  45281. protected _emissiveColor: Color3;
  45282. /**
  45283. * AKA Glossiness in other nomenclature.
  45284. */
  45285. protected _microSurface: number;
  45286. /**
  45287. * Specifies that the material will use the light map as a show map.
  45288. */
  45289. protected _useLightmapAsShadowmap: boolean;
  45290. /**
  45291. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45292. * makes the reflect vector face the model (under horizon).
  45293. */
  45294. protected _useHorizonOcclusion: boolean;
  45295. /**
  45296. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45297. * too much the area relying on ambient texture to define their ambient occlusion.
  45298. */
  45299. protected _useRadianceOcclusion: boolean;
  45300. /**
  45301. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45302. */
  45303. protected _useAlphaFromAlbedoTexture: boolean;
  45304. /**
  45305. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45306. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45307. */
  45308. protected _useSpecularOverAlpha: boolean;
  45309. /**
  45310. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45311. */
  45312. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45313. /**
  45314. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45315. */
  45316. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45317. /**
  45318. * Specifies if the metallic texture contains the roughness information in its green channel.
  45319. */
  45320. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45321. /**
  45322. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45323. */
  45324. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45325. /**
  45326. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45327. */
  45328. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45329. /**
  45330. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45331. */
  45332. protected _useAmbientInGrayScale: boolean;
  45333. /**
  45334. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45335. * The material will try to infer what glossiness each pixel should be.
  45336. */
  45337. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45338. /**
  45339. * Defines the falloff type used in this material.
  45340. * It by default is Physical.
  45341. */
  45342. protected _lightFalloff: number;
  45343. /**
  45344. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45345. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45346. */
  45347. protected _useRadianceOverAlpha: boolean;
  45348. /**
  45349. * Allows using an object space normal map (instead of tangent space).
  45350. */
  45351. protected _useObjectSpaceNormalMap: boolean;
  45352. /**
  45353. * Allows using the bump map in parallax mode.
  45354. */
  45355. protected _useParallax: boolean;
  45356. /**
  45357. * Allows using the bump map in parallax occlusion mode.
  45358. */
  45359. protected _useParallaxOcclusion: boolean;
  45360. /**
  45361. * Controls the scale bias of the parallax mode.
  45362. */
  45363. protected _parallaxScaleBias: number;
  45364. /**
  45365. * If sets to true, disables all the lights affecting the material.
  45366. */
  45367. protected _disableLighting: boolean;
  45368. /**
  45369. * Number of Simultaneous lights allowed on the material.
  45370. */
  45371. protected _maxSimultaneousLights: number;
  45372. /**
  45373. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45374. */
  45375. protected _invertNormalMapX: boolean;
  45376. /**
  45377. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45378. */
  45379. protected _invertNormalMapY: boolean;
  45380. /**
  45381. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45382. */
  45383. protected _twoSidedLighting: boolean;
  45384. /**
  45385. * Defines the alpha limits in alpha test mode.
  45386. */
  45387. protected _alphaCutOff: number;
  45388. /**
  45389. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45390. */
  45391. protected _forceAlphaTest: boolean;
  45392. /**
  45393. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45394. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45395. */
  45396. protected _useAlphaFresnel: boolean;
  45397. /**
  45398. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45399. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45400. */
  45401. protected _useLinearAlphaFresnel: boolean;
  45402. /**
  45403. * The transparency mode of the material.
  45404. */
  45405. protected _transparencyMode: Nullable<number>;
  45406. /**
  45407. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45408. * from cos thetav and roughness:
  45409. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45410. */
  45411. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45412. /**
  45413. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45414. */
  45415. protected _forceIrradianceInFragment: boolean;
  45416. /**
  45417. * Force normal to face away from face.
  45418. */
  45419. protected _forceNormalForward: boolean;
  45420. /**
  45421. * Enables specular anti aliasing in the PBR shader.
  45422. * It will both interacts on the Geometry for analytical and IBL lighting.
  45423. * It also prefilter the roughness map based on the bump values.
  45424. */
  45425. protected _enableSpecularAntiAliasing: boolean;
  45426. /**
  45427. * Default configuration related to image processing available in the PBR Material.
  45428. */
  45429. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45430. /**
  45431. * Keep track of the image processing observer to allow dispose and replace.
  45432. */
  45433. private _imageProcessingObserver;
  45434. /**
  45435. * Attaches a new image processing configuration to the PBR Material.
  45436. * @param configuration
  45437. */
  45438. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45439. /**
  45440. * Stores the available render targets.
  45441. */
  45442. private _renderTargets;
  45443. /**
  45444. * Sets the global ambient color for the material used in lighting calculations.
  45445. */
  45446. private _globalAmbientColor;
  45447. /**
  45448. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45449. */
  45450. private _useLogarithmicDepth;
  45451. /**
  45452. * If set to true, no lighting calculations will be applied.
  45453. */
  45454. private _unlit;
  45455. private _debugMode;
  45456. /**
  45457. * @hidden
  45458. * This is reserved for the inspector.
  45459. * Defines the material debug mode.
  45460. * It helps seeing only some components of the material while troubleshooting.
  45461. */
  45462. debugMode: number;
  45463. /**
  45464. * @hidden
  45465. * This is reserved for the inspector.
  45466. * Specify from where on screen the debug mode should start.
  45467. * The value goes from -1 (full screen) to 1 (not visible)
  45468. * It helps with side by side comparison against the final render
  45469. * This defaults to -1
  45470. */
  45471. private debugLimit;
  45472. /**
  45473. * @hidden
  45474. * This is reserved for the inspector.
  45475. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45476. * You can use the factor to better multiply the final value.
  45477. */
  45478. private debugFactor;
  45479. /**
  45480. * Defines the clear coat layer parameters for the material.
  45481. */
  45482. readonly clearCoat: PBRClearCoatConfiguration;
  45483. /**
  45484. * Defines the anisotropic parameters for the material.
  45485. */
  45486. readonly anisotropy: PBRAnisotropicConfiguration;
  45487. /**
  45488. * Defines the BRDF parameters for the material.
  45489. */
  45490. readonly brdf: PBRBRDFConfiguration;
  45491. /**
  45492. * Defines the Sheen parameters for the material.
  45493. */
  45494. readonly sheen: PBRSheenConfiguration;
  45495. /**
  45496. * Defines the SubSurface parameters for the material.
  45497. */
  45498. readonly subSurface: PBRSubSurfaceConfiguration;
  45499. /**
  45500. * Custom callback helping to override the default shader used in the material.
  45501. */
  45502. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45503. /**
  45504. * Instantiates a new PBRMaterial instance.
  45505. *
  45506. * @param name The material name
  45507. * @param scene The scene the material will be use in.
  45508. */
  45509. constructor(name: string, scene: Scene);
  45510. /**
  45511. * Gets a boolean indicating that current material needs to register RTT
  45512. */
  45513. readonly hasRenderTargetTextures: boolean;
  45514. /**
  45515. * Gets the name of the material class.
  45516. */
  45517. getClassName(): string;
  45518. /**
  45519. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45520. */
  45521. /**
  45522. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45523. */
  45524. useLogarithmicDepth: boolean;
  45525. /**
  45526. * Gets the current transparency mode.
  45527. */
  45528. /**
  45529. * Sets the transparency mode of the material.
  45530. *
  45531. * | Value | Type | Description |
  45532. * | ----- | ----------------------------------- | ----------- |
  45533. * | 0 | OPAQUE | |
  45534. * | 1 | ALPHATEST | |
  45535. * | 2 | ALPHABLEND | |
  45536. * | 3 | ALPHATESTANDBLEND | |
  45537. *
  45538. */
  45539. transparencyMode: Nullable<number>;
  45540. /**
  45541. * Returns true if alpha blending should be disabled.
  45542. */
  45543. private readonly _disableAlphaBlending;
  45544. /**
  45545. * Specifies whether or not this material should be rendered in alpha blend mode.
  45546. */
  45547. needAlphaBlending(): boolean;
  45548. /**
  45549. * Specifies if the mesh will require alpha blending.
  45550. * @param mesh - BJS mesh.
  45551. */
  45552. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45553. /**
  45554. * Specifies whether or not this material should be rendered in alpha test mode.
  45555. */
  45556. needAlphaTesting(): boolean;
  45557. /**
  45558. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45559. */
  45560. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45561. /**
  45562. * Gets the texture used for the alpha test.
  45563. */
  45564. getAlphaTestTexture(): Nullable<BaseTexture>;
  45565. /**
  45566. * Specifies that the submesh is ready to be used.
  45567. * @param mesh - BJS mesh.
  45568. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45569. * @param useInstances - Specifies that instances should be used.
  45570. * @returns - boolean indicating that the submesh is ready or not.
  45571. */
  45572. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45573. /**
  45574. * Specifies if the material uses metallic roughness workflow.
  45575. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45576. */
  45577. isMetallicWorkflow(): boolean;
  45578. private _prepareEffect;
  45579. private _prepareDefines;
  45580. /**
  45581. * Force shader compilation
  45582. */
  45583. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45584. clipPlane: boolean;
  45585. }>): void;
  45586. /**
  45587. * Initializes the uniform buffer layout for the shader.
  45588. */
  45589. buildUniformLayout(): void;
  45590. /**
  45591. * Unbinds the material from the mesh
  45592. */
  45593. unbind(): void;
  45594. /**
  45595. * Binds the submesh data.
  45596. * @param world - The world matrix.
  45597. * @param mesh - The BJS mesh.
  45598. * @param subMesh - A submesh of the BJS mesh.
  45599. */
  45600. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45601. /**
  45602. * Returns the animatable textures.
  45603. * @returns - Array of animatable textures.
  45604. */
  45605. getAnimatables(): IAnimatable[];
  45606. /**
  45607. * Returns the texture used for reflections.
  45608. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45609. */
  45610. private _getReflectionTexture;
  45611. /**
  45612. * Returns an array of the actively used textures.
  45613. * @returns - Array of BaseTextures
  45614. */
  45615. getActiveTextures(): BaseTexture[];
  45616. /**
  45617. * Checks to see if a texture is used in the material.
  45618. * @param texture - Base texture to use.
  45619. * @returns - Boolean specifying if a texture is used in the material.
  45620. */
  45621. hasTexture(texture: BaseTexture): boolean;
  45622. /**
  45623. * Disposes the resources of the material.
  45624. * @param forceDisposeEffect - Forces the disposal of effects.
  45625. * @param forceDisposeTextures - Forces the disposal of all textures.
  45626. */
  45627. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45628. }
  45629. }
  45630. declare module BABYLON {
  45631. /**
  45632. * The Physically based material of BJS.
  45633. *
  45634. * This offers the main features of a standard PBR material.
  45635. * For more information, please refer to the documentation :
  45636. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45637. */
  45638. export class PBRMaterial extends PBRBaseMaterial {
  45639. /**
  45640. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45641. */
  45642. static readonly PBRMATERIAL_OPAQUE: number;
  45643. /**
  45644. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45645. */
  45646. static readonly PBRMATERIAL_ALPHATEST: number;
  45647. /**
  45648. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45649. */
  45650. static readonly PBRMATERIAL_ALPHABLEND: number;
  45651. /**
  45652. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45653. * They are also discarded below the alpha cutoff threshold to improve performances.
  45654. */
  45655. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45656. /**
  45657. * Defines the default value of how much AO map is occluding the analytical lights
  45658. * (point spot...).
  45659. */
  45660. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45661. /**
  45662. * Intensity of the direct lights e.g. the four lights available in your scene.
  45663. * This impacts both the direct diffuse and specular highlights.
  45664. */
  45665. directIntensity: number;
  45666. /**
  45667. * Intensity of the emissive part of the material.
  45668. * This helps controlling the emissive effect without modifying the emissive color.
  45669. */
  45670. emissiveIntensity: number;
  45671. /**
  45672. * Intensity of the environment e.g. how much the environment will light the object
  45673. * either through harmonics for rough material or through the refelction for shiny ones.
  45674. */
  45675. environmentIntensity: number;
  45676. /**
  45677. * This is a special control allowing the reduction of the specular highlights coming from the
  45678. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45679. */
  45680. specularIntensity: number;
  45681. /**
  45682. * Debug Control allowing disabling the bump map on this material.
  45683. */
  45684. disableBumpMap: boolean;
  45685. /**
  45686. * AKA Diffuse Texture in standard nomenclature.
  45687. */
  45688. albedoTexture: BaseTexture;
  45689. /**
  45690. * AKA Occlusion Texture in other nomenclature.
  45691. */
  45692. ambientTexture: BaseTexture;
  45693. /**
  45694. * AKA Occlusion Texture Intensity in other nomenclature.
  45695. */
  45696. ambientTextureStrength: number;
  45697. /**
  45698. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45699. * 1 means it completely occludes it
  45700. * 0 mean it has no impact
  45701. */
  45702. ambientTextureImpactOnAnalyticalLights: number;
  45703. /**
  45704. * Stores the alpha values in a texture.
  45705. */
  45706. opacityTexture: BaseTexture;
  45707. /**
  45708. * Stores the reflection values in a texture.
  45709. */
  45710. reflectionTexture: Nullable<BaseTexture>;
  45711. /**
  45712. * Stores the emissive values in a texture.
  45713. */
  45714. emissiveTexture: BaseTexture;
  45715. /**
  45716. * AKA Specular texture in other nomenclature.
  45717. */
  45718. reflectivityTexture: BaseTexture;
  45719. /**
  45720. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45721. */
  45722. metallicTexture: BaseTexture;
  45723. /**
  45724. * Specifies the metallic scalar of the metallic/roughness workflow.
  45725. * Can also be used to scale the metalness values of the metallic texture.
  45726. */
  45727. metallic: Nullable<number>;
  45728. /**
  45729. * Specifies the roughness scalar of the metallic/roughness workflow.
  45730. * Can also be used to scale the roughness values of the metallic texture.
  45731. */
  45732. roughness: Nullable<number>;
  45733. /**
  45734. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45735. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45736. */
  45737. microSurfaceTexture: BaseTexture;
  45738. /**
  45739. * Stores surface normal data used to displace a mesh in a texture.
  45740. */
  45741. bumpTexture: BaseTexture;
  45742. /**
  45743. * Stores the pre-calculated light information of a mesh in a texture.
  45744. */
  45745. lightmapTexture: BaseTexture;
  45746. /**
  45747. * Stores the refracted light information in a texture.
  45748. */
  45749. refractionTexture: Nullable<BaseTexture>;
  45750. /**
  45751. * The color of a material in ambient lighting.
  45752. */
  45753. ambientColor: Color3;
  45754. /**
  45755. * AKA Diffuse Color in other nomenclature.
  45756. */
  45757. albedoColor: Color3;
  45758. /**
  45759. * AKA Specular Color in other nomenclature.
  45760. */
  45761. reflectivityColor: Color3;
  45762. /**
  45763. * The color reflected from the material.
  45764. */
  45765. reflectionColor: Color3;
  45766. /**
  45767. * The color emitted from the material.
  45768. */
  45769. emissiveColor: Color3;
  45770. /**
  45771. * AKA Glossiness in other nomenclature.
  45772. */
  45773. microSurface: number;
  45774. /**
  45775. * source material index of refraction (IOR)' / 'destination material IOR.
  45776. */
  45777. indexOfRefraction: number;
  45778. /**
  45779. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45780. */
  45781. invertRefractionY: boolean;
  45782. /**
  45783. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45784. * Materials half opaque for instance using refraction could benefit from this control.
  45785. */
  45786. linkRefractionWithTransparency: boolean;
  45787. /**
  45788. * If true, the light map contains occlusion information instead of lighting info.
  45789. */
  45790. useLightmapAsShadowmap: boolean;
  45791. /**
  45792. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45793. */
  45794. useAlphaFromAlbedoTexture: boolean;
  45795. /**
  45796. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45797. */
  45798. forceAlphaTest: boolean;
  45799. /**
  45800. * Defines the alpha limits in alpha test mode.
  45801. */
  45802. alphaCutOff: number;
  45803. /**
  45804. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45805. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45806. */
  45807. useSpecularOverAlpha: boolean;
  45808. /**
  45809. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45810. */
  45811. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45812. /**
  45813. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45814. */
  45815. useRoughnessFromMetallicTextureAlpha: boolean;
  45816. /**
  45817. * Specifies if the metallic texture contains the roughness information in its green channel.
  45818. */
  45819. useRoughnessFromMetallicTextureGreen: boolean;
  45820. /**
  45821. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45822. */
  45823. useMetallnessFromMetallicTextureBlue: boolean;
  45824. /**
  45825. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45826. */
  45827. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45828. /**
  45829. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45830. */
  45831. useAmbientInGrayScale: boolean;
  45832. /**
  45833. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45834. * The material will try to infer what glossiness each pixel should be.
  45835. */
  45836. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45837. /**
  45838. * BJS is using an harcoded light falloff based on a manually sets up range.
  45839. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45840. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45841. */
  45842. /**
  45843. * BJS is using an harcoded light falloff based on a manually sets up range.
  45844. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45845. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45846. */
  45847. usePhysicalLightFalloff: boolean;
  45848. /**
  45849. * In order to support the falloff compatibility with gltf, a special mode has been added
  45850. * to reproduce the gltf light falloff.
  45851. */
  45852. /**
  45853. * In order to support the falloff compatibility with gltf, a special mode has been added
  45854. * to reproduce the gltf light falloff.
  45855. */
  45856. useGLTFLightFalloff: boolean;
  45857. /**
  45858. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45859. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45860. */
  45861. useRadianceOverAlpha: boolean;
  45862. /**
  45863. * Allows using an object space normal map (instead of tangent space).
  45864. */
  45865. useObjectSpaceNormalMap: boolean;
  45866. /**
  45867. * Allows using the bump map in parallax mode.
  45868. */
  45869. useParallax: boolean;
  45870. /**
  45871. * Allows using the bump map in parallax occlusion mode.
  45872. */
  45873. useParallaxOcclusion: boolean;
  45874. /**
  45875. * Controls the scale bias of the parallax mode.
  45876. */
  45877. parallaxScaleBias: number;
  45878. /**
  45879. * If sets to true, disables all the lights affecting the material.
  45880. */
  45881. disableLighting: boolean;
  45882. /**
  45883. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45884. */
  45885. forceIrradianceInFragment: boolean;
  45886. /**
  45887. * Number of Simultaneous lights allowed on the material.
  45888. */
  45889. maxSimultaneousLights: number;
  45890. /**
  45891. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45892. */
  45893. invertNormalMapX: boolean;
  45894. /**
  45895. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45896. */
  45897. invertNormalMapY: boolean;
  45898. /**
  45899. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45900. */
  45901. twoSidedLighting: boolean;
  45902. /**
  45903. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45904. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45905. */
  45906. useAlphaFresnel: boolean;
  45907. /**
  45908. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45909. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45910. */
  45911. useLinearAlphaFresnel: boolean;
  45912. /**
  45913. * Let user defines the brdf lookup texture used for IBL.
  45914. * A default 8bit version is embedded but you could point at :
  45915. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45916. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45917. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45918. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45919. */
  45920. environmentBRDFTexture: Nullable<BaseTexture>;
  45921. /**
  45922. * Force normal to face away from face.
  45923. */
  45924. forceNormalForward: boolean;
  45925. /**
  45926. * Enables specular anti aliasing in the PBR shader.
  45927. * It will both interacts on the Geometry for analytical and IBL lighting.
  45928. * It also prefilter the roughness map based on the bump values.
  45929. */
  45930. enableSpecularAntiAliasing: boolean;
  45931. /**
  45932. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45933. * makes the reflect vector face the model (under horizon).
  45934. */
  45935. useHorizonOcclusion: boolean;
  45936. /**
  45937. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45938. * too much the area relying on ambient texture to define their ambient occlusion.
  45939. */
  45940. useRadianceOcclusion: boolean;
  45941. /**
  45942. * If set to true, no lighting calculations will be applied.
  45943. */
  45944. unlit: boolean;
  45945. /**
  45946. * Gets the image processing configuration used either in this material.
  45947. */
  45948. /**
  45949. * Sets the Default image processing configuration used either in the this material.
  45950. *
  45951. * If sets to null, the scene one is in use.
  45952. */
  45953. imageProcessingConfiguration: ImageProcessingConfiguration;
  45954. /**
  45955. * Gets wether the color curves effect is enabled.
  45956. */
  45957. /**
  45958. * Sets wether the color curves effect is enabled.
  45959. */
  45960. cameraColorCurvesEnabled: boolean;
  45961. /**
  45962. * Gets wether the color grading effect is enabled.
  45963. */
  45964. /**
  45965. * Gets wether the color grading effect is enabled.
  45966. */
  45967. cameraColorGradingEnabled: boolean;
  45968. /**
  45969. * Gets wether tonemapping is enabled or not.
  45970. */
  45971. /**
  45972. * Sets wether tonemapping is enabled or not
  45973. */
  45974. cameraToneMappingEnabled: boolean;
  45975. /**
  45976. * The camera exposure used on this material.
  45977. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45978. * This corresponds to a photographic exposure.
  45979. */
  45980. /**
  45981. * The camera exposure used on this material.
  45982. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45983. * This corresponds to a photographic exposure.
  45984. */
  45985. cameraExposure: number;
  45986. /**
  45987. * Gets The camera contrast used on this material.
  45988. */
  45989. /**
  45990. * Sets The camera contrast used on this material.
  45991. */
  45992. cameraContrast: number;
  45993. /**
  45994. * Gets the Color Grading 2D Lookup Texture.
  45995. */
  45996. /**
  45997. * Sets the Color Grading 2D Lookup Texture.
  45998. */
  45999. cameraColorGradingTexture: Nullable<BaseTexture>;
  46000. /**
  46001. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46002. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46003. * 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;
  46004. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46005. */
  46006. /**
  46007. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46008. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46009. * 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;
  46010. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46011. */
  46012. cameraColorCurves: Nullable<ColorCurves>;
  46013. /**
  46014. * Instantiates a new PBRMaterial instance.
  46015. *
  46016. * @param name The material name
  46017. * @param scene The scene the material will be use in.
  46018. */
  46019. constructor(name: string, scene: Scene);
  46020. /**
  46021. * Returns the name of this material class.
  46022. */
  46023. getClassName(): string;
  46024. /**
  46025. * Makes a duplicate of the current material.
  46026. * @param name - name to use for the new material.
  46027. */
  46028. clone(name: string): PBRMaterial;
  46029. /**
  46030. * Serializes this PBR Material.
  46031. * @returns - An object with the serialized material.
  46032. */
  46033. serialize(): any;
  46034. /**
  46035. * Parses a PBR Material from a serialized object.
  46036. * @param source - Serialized object.
  46037. * @param scene - BJS scene instance.
  46038. * @param rootUrl - url for the scene object
  46039. * @returns - PBRMaterial
  46040. */
  46041. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46042. }
  46043. }
  46044. declare module BABYLON {
  46045. /**
  46046. * Direct draw surface info
  46047. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46048. */
  46049. export interface DDSInfo {
  46050. /**
  46051. * Width of the texture
  46052. */
  46053. width: number;
  46054. /**
  46055. * Width of the texture
  46056. */
  46057. height: number;
  46058. /**
  46059. * Number of Mipmaps for the texture
  46060. * @see https://en.wikipedia.org/wiki/Mipmap
  46061. */
  46062. mipmapCount: number;
  46063. /**
  46064. * If the textures format is a known fourCC format
  46065. * @see https://www.fourcc.org/
  46066. */
  46067. isFourCC: boolean;
  46068. /**
  46069. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46070. */
  46071. isRGB: boolean;
  46072. /**
  46073. * If the texture is a lumincance format
  46074. */
  46075. isLuminance: boolean;
  46076. /**
  46077. * If this is a cube texture
  46078. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46079. */
  46080. isCube: boolean;
  46081. /**
  46082. * If the texture is a compressed format eg. FOURCC_DXT1
  46083. */
  46084. isCompressed: boolean;
  46085. /**
  46086. * The dxgiFormat of the texture
  46087. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46088. */
  46089. dxgiFormat: number;
  46090. /**
  46091. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46092. */
  46093. textureType: number;
  46094. /**
  46095. * Sphericle polynomial created for the dds texture
  46096. */
  46097. sphericalPolynomial?: SphericalPolynomial;
  46098. }
  46099. /**
  46100. * Class used to provide DDS decompression tools
  46101. */
  46102. export class DDSTools {
  46103. /**
  46104. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46105. */
  46106. static StoreLODInAlphaChannel: boolean;
  46107. /**
  46108. * Gets DDS information from an array buffer
  46109. * @param arrayBuffer defines the array buffer to read data from
  46110. * @returns the DDS information
  46111. */
  46112. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46113. private static _FloatView;
  46114. private static _Int32View;
  46115. private static _ToHalfFloat;
  46116. private static _FromHalfFloat;
  46117. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46118. private static _GetHalfFloatRGBAArrayBuffer;
  46119. private static _GetFloatRGBAArrayBuffer;
  46120. private static _GetFloatAsUIntRGBAArrayBuffer;
  46121. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46122. private static _GetRGBAArrayBuffer;
  46123. private static _ExtractLongWordOrder;
  46124. private static _GetRGBArrayBuffer;
  46125. private static _GetLuminanceArrayBuffer;
  46126. /**
  46127. * Uploads DDS Levels to a Babylon Texture
  46128. * @hidden
  46129. */
  46130. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46131. }
  46132. interface Engine {
  46133. /**
  46134. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46135. * @param rootUrl defines the url where the file to load is located
  46136. * @param scene defines the current scene
  46137. * @param lodScale defines scale to apply to the mip map selection
  46138. * @param lodOffset defines offset to apply to the mip map selection
  46139. * @param onLoad defines an optional callback raised when the texture is loaded
  46140. * @param onError defines an optional callback raised if there is an issue to load the texture
  46141. * @param format defines the format of the data
  46142. * @param forcedExtension defines the extension to use to pick the right loader
  46143. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46144. * @returns the cube texture as an InternalTexture
  46145. */
  46146. 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;
  46147. }
  46148. }
  46149. declare module BABYLON {
  46150. /**
  46151. * Implementation of the DDS Texture Loader.
  46152. * @hidden
  46153. */
  46154. export class _DDSTextureLoader implements IInternalTextureLoader {
  46155. /**
  46156. * Defines wether the loader supports cascade loading the different faces.
  46157. */
  46158. readonly supportCascades: boolean;
  46159. /**
  46160. * This returns if the loader support the current file information.
  46161. * @param extension defines the file extension of the file being loaded
  46162. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46163. * @param fallback defines the fallback internal texture if any
  46164. * @param isBase64 defines whether the texture is encoded as a base64
  46165. * @param isBuffer defines whether the texture data are stored as a buffer
  46166. * @returns true if the loader can load the specified file
  46167. */
  46168. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46169. /**
  46170. * Transform the url before loading if required.
  46171. * @param rootUrl the url of the texture
  46172. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46173. * @returns the transformed texture
  46174. */
  46175. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46176. /**
  46177. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46178. * @param rootUrl the url of the texture
  46179. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46180. * @returns the fallback texture
  46181. */
  46182. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46183. /**
  46184. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46185. * @param data contains the texture data
  46186. * @param texture defines the BabylonJS internal texture
  46187. * @param createPolynomials will be true if polynomials have been requested
  46188. * @param onLoad defines the callback to trigger once the texture is ready
  46189. * @param onError defines the callback to trigger in case of error
  46190. */
  46191. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46192. /**
  46193. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46194. * @param data contains the texture data
  46195. * @param texture defines the BabylonJS internal texture
  46196. * @param callback defines the method to call once ready to upload
  46197. */
  46198. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46199. }
  46200. }
  46201. declare module BABYLON {
  46202. /** @hidden */
  46203. export var rgbdEncodePixelShader: {
  46204. name: string;
  46205. shader: string;
  46206. };
  46207. }
  46208. declare module BABYLON {
  46209. /**
  46210. * Raw texture data and descriptor sufficient for WebGL texture upload
  46211. */
  46212. export interface EnvironmentTextureInfo {
  46213. /**
  46214. * Version of the environment map
  46215. */
  46216. version: number;
  46217. /**
  46218. * Width of image
  46219. */
  46220. width: number;
  46221. /**
  46222. * Irradiance information stored in the file.
  46223. */
  46224. irradiance: any;
  46225. /**
  46226. * Specular information stored in the file.
  46227. */
  46228. specular: any;
  46229. }
  46230. /**
  46231. * Sets of helpers addressing the serialization and deserialization of environment texture
  46232. * stored in a BabylonJS env file.
  46233. * Those files are usually stored as .env files.
  46234. */
  46235. export class EnvironmentTextureTools {
  46236. /**
  46237. * Magic number identifying the env file.
  46238. */
  46239. private static _MagicBytes;
  46240. /**
  46241. * Gets the environment info from an env file.
  46242. * @param data The array buffer containing the .env bytes.
  46243. * @returns the environment file info (the json header) if successfully parsed.
  46244. */
  46245. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46246. /**
  46247. * Creates an environment texture from a loaded cube texture.
  46248. * @param texture defines the cube texture to convert in env file
  46249. * @return a promise containing the environment data if succesfull.
  46250. */
  46251. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46252. /**
  46253. * Creates a JSON representation of the spherical data.
  46254. * @param texture defines the texture containing the polynomials
  46255. * @return the JSON representation of the spherical info
  46256. */
  46257. private static _CreateEnvTextureIrradiance;
  46258. /**
  46259. * Uploads the texture info contained in the env file to the GPU.
  46260. * @param texture defines the internal texture to upload to
  46261. * @param arrayBuffer defines the buffer cotaining the data to load
  46262. * @param info defines the texture info retrieved through the GetEnvInfo method
  46263. * @returns a promise
  46264. */
  46265. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46266. /**
  46267. * Uploads the levels of image data to the GPU.
  46268. * @param texture defines the internal texture to upload to
  46269. * @param imageData defines the array buffer views of image data [mipmap][face]
  46270. * @returns a promise
  46271. */
  46272. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46273. /**
  46274. * Uploads spherical polynomials information to the texture.
  46275. * @param texture defines the texture we are trying to upload the information to
  46276. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46277. */
  46278. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46279. /** @hidden */
  46280. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46281. }
  46282. }
  46283. declare module BABYLON {
  46284. /**
  46285. * Implementation of the ENV Texture Loader.
  46286. * @hidden
  46287. */
  46288. export class _ENVTextureLoader implements IInternalTextureLoader {
  46289. /**
  46290. * Defines wether the loader supports cascade loading the different faces.
  46291. */
  46292. readonly supportCascades: boolean;
  46293. /**
  46294. * This returns if the loader support the current file information.
  46295. * @param extension defines the file extension of the file being loaded
  46296. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46297. * @param fallback defines the fallback internal texture if any
  46298. * @param isBase64 defines whether the texture is encoded as a base64
  46299. * @param isBuffer defines whether the texture data are stored as a buffer
  46300. * @returns true if the loader can load the specified file
  46301. */
  46302. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46303. /**
  46304. * Transform the url before loading if required.
  46305. * @param rootUrl the url of the texture
  46306. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46307. * @returns the transformed texture
  46308. */
  46309. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46310. /**
  46311. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46312. * @param rootUrl the url of the texture
  46313. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46314. * @returns the fallback texture
  46315. */
  46316. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46317. /**
  46318. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46319. * @param data contains the texture data
  46320. * @param texture defines the BabylonJS internal texture
  46321. * @param createPolynomials will be true if polynomials have been requested
  46322. * @param onLoad defines the callback to trigger once the texture is ready
  46323. * @param onError defines the callback to trigger in case of error
  46324. */
  46325. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46326. /**
  46327. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46328. * @param data contains the texture data
  46329. * @param texture defines the BabylonJS internal texture
  46330. * @param callback defines the method to call once ready to upload
  46331. */
  46332. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46333. }
  46334. }
  46335. declare module BABYLON {
  46336. /**
  46337. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46338. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46339. */
  46340. export class KhronosTextureContainer {
  46341. /** contents of the KTX container file */
  46342. arrayBuffer: any;
  46343. private static HEADER_LEN;
  46344. private static COMPRESSED_2D;
  46345. private static COMPRESSED_3D;
  46346. private static TEX_2D;
  46347. private static TEX_3D;
  46348. /**
  46349. * Gets the openGL type
  46350. */
  46351. glType: number;
  46352. /**
  46353. * Gets the openGL type size
  46354. */
  46355. glTypeSize: number;
  46356. /**
  46357. * Gets the openGL format
  46358. */
  46359. glFormat: number;
  46360. /**
  46361. * Gets the openGL internal format
  46362. */
  46363. glInternalFormat: number;
  46364. /**
  46365. * Gets the base internal format
  46366. */
  46367. glBaseInternalFormat: number;
  46368. /**
  46369. * Gets image width in pixel
  46370. */
  46371. pixelWidth: number;
  46372. /**
  46373. * Gets image height in pixel
  46374. */
  46375. pixelHeight: number;
  46376. /**
  46377. * Gets image depth in pixels
  46378. */
  46379. pixelDepth: number;
  46380. /**
  46381. * Gets the number of array elements
  46382. */
  46383. numberOfArrayElements: number;
  46384. /**
  46385. * Gets the number of faces
  46386. */
  46387. numberOfFaces: number;
  46388. /**
  46389. * Gets the number of mipmap levels
  46390. */
  46391. numberOfMipmapLevels: number;
  46392. /**
  46393. * Gets the bytes of key value data
  46394. */
  46395. bytesOfKeyValueData: number;
  46396. /**
  46397. * Gets the load type
  46398. */
  46399. loadType: number;
  46400. /**
  46401. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46402. */
  46403. isInvalid: boolean;
  46404. /**
  46405. * Creates a new KhronosTextureContainer
  46406. * @param arrayBuffer contents of the KTX container file
  46407. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46408. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46409. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46410. */
  46411. constructor(
  46412. /** contents of the KTX container file */
  46413. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46414. /**
  46415. * Uploads KTX content to a Babylon Texture.
  46416. * It is assumed that the texture has already been created & is currently bound
  46417. * @hidden
  46418. */
  46419. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46420. private _upload2DCompressedLevels;
  46421. }
  46422. }
  46423. declare module BABYLON {
  46424. /**
  46425. * Implementation of the KTX Texture Loader.
  46426. * @hidden
  46427. */
  46428. export class _KTXTextureLoader implements IInternalTextureLoader {
  46429. /**
  46430. * Defines wether the loader supports cascade loading the different faces.
  46431. */
  46432. readonly supportCascades: boolean;
  46433. /**
  46434. * This returns if the loader support the current file information.
  46435. * @param extension defines the file extension of the file being loaded
  46436. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46437. * @param fallback defines the fallback internal texture if any
  46438. * @param isBase64 defines whether the texture is encoded as a base64
  46439. * @param isBuffer defines whether the texture data are stored as a buffer
  46440. * @returns true if the loader can load the specified file
  46441. */
  46442. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46443. /**
  46444. * Transform the url before loading if required.
  46445. * @param rootUrl the url of the texture
  46446. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46447. * @returns the transformed texture
  46448. */
  46449. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46450. /**
  46451. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46452. * @param rootUrl the url of the texture
  46453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46454. * @returns the fallback texture
  46455. */
  46456. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46457. /**
  46458. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46459. * @param data contains the texture data
  46460. * @param texture defines the BabylonJS internal texture
  46461. * @param createPolynomials will be true if polynomials have been requested
  46462. * @param onLoad defines the callback to trigger once the texture is ready
  46463. * @param onError defines the callback to trigger in case of error
  46464. */
  46465. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46466. /**
  46467. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46468. * @param data contains the texture data
  46469. * @param texture defines the BabylonJS internal texture
  46470. * @param callback defines the method to call once ready to upload
  46471. */
  46472. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46473. }
  46474. }
  46475. declare module BABYLON {
  46476. /** @hidden */
  46477. export var _forceSceneHelpersToBundle: boolean;
  46478. interface Scene {
  46479. /**
  46480. * Creates a default light for the scene.
  46481. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46482. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46483. */
  46484. createDefaultLight(replace?: boolean): void;
  46485. /**
  46486. * Creates a default camera for the scene.
  46487. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46488. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46489. * @param replace has default false, when true replaces the active camera in the scene
  46490. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46491. */
  46492. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46493. /**
  46494. * Creates a default camera and a default light.
  46495. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46496. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46497. * @param replace has the default false, when true replaces the active camera/light in the scene
  46498. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46499. */
  46500. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46501. /**
  46502. * Creates a new sky box
  46503. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46504. * @param environmentTexture defines the texture to use as environment texture
  46505. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46506. * @param scale defines the overall scale of the skybox
  46507. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46508. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46509. * @returns a new mesh holding the sky box
  46510. */
  46511. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46512. /**
  46513. * Creates a new environment
  46514. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46515. * @param options defines the options you can use to configure the environment
  46516. * @returns the new EnvironmentHelper
  46517. */
  46518. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46519. /**
  46520. * Creates a new VREXperienceHelper
  46521. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46522. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46523. * @returns a new VREXperienceHelper
  46524. */
  46525. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46526. /**
  46527. * Creates a new XREXperienceHelper
  46528. * @see http://doc.babylonjs.com/how_to/webxr
  46529. * @returns a promise for a new XREXperienceHelper
  46530. */
  46531. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46532. }
  46533. }
  46534. declare module BABYLON {
  46535. /**
  46536. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46537. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46538. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46539. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46540. */
  46541. export class VideoDome extends TransformNode {
  46542. /**
  46543. * Define the video source as a Monoscopic panoramic 360 video.
  46544. */
  46545. static readonly MODE_MONOSCOPIC: number;
  46546. /**
  46547. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46548. */
  46549. static readonly MODE_TOPBOTTOM: number;
  46550. /**
  46551. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46552. */
  46553. static readonly MODE_SIDEBYSIDE: number;
  46554. private _useDirectMapping;
  46555. /**
  46556. * The video texture being displayed on the sphere
  46557. */
  46558. protected _videoTexture: VideoTexture;
  46559. /**
  46560. * Gets the video texture being displayed on the sphere
  46561. */
  46562. readonly videoTexture: VideoTexture;
  46563. /**
  46564. * The skybox material
  46565. */
  46566. protected _material: BackgroundMaterial;
  46567. /**
  46568. * The surface used for the skybox
  46569. */
  46570. protected _mesh: Mesh;
  46571. /**
  46572. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46573. * Also see the options.resolution property.
  46574. */
  46575. fovMultiplier: number;
  46576. private _videoMode;
  46577. /**
  46578. * Gets or set the current video mode for the video. It can be:
  46579. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46580. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46581. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46582. */
  46583. videoMode: number;
  46584. /**
  46585. * Oberserver used in Stereoscopic VR Mode.
  46586. */
  46587. private _onBeforeCameraRenderObserver;
  46588. /**
  46589. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46590. * @param name Element's name, child elements will append suffixes for their own names.
  46591. * @param urlsOrVideo defines the url(s) or the video element to use
  46592. * @param options An object containing optional or exposed sub element properties
  46593. */
  46594. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46595. resolution?: number;
  46596. clickToPlay?: boolean;
  46597. autoPlay?: boolean;
  46598. loop?: boolean;
  46599. size?: number;
  46600. poster?: string;
  46601. faceForward?: boolean;
  46602. useDirectMapping?: boolean;
  46603. }, scene: Scene);
  46604. private _changeVideoMode;
  46605. /**
  46606. * Releases resources associated with this node.
  46607. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46608. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46609. */
  46610. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46611. }
  46612. }
  46613. declare module BABYLON {
  46614. /**
  46615. * This class can be used to get instrumentation data from a Babylon engine
  46616. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46617. */
  46618. export class EngineInstrumentation implements IDisposable {
  46619. /**
  46620. * Define the instrumented engine.
  46621. */
  46622. engine: Engine;
  46623. private _captureGPUFrameTime;
  46624. private _gpuFrameTimeToken;
  46625. private _gpuFrameTime;
  46626. private _captureShaderCompilationTime;
  46627. private _shaderCompilationTime;
  46628. private _onBeginFrameObserver;
  46629. private _onEndFrameObserver;
  46630. private _onBeforeShaderCompilationObserver;
  46631. private _onAfterShaderCompilationObserver;
  46632. /**
  46633. * Gets the perf counter used for GPU frame time
  46634. */
  46635. readonly gpuFrameTimeCounter: PerfCounter;
  46636. /**
  46637. * Gets the GPU frame time capture status
  46638. */
  46639. /**
  46640. * Enable or disable the GPU frame time capture
  46641. */
  46642. captureGPUFrameTime: boolean;
  46643. /**
  46644. * Gets the perf counter used for shader compilation time
  46645. */
  46646. readonly shaderCompilationTimeCounter: PerfCounter;
  46647. /**
  46648. * Gets the shader compilation time capture status
  46649. */
  46650. /**
  46651. * Enable or disable the shader compilation time capture
  46652. */
  46653. captureShaderCompilationTime: boolean;
  46654. /**
  46655. * Instantiates a new engine instrumentation.
  46656. * This class can be used to get instrumentation data from a Babylon engine
  46657. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46658. * @param engine Defines the engine to instrument
  46659. */
  46660. constructor(
  46661. /**
  46662. * Define the instrumented engine.
  46663. */
  46664. engine: Engine);
  46665. /**
  46666. * Dispose and release associated resources.
  46667. */
  46668. dispose(): void;
  46669. }
  46670. }
  46671. declare module BABYLON {
  46672. /**
  46673. * This class can be used to get instrumentation data from a Babylon engine
  46674. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46675. */
  46676. export class SceneInstrumentation implements IDisposable {
  46677. /**
  46678. * Defines the scene to instrument
  46679. */
  46680. scene: Scene;
  46681. private _captureActiveMeshesEvaluationTime;
  46682. private _activeMeshesEvaluationTime;
  46683. private _captureRenderTargetsRenderTime;
  46684. private _renderTargetsRenderTime;
  46685. private _captureFrameTime;
  46686. private _frameTime;
  46687. private _captureRenderTime;
  46688. private _renderTime;
  46689. private _captureInterFrameTime;
  46690. private _interFrameTime;
  46691. private _captureParticlesRenderTime;
  46692. private _particlesRenderTime;
  46693. private _captureSpritesRenderTime;
  46694. private _spritesRenderTime;
  46695. private _capturePhysicsTime;
  46696. private _physicsTime;
  46697. private _captureAnimationsTime;
  46698. private _animationsTime;
  46699. private _captureCameraRenderTime;
  46700. private _cameraRenderTime;
  46701. private _onBeforeActiveMeshesEvaluationObserver;
  46702. private _onAfterActiveMeshesEvaluationObserver;
  46703. private _onBeforeRenderTargetsRenderObserver;
  46704. private _onAfterRenderTargetsRenderObserver;
  46705. private _onAfterRenderObserver;
  46706. private _onBeforeDrawPhaseObserver;
  46707. private _onAfterDrawPhaseObserver;
  46708. private _onBeforeAnimationsObserver;
  46709. private _onBeforeParticlesRenderingObserver;
  46710. private _onAfterParticlesRenderingObserver;
  46711. private _onBeforeSpritesRenderingObserver;
  46712. private _onAfterSpritesRenderingObserver;
  46713. private _onBeforePhysicsObserver;
  46714. private _onAfterPhysicsObserver;
  46715. private _onAfterAnimationsObserver;
  46716. private _onBeforeCameraRenderObserver;
  46717. private _onAfterCameraRenderObserver;
  46718. /**
  46719. * Gets the perf counter used for active meshes evaluation time
  46720. */
  46721. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46722. /**
  46723. * Gets the active meshes evaluation time capture status
  46724. */
  46725. /**
  46726. * Enable or disable the active meshes evaluation time capture
  46727. */
  46728. captureActiveMeshesEvaluationTime: boolean;
  46729. /**
  46730. * Gets the perf counter used for render targets render time
  46731. */
  46732. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46733. /**
  46734. * Gets the render targets render time capture status
  46735. */
  46736. /**
  46737. * Enable or disable the render targets render time capture
  46738. */
  46739. captureRenderTargetsRenderTime: boolean;
  46740. /**
  46741. * Gets the perf counter used for particles render time
  46742. */
  46743. readonly particlesRenderTimeCounter: PerfCounter;
  46744. /**
  46745. * Gets the particles render time capture status
  46746. */
  46747. /**
  46748. * Enable or disable the particles render time capture
  46749. */
  46750. captureParticlesRenderTime: boolean;
  46751. /**
  46752. * Gets the perf counter used for sprites render time
  46753. */
  46754. readonly spritesRenderTimeCounter: PerfCounter;
  46755. /**
  46756. * Gets the sprites render time capture status
  46757. */
  46758. /**
  46759. * Enable or disable the sprites render time capture
  46760. */
  46761. captureSpritesRenderTime: boolean;
  46762. /**
  46763. * Gets the perf counter used for physics time
  46764. */
  46765. readonly physicsTimeCounter: PerfCounter;
  46766. /**
  46767. * Gets the physics time capture status
  46768. */
  46769. /**
  46770. * Enable or disable the physics time capture
  46771. */
  46772. capturePhysicsTime: boolean;
  46773. /**
  46774. * Gets the perf counter used for animations time
  46775. */
  46776. readonly animationsTimeCounter: PerfCounter;
  46777. /**
  46778. * Gets the animations time capture status
  46779. */
  46780. /**
  46781. * Enable or disable the animations time capture
  46782. */
  46783. captureAnimationsTime: boolean;
  46784. /**
  46785. * Gets the perf counter used for frame time capture
  46786. */
  46787. readonly frameTimeCounter: PerfCounter;
  46788. /**
  46789. * Gets the frame time capture status
  46790. */
  46791. /**
  46792. * Enable or disable the frame time capture
  46793. */
  46794. captureFrameTime: boolean;
  46795. /**
  46796. * Gets the perf counter used for inter-frames time capture
  46797. */
  46798. readonly interFrameTimeCounter: PerfCounter;
  46799. /**
  46800. * Gets the inter-frames time capture status
  46801. */
  46802. /**
  46803. * Enable or disable the inter-frames time capture
  46804. */
  46805. captureInterFrameTime: boolean;
  46806. /**
  46807. * Gets the perf counter used for render time capture
  46808. */
  46809. readonly renderTimeCounter: PerfCounter;
  46810. /**
  46811. * Gets the render time capture status
  46812. */
  46813. /**
  46814. * Enable or disable the render time capture
  46815. */
  46816. captureRenderTime: boolean;
  46817. /**
  46818. * Gets the perf counter used for camera render time capture
  46819. */
  46820. readonly cameraRenderTimeCounter: PerfCounter;
  46821. /**
  46822. * Gets the camera render time capture status
  46823. */
  46824. /**
  46825. * Enable or disable the camera render time capture
  46826. */
  46827. captureCameraRenderTime: boolean;
  46828. /**
  46829. * Gets the perf counter used for draw calls
  46830. */
  46831. readonly drawCallsCounter: PerfCounter;
  46832. /**
  46833. * Instantiates a new scene instrumentation.
  46834. * This class can be used to get instrumentation data from a Babylon engine
  46835. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46836. * @param scene Defines the scene to instrument
  46837. */
  46838. constructor(
  46839. /**
  46840. * Defines the scene to instrument
  46841. */
  46842. scene: Scene);
  46843. /**
  46844. * Dispose and release associated resources.
  46845. */
  46846. dispose(): void;
  46847. }
  46848. }
  46849. declare module BABYLON {
  46850. /** @hidden */
  46851. export var glowMapGenerationPixelShader: {
  46852. name: string;
  46853. shader: string;
  46854. };
  46855. }
  46856. declare module BABYLON {
  46857. /** @hidden */
  46858. export var glowMapGenerationVertexShader: {
  46859. name: string;
  46860. shader: string;
  46861. };
  46862. }
  46863. declare module BABYLON {
  46864. /**
  46865. * Effect layer options. This helps customizing the behaviour
  46866. * of the effect layer.
  46867. */
  46868. export interface IEffectLayerOptions {
  46869. /**
  46870. * Multiplication factor apply to the canvas size to compute the render target size
  46871. * used to generated the objects (the smaller the faster).
  46872. */
  46873. mainTextureRatio: number;
  46874. /**
  46875. * Enforces a fixed size texture to ensure effect stability across devices.
  46876. */
  46877. mainTextureFixedSize?: number;
  46878. /**
  46879. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46880. */
  46881. alphaBlendingMode: number;
  46882. /**
  46883. * The camera attached to the layer.
  46884. */
  46885. camera: Nullable<Camera>;
  46886. /**
  46887. * The rendering group to draw the layer in.
  46888. */
  46889. renderingGroupId: number;
  46890. }
  46891. /**
  46892. * The effect layer Helps adding post process effect blended with the main pass.
  46893. *
  46894. * This can be for instance use to generate glow or higlight effects on the scene.
  46895. *
  46896. * The effect layer class can not be used directly and is intented to inherited from to be
  46897. * customized per effects.
  46898. */
  46899. export abstract class EffectLayer {
  46900. private _vertexBuffers;
  46901. private _indexBuffer;
  46902. private _cachedDefines;
  46903. private _effectLayerMapGenerationEffect;
  46904. private _effectLayerOptions;
  46905. private _mergeEffect;
  46906. protected _scene: Scene;
  46907. protected _engine: Engine;
  46908. protected _maxSize: number;
  46909. protected _mainTextureDesiredSize: ISize;
  46910. protected _mainTexture: RenderTargetTexture;
  46911. protected _shouldRender: boolean;
  46912. protected _postProcesses: PostProcess[];
  46913. protected _textures: BaseTexture[];
  46914. protected _emissiveTextureAndColor: {
  46915. texture: Nullable<BaseTexture>;
  46916. color: Color4;
  46917. };
  46918. /**
  46919. * The name of the layer
  46920. */
  46921. name: string;
  46922. /**
  46923. * The clear color of the texture used to generate the glow map.
  46924. */
  46925. neutralColor: Color4;
  46926. /**
  46927. * Specifies wether the highlight layer is enabled or not.
  46928. */
  46929. isEnabled: boolean;
  46930. /**
  46931. * Gets the camera attached to the layer.
  46932. */
  46933. readonly camera: Nullable<Camera>;
  46934. /**
  46935. * Gets the rendering group id the layer should render in.
  46936. */
  46937. readonly renderingGroupId: number;
  46938. /**
  46939. * An event triggered when the effect layer has been disposed.
  46940. */
  46941. onDisposeObservable: Observable<EffectLayer>;
  46942. /**
  46943. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46944. */
  46945. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46946. /**
  46947. * An event triggered when the generated texture is being merged in the scene.
  46948. */
  46949. onBeforeComposeObservable: Observable<EffectLayer>;
  46950. /**
  46951. * An event triggered when the generated texture has been merged in the scene.
  46952. */
  46953. onAfterComposeObservable: Observable<EffectLayer>;
  46954. /**
  46955. * An event triggered when the efffect layer changes its size.
  46956. */
  46957. onSizeChangedObservable: Observable<EffectLayer>;
  46958. /** @hidden */
  46959. static _SceneComponentInitialization: (scene: Scene) => void;
  46960. /**
  46961. * Instantiates a new effect Layer and references it in the scene.
  46962. * @param name The name of the layer
  46963. * @param scene The scene to use the layer in
  46964. */
  46965. constructor(
  46966. /** The Friendly of the effect in the scene */
  46967. name: string, scene: Scene);
  46968. /**
  46969. * Get the effect name of the layer.
  46970. * @return The effect name
  46971. */
  46972. abstract getEffectName(): string;
  46973. /**
  46974. * Checks for the readiness of the element composing the layer.
  46975. * @param subMesh the mesh to check for
  46976. * @param useInstances specify wether or not to use instances to render the mesh
  46977. * @return true if ready otherwise, false
  46978. */
  46979. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46980. /**
  46981. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46982. * @returns true if the effect requires stencil during the main canvas render pass.
  46983. */
  46984. abstract needStencil(): boolean;
  46985. /**
  46986. * Create the merge effect. This is the shader use to blit the information back
  46987. * to the main canvas at the end of the scene rendering.
  46988. * @returns The effect containing the shader used to merge the effect on the main canvas
  46989. */
  46990. protected abstract _createMergeEffect(): Effect;
  46991. /**
  46992. * Creates the render target textures and post processes used in the effect layer.
  46993. */
  46994. protected abstract _createTextureAndPostProcesses(): void;
  46995. /**
  46996. * Implementation specific of rendering the generating effect on the main canvas.
  46997. * @param effect The effect used to render through
  46998. */
  46999. protected abstract _internalRender(effect: Effect): void;
  47000. /**
  47001. * Sets the required values for both the emissive texture and and the main color.
  47002. */
  47003. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47004. /**
  47005. * Free any resources and references associated to a mesh.
  47006. * Internal use
  47007. * @param mesh The mesh to free.
  47008. */
  47009. abstract _disposeMesh(mesh: Mesh): void;
  47010. /**
  47011. * Serializes this layer (Glow or Highlight for example)
  47012. * @returns a serialized layer object
  47013. */
  47014. abstract serialize?(): any;
  47015. /**
  47016. * Initializes the effect layer with the required options.
  47017. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47018. */
  47019. protected _init(options: Partial<IEffectLayerOptions>): void;
  47020. /**
  47021. * Generates the index buffer of the full screen quad blending to the main canvas.
  47022. */
  47023. private _generateIndexBuffer;
  47024. /**
  47025. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47026. */
  47027. private _generateVertexBuffer;
  47028. /**
  47029. * Sets the main texture desired size which is the closest power of two
  47030. * of the engine canvas size.
  47031. */
  47032. private _setMainTextureSize;
  47033. /**
  47034. * Creates the main texture for the effect layer.
  47035. */
  47036. protected _createMainTexture(): void;
  47037. /**
  47038. * Adds specific effects defines.
  47039. * @param defines The defines to add specifics to.
  47040. */
  47041. protected _addCustomEffectDefines(defines: string[]): void;
  47042. /**
  47043. * Checks for the readiness of the element composing the layer.
  47044. * @param subMesh the mesh to check for
  47045. * @param useInstances specify wether or not to use instances to render the mesh
  47046. * @param emissiveTexture the associated emissive texture used to generate the glow
  47047. * @return true if ready otherwise, false
  47048. */
  47049. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47050. /**
  47051. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47052. */
  47053. render(): void;
  47054. /**
  47055. * Determine if a given mesh will be used in the current effect.
  47056. * @param mesh mesh to test
  47057. * @returns true if the mesh will be used
  47058. */
  47059. hasMesh(mesh: AbstractMesh): boolean;
  47060. /**
  47061. * Returns true if the layer contains information to display, otherwise false.
  47062. * @returns true if the glow layer should be rendered
  47063. */
  47064. shouldRender(): boolean;
  47065. /**
  47066. * Returns true if the mesh should render, otherwise false.
  47067. * @param mesh The mesh to render
  47068. * @returns true if it should render otherwise false
  47069. */
  47070. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47071. /**
  47072. * Returns true if the mesh can be rendered, otherwise false.
  47073. * @param mesh The mesh to render
  47074. * @param material The material used on the mesh
  47075. * @returns true if it can be rendered otherwise false
  47076. */
  47077. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47078. /**
  47079. * Returns true if the mesh should render, otherwise false.
  47080. * @param mesh The mesh to render
  47081. * @returns true if it should render otherwise false
  47082. */
  47083. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47084. /**
  47085. * Renders the submesh passed in parameter to the generation map.
  47086. */
  47087. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47088. /**
  47089. * Rebuild the required buffers.
  47090. * @hidden Internal use only.
  47091. */
  47092. _rebuild(): void;
  47093. /**
  47094. * Dispose only the render target textures and post process.
  47095. */
  47096. private _disposeTextureAndPostProcesses;
  47097. /**
  47098. * Dispose the highlight layer and free resources.
  47099. */
  47100. dispose(): void;
  47101. /**
  47102. * Gets the class name of the effect layer
  47103. * @returns the string with the class name of the effect layer
  47104. */
  47105. getClassName(): string;
  47106. /**
  47107. * Creates an effect layer from parsed effect layer data
  47108. * @param parsedEffectLayer defines effect layer data
  47109. * @param scene defines the current scene
  47110. * @param rootUrl defines the root URL containing the effect layer information
  47111. * @returns a parsed effect Layer
  47112. */
  47113. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47114. }
  47115. }
  47116. declare module BABYLON {
  47117. interface AbstractScene {
  47118. /**
  47119. * The list of effect layers (highlights/glow) added to the scene
  47120. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47121. * @see http://doc.babylonjs.com/how_to/glow_layer
  47122. */
  47123. effectLayers: Array<EffectLayer>;
  47124. /**
  47125. * Removes the given effect layer from this scene.
  47126. * @param toRemove defines the effect layer to remove
  47127. * @returns the index of the removed effect layer
  47128. */
  47129. removeEffectLayer(toRemove: EffectLayer): number;
  47130. /**
  47131. * Adds the given effect layer to this scene
  47132. * @param newEffectLayer defines the effect layer to add
  47133. */
  47134. addEffectLayer(newEffectLayer: EffectLayer): void;
  47135. }
  47136. /**
  47137. * Defines the layer scene component responsible to manage any effect layers
  47138. * in a given scene.
  47139. */
  47140. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47141. /**
  47142. * The component name helpfull to identify the component in the list of scene components.
  47143. */
  47144. readonly name: string;
  47145. /**
  47146. * The scene the component belongs to.
  47147. */
  47148. scene: Scene;
  47149. private _engine;
  47150. private _renderEffects;
  47151. private _needStencil;
  47152. private _previousStencilState;
  47153. /**
  47154. * Creates a new instance of the component for the given scene
  47155. * @param scene Defines the scene to register the component in
  47156. */
  47157. constructor(scene: Scene);
  47158. /**
  47159. * Registers the component in a given scene
  47160. */
  47161. register(): void;
  47162. /**
  47163. * Rebuilds the elements related to this component in case of
  47164. * context lost for instance.
  47165. */
  47166. rebuild(): void;
  47167. /**
  47168. * Serializes the component data to the specified json object
  47169. * @param serializationObject The object to serialize to
  47170. */
  47171. serialize(serializationObject: any): void;
  47172. /**
  47173. * Adds all the element from the container to the scene
  47174. * @param container the container holding the elements
  47175. */
  47176. addFromContainer(container: AbstractScene): void;
  47177. /**
  47178. * Removes all the elements in the container from the scene
  47179. * @param container contains the elements to remove
  47180. * @param dispose if the removed element should be disposed (default: false)
  47181. */
  47182. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47183. /**
  47184. * Disposes the component and the associated ressources.
  47185. */
  47186. dispose(): void;
  47187. private _isReadyForMesh;
  47188. private _renderMainTexture;
  47189. private _setStencil;
  47190. private _setStencilBack;
  47191. private _draw;
  47192. private _drawCamera;
  47193. private _drawRenderingGroup;
  47194. }
  47195. }
  47196. declare module BABYLON {
  47197. /** @hidden */
  47198. export var glowMapMergePixelShader: {
  47199. name: string;
  47200. shader: string;
  47201. };
  47202. }
  47203. declare module BABYLON {
  47204. /** @hidden */
  47205. export var glowMapMergeVertexShader: {
  47206. name: string;
  47207. shader: string;
  47208. };
  47209. }
  47210. declare module BABYLON {
  47211. interface AbstractScene {
  47212. /**
  47213. * Return a the first highlight layer of the scene with a given name.
  47214. * @param name The name of the highlight layer to look for.
  47215. * @return The highlight layer if found otherwise null.
  47216. */
  47217. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47218. }
  47219. /**
  47220. * Glow layer options. This helps customizing the behaviour
  47221. * of the glow layer.
  47222. */
  47223. export interface IGlowLayerOptions {
  47224. /**
  47225. * Multiplication factor apply to the canvas size to compute the render target size
  47226. * used to generated the glowing objects (the smaller the faster).
  47227. */
  47228. mainTextureRatio: number;
  47229. /**
  47230. * Enforces a fixed size texture to ensure resize independant blur.
  47231. */
  47232. mainTextureFixedSize?: number;
  47233. /**
  47234. * How big is the kernel of the blur texture.
  47235. */
  47236. blurKernelSize: number;
  47237. /**
  47238. * The camera attached to the layer.
  47239. */
  47240. camera: Nullable<Camera>;
  47241. /**
  47242. * Enable MSAA by chosing the number of samples.
  47243. */
  47244. mainTextureSamples?: number;
  47245. /**
  47246. * The rendering group to draw the layer in.
  47247. */
  47248. renderingGroupId: number;
  47249. }
  47250. /**
  47251. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47252. *
  47253. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47254. * glowy meshes to your scene.
  47255. *
  47256. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47257. */
  47258. export class GlowLayer extends EffectLayer {
  47259. /**
  47260. * Effect Name of the layer.
  47261. */
  47262. static readonly EffectName: string;
  47263. /**
  47264. * The default blur kernel size used for the glow.
  47265. */
  47266. static DefaultBlurKernelSize: number;
  47267. /**
  47268. * The default texture size ratio used for the glow.
  47269. */
  47270. static DefaultTextureRatio: number;
  47271. /**
  47272. * Sets the kernel size of the blur.
  47273. */
  47274. /**
  47275. * Gets the kernel size of the blur.
  47276. */
  47277. blurKernelSize: number;
  47278. /**
  47279. * Sets the glow intensity.
  47280. */
  47281. /**
  47282. * Gets the glow intensity.
  47283. */
  47284. intensity: number;
  47285. private _options;
  47286. private _intensity;
  47287. private _horizontalBlurPostprocess1;
  47288. private _verticalBlurPostprocess1;
  47289. private _horizontalBlurPostprocess2;
  47290. private _verticalBlurPostprocess2;
  47291. private _blurTexture1;
  47292. private _blurTexture2;
  47293. private _postProcesses1;
  47294. private _postProcesses2;
  47295. private _includedOnlyMeshes;
  47296. private _excludedMeshes;
  47297. /**
  47298. * Callback used to let the user override the color selection on a per mesh basis
  47299. */
  47300. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47301. /**
  47302. * Callback used to let the user override the texture selection on a per mesh basis
  47303. */
  47304. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47305. /**
  47306. * Instantiates a new glow Layer and references it to the scene.
  47307. * @param name The name of the layer
  47308. * @param scene The scene to use the layer in
  47309. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47310. */
  47311. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47312. /**
  47313. * Get the effect name of the layer.
  47314. * @return The effect name
  47315. */
  47316. getEffectName(): string;
  47317. /**
  47318. * Create the merge effect. This is the shader use to blit the information back
  47319. * to the main canvas at the end of the scene rendering.
  47320. */
  47321. protected _createMergeEffect(): Effect;
  47322. /**
  47323. * Creates the render target textures and post processes used in the glow layer.
  47324. */
  47325. protected _createTextureAndPostProcesses(): void;
  47326. /**
  47327. * Checks for the readiness of the element composing the layer.
  47328. * @param subMesh the mesh to check for
  47329. * @param useInstances specify wether or not to use instances to render the mesh
  47330. * @param emissiveTexture the associated emissive texture used to generate the glow
  47331. * @return true if ready otherwise, false
  47332. */
  47333. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47334. /**
  47335. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47336. */
  47337. needStencil(): boolean;
  47338. /**
  47339. * Returns true if the mesh can be rendered, otherwise false.
  47340. * @param mesh The mesh to render
  47341. * @param material The material used on the mesh
  47342. * @returns true if it can be rendered otherwise false
  47343. */
  47344. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47345. /**
  47346. * Implementation specific of rendering the generating effect on the main canvas.
  47347. * @param effect The effect used to render through
  47348. */
  47349. protected _internalRender(effect: Effect): void;
  47350. /**
  47351. * Sets the required values for both the emissive texture and and the main color.
  47352. */
  47353. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47354. /**
  47355. * Returns true if the mesh should render, otherwise false.
  47356. * @param mesh The mesh to render
  47357. * @returns true if it should render otherwise false
  47358. */
  47359. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47360. /**
  47361. * Adds specific effects defines.
  47362. * @param defines The defines to add specifics to.
  47363. */
  47364. protected _addCustomEffectDefines(defines: string[]): void;
  47365. /**
  47366. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47367. * @param mesh The mesh to exclude from the glow layer
  47368. */
  47369. addExcludedMesh(mesh: Mesh): void;
  47370. /**
  47371. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47372. * @param mesh The mesh to remove
  47373. */
  47374. removeExcludedMesh(mesh: Mesh): void;
  47375. /**
  47376. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47377. * @param mesh The mesh to include in the glow layer
  47378. */
  47379. addIncludedOnlyMesh(mesh: Mesh): void;
  47380. /**
  47381. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47382. * @param mesh The mesh to remove
  47383. */
  47384. removeIncludedOnlyMesh(mesh: Mesh): void;
  47385. /**
  47386. * Determine if a given mesh will be used in the glow layer
  47387. * @param mesh The mesh to test
  47388. * @returns true if the mesh will be highlighted by the current glow layer
  47389. */
  47390. hasMesh(mesh: AbstractMesh): boolean;
  47391. /**
  47392. * Free any resources and references associated to a mesh.
  47393. * Internal use
  47394. * @param mesh The mesh to free.
  47395. * @hidden
  47396. */
  47397. _disposeMesh(mesh: Mesh): void;
  47398. /**
  47399. * Gets the class name of the effect layer
  47400. * @returns the string with the class name of the effect layer
  47401. */
  47402. getClassName(): string;
  47403. /**
  47404. * Serializes this glow layer
  47405. * @returns a serialized glow layer object
  47406. */
  47407. serialize(): any;
  47408. /**
  47409. * Creates a Glow Layer from parsed glow layer data
  47410. * @param parsedGlowLayer defines glow layer data
  47411. * @param scene defines the current scene
  47412. * @param rootUrl defines the root URL containing the glow layer information
  47413. * @returns a parsed Glow Layer
  47414. */
  47415. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47416. }
  47417. }
  47418. declare module BABYLON {
  47419. /** @hidden */
  47420. export var glowBlurPostProcessPixelShader: {
  47421. name: string;
  47422. shader: string;
  47423. };
  47424. }
  47425. declare module BABYLON {
  47426. interface AbstractScene {
  47427. /**
  47428. * Return a the first highlight layer of the scene with a given name.
  47429. * @param name The name of the highlight layer to look for.
  47430. * @return The highlight layer if found otherwise null.
  47431. */
  47432. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47433. }
  47434. /**
  47435. * Highlight layer options. This helps customizing the behaviour
  47436. * of the highlight layer.
  47437. */
  47438. export interface IHighlightLayerOptions {
  47439. /**
  47440. * Multiplication factor apply to the canvas size to compute the render target size
  47441. * used to generated the glowing objects (the smaller the faster).
  47442. */
  47443. mainTextureRatio: number;
  47444. /**
  47445. * Enforces a fixed size texture to ensure resize independant blur.
  47446. */
  47447. mainTextureFixedSize?: number;
  47448. /**
  47449. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47450. * of the picture to blur (the smaller the faster).
  47451. */
  47452. blurTextureSizeRatio: number;
  47453. /**
  47454. * How big in texel of the blur texture is the vertical blur.
  47455. */
  47456. blurVerticalSize: number;
  47457. /**
  47458. * How big in texel of the blur texture is the horizontal blur.
  47459. */
  47460. blurHorizontalSize: number;
  47461. /**
  47462. * Alpha blending mode used to apply the blur. Default is combine.
  47463. */
  47464. alphaBlendingMode: number;
  47465. /**
  47466. * The camera attached to the layer.
  47467. */
  47468. camera: Nullable<Camera>;
  47469. /**
  47470. * Should we display highlight as a solid stroke?
  47471. */
  47472. isStroke?: boolean;
  47473. /**
  47474. * The rendering group to draw the layer in.
  47475. */
  47476. renderingGroupId: number;
  47477. }
  47478. /**
  47479. * The highlight layer Helps adding a glow effect around a mesh.
  47480. *
  47481. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47482. * glowy meshes to your scene.
  47483. *
  47484. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47485. */
  47486. export class HighlightLayer extends EffectLayer {
  47487. name: string;
  47488. /**
  47489. * Effect Name of the highlight layer.
  47490. */
  47491. static readonly EffectName: string;
  47492. /**
  47493. * The neutral color used during the preparation of the glow effect.
  47494. * This is black by default as the blend operation is a blend operation.
  47495. */
  47496. static NeutralColor: Color4;
  47497. /**
  47498. * Stencil value used for glowing meshes.
  47499. */
  47500. static GlowingMeshStencilReference: number;
  47501. /**
  47502. * Stencil value used for the other meshes in the scene.
  47503. */
  47504. static NormalMeshStencilReference: number;
  47505. /**
  47506. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47507. */
  47508. innerGlow: boolean;
  47509. /**
  47510. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47511. */
  47512. outerGlow: boolean;
  47513. /**
  47514. * Specifies the horizontal size of the blur.
  47515. */
  47516. /**
  47517. * Gets the horizontal size of the blur.
  47518. */
  47519. blurHorizontalSize: number;
  47520. /**
  47521. * Specifies the vertical size of the blur.
  47522. */
  47523. /**
  47524. * Gets the vertical size of the blur.
  47525. */
  47526. blurVerticalSize: number;
  47527. /**
  47528. * An event triggered when the highlight layer is being blurred.
  47529. */
  47530. onBeforeBlurObservable: Observable<HighlightLayer>;
  47531. /**
  47532. * An event triggered when the highlight layer has been blurred.
  47533. */
  47534. onAfterBlurObservable: Observable<HighlightLayer>;
  47535. private _instanceGlowingMeshStencilReference;
  47536. private _options;
  47537. private _downSamplePostprocess;
  47538. private _horizontalBlurPostprocess;
  47539. private _verticalBlurPostprocess;
  47540. private _blurTexture;
  47541. private _meshes;
  47542. private _excludedMeshes;
  47543. /**
  47544. * Instantiates a new highlight Layer and references it to the scene..
  47545. * @param name The name of the layer
  47546. * @param scene The scene to use the layer in
  47547. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47548. */
  47549. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47550. /**
  47551. * Get the effect name of the layer.
  47552. * @return The effect name
  47553. */
  47554. getEffectName(): string;
  47555. /**
  47556. * Create the merge effect. This is the shader use to blit the information back
  47557. * to the main canvas at the end of the scene rendering.
  47558. */
  47559. protected _createMergeEffect(): Effect;
  47560. /**
  47561. * Creates the render target textures and post processes used in the highlight layer.
  47562. */
  47563. protected _createTextureAndPostProcesses(): void;
  47564. /**
  47565. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47566. */
  47567. needStencil(): boolean;
  47568. /**
  47569. * Checks for the readiness of the element composing the layer.
  47570. * @param subMesh the mesh to check for
  47571. * @param useInstances specify wether or not to use instances to render the mesh
  47572. * @param emissiveTexture the associated emissive texture used to generate the glow
  47573. * @return true if ready otherwise, false
  47574. */
  47575. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47576. /**
  47577. * Implementation specific of rendering the generating effect on the main canvas.
  47578. * @param effect The effect used to render through
  47579. */
  47580. protected _internalRender(effect: Effect): void;
  47581. /**
  47582. * Returns true if the layer contains information to display, otherwise false.
  47583. */
  47584. shouldRender(): boolean;
  47585. /**
  47586. * Returns true if the mesh should render, otherwise false.
  47587. * @param mesh The mesh to render
  47588. * @returns true if it should render otherwise false
  47589. */
  47590. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47591. /**
  47592. * Sets the required values for both the emissive texture and and the main color.
  47593. */
  47594. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47595. /**
  47596. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47597. * @param mesh The mesh to exclude from the highlight layer
  47598. */
  47599. addExcludedMesh(mesh: Mesh): void;
  47600. /**
  47601. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47602. * @param mesh The mesh to highlight
  47603. */
  47604. removeExcludedMesh(mesh: Mesh): void;
  47605. /**
  47606. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47607. * @param mesh mesh to test
  47608. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47609. */
  47610. hasMesh(mesh: AbstractMesh): boolean;
  47611. /**
  47612. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47613. * @param mesh The mesh to highlight
  47614. * @param color The color of the highlight
  47615. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47616. */
  47617. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47618. /**
  47619. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47620. * @param mesh The mesh to highlight
  47621. */
  47622. removeMesh(mesh: Mesh): void;
  47623. /**
  47624. * Force the stencil to the normal expected value for none glowing parts
  47625. */
  47626. private _defaultStencilReference;
  47627. /**
  47628. * Free any resources and references associated to a mesh.
  47629. * Internal use
  47630. * @param mesh The mesh to free.
  47631. * @hidden
  47632. */
  47633. _disposeMesh(mesh: Mesh): void;
  47634. /**
  47635. * Dispose the highlight layer and free resources.
  47636. */
  47637. dispose(): void;
  47638. /**
  47639. * Gets the class name of the effect layer
  47640. * @returns the string with the class name of the effect layer
  47641. */
  47642. getClassName(): string;
  47643. /**
  47644. * Serializes this Highlight layer
  47645. * @returns a serialized Highlight layer object
  47646. */
  47647. serialize(): any;
  47648. /**
  47649. * Creates a Highlight layer from parsed Highlight layer data
  47650. * @param parsedHightlightLayer defines the Highlight layer data
  47651. * @param scene defines the current scene
  47652. * @param rootUrl defines the root URL containing the Highlight layer information
  47653. * @returns a parsed Highlight layer
  47654. */
  47655. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47656. }
  47657. }
  47658. declare module BABYLON {
  47659. /** @hidden */
  47660. export var lensFlarePixelShader: {
  47661. name: string;
  47662. shader: string;
  47663. };
  47664. }
  47665. declare module BABYLON {
  47666. /** @hidden */
  47667. export var lensFlareVertexShader: {
  47668. name: string;
  47669. shader: string;
  47670. };
  47671. }
  47672. declare module BABYLON {
  47673. /**
  47674. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47675. * It is usually composed of several `lensFlare`.
  47676. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47677. */
  47678. export class LensFlareSystem {
  47679. /**
  47680. * Define the name of the lens flare system
  47681. */
  47682. name: string;
  47683. /**
  47684. * List of lens flares used in this system.
  47685. */
  47686. lensFlares: LensFlare[];
  47687. /**
  47688. * Define a limit from the border the lens flare can be visible.
  47689. */
  47690. borderLimit: number;
  47691. /**
  47692. * Define a viewport border we do not want to see the lens flare in.
  47693. */
  47694. viewportBorder: number;
  47695. /**
  47696. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47697. */
  47698. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47699. /**
  47700. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47701. */
  47702. layerMask: number;
  47703. /**
  47704. * Define the id of the lens flare system in the scene.
  47705. * (equal to name by default)
  47706. */
  47707. id: string;
  47708. private _scene;
  47709. private _emitter;
  47710. private _vertexBuffers;
  47711. private _indexBuffer;
  47712. private _effect;
  47713. private _positionX;
  47714. private _positionY;
  47715. private _isEnabled;
  47716. /** @hidden */
  47717. static _SceneComponentInitialization: (scene: Scene) => void;
  47718. /**
  47719. * Instantiates a lens flare system.
  47720. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47721. * It is usually composed of several `lensFlare`.
  47722. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47723. * @param name Define the name of the lens flare system in the scene
  47724. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47725. * @param scene Define the scene the lens flare system belongs to
  47726. */
  47727. constructor(
  47728. /**
  47729. * Define the name of the lens flare system
  47730. */
  47731. name: string, emitter: any, scene: Scene);
  47732. /**
  47733. * Define if the lens flare system is enabled.
  47734. */
  47735. isEnabled: boolean;
  47736. /**
  47737. * Get the scene the effects belongs to.
  47738. * @returns the scene holding the lens flare system
  47739. */
  47740. getScene(): Scene;
  47741. /**
  47742. * Get the emitter of the lens flare system.
  47743. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47744. * @returns the emitter of the lens flare system
  47745. */
  47746. getEmitter(): any;
  47747. /**
  47748. * Set the emitter of the lens flare system.
  47749. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47750. * @param newEmitter Define the new emitter of the system
  47751. */
  47752. setEmitter(newEmitter: any): void;
  47753. /**
  47754. * Get the lens flare system emitter position.
  47755. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47756. * @returns the position
  47757. */
  47758. getEmitterPosition(): Vector3;
  47759. /**
  47760. * @hidden
  47761. */
  47762. computeEffectivePosition(globalViewport: Viewport): boolean;
  47763. /** @hidden */
  47764. _isVisible(): boolean;
  47765. /**
  47766. * @hidden
  47767. */
  47768. render(): boolean;
  47769. /**
  47770. * Dispose and release the lens flare with its associated resources.
  47771. */
  47772. dispose(): void;
  47773. /**
  47774. * Parse a lens flare system from a JSON repressentation
  47775. * @param parsedLensFlareSystem Define the JSON to parse
  47776. * @param scene Define the scene the parsed system should be instantiated in
  47777. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47778. * @returns the parsed system
  47779. */
  47780. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47781. /**
  47782. * Serialize the current Lens Flare System into a JSON representation.
  47783. * @returns the serialized JSON
  47784. */
  47785. serialize(): any;
  47786. }
  47787. }
  47788. declare module BABYLON {
  47789. /**
  47790. * This represents one of the lens effect in a `lensFlareSystem`.
  47791. * It controls one of the indiviual texture used in the effect.
  47792. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47793. */
  47794. export class LensFlare {
  47795. /**
  47796. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47797. */
  47798. size: number;
  47799. /**
  47800. * 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.
  47801. */
  47802. position: number;
  47803. /**
  47804. * Define the lens color.
  47805. */
  47806. color: Color3;
  47807. /**
  47808. * Define the lens texture.
  47809. */
  47810. texture: Nullable<Texture>;
  47811. /**
  47812. * Define the alpha mode to render this particular lens.
  47813. */
  47814. alphaMode: number;
  47815. private _system;
  47816. /**
  47817. * Creates a new Lens Flare.
  47818. * This represents one of the lens effect in a `lensFlareSystem`.
  47819. * It controls one of the indiviual texture used in the effect.
  47820. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47821. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47822. * @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.
  47823. * @param color Define the lens color
  47824. * @param imgUrl Define the lens texture url
  47825. * @param system Define the `lensFlareSystem` this flare is part of
  47826. * @returns The newly created Lens Flare
  47827. */
  47828. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47829. /**
  47830. * Instantiates a new Lens Flare.
  47831. * This represents one of the lens effect in a `lensFlareSystem`.
  47832. * It controls one of the indiviual texture used in the effect.
  47833. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47834. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47835. * @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.
  47836. * @param color Define the lens color
  47837. * @param imgUrl Define the lens texture url
  47838. * @param system Define the `lensFlareSystem` this flare is part of
  47839. */
  47840. constructor(
  47841. /**
  47842. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47843. */
  47844. size: number,
  47845. /**
  47846. * 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.
  47847. */
  47848. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47849. /**
  47850. * Dispose and release the lens flare with its associated resources.
  47851. */
  47852. dispose(): void;
  47853. }
  47854. }
  47855. declare module BABYLON {
  47856. interface AbstractScene {
  47857. /**
  47858. * The list of lens flare system added to the scene
  47859. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47860. */
  47861. lensFlareSystems: Array<LensFlareSystem>;
  47862. /**
  47863. * Removes the given lens flare system from this scene.
  47864. * @param toRemove The lens flare system to remove
  47865. * @returns The index of the removed lens flare system
  47866. */
  47867. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47868. /**
  47869. * Adds the given lens flare system to this scene
  47870. * @param newLensFlareSystem The lens flare system to add
  47871. */
  47872. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47873. /**
  47874. * Gets a lens flare system using its name
  47875. * @param name defines the name to look for
  47876. * @returns the lens flare system or null if not found
  47877. */
  47878. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47879. /**
  47880. * Gets a lens flare system using its id
  47881. * @param id defines the id to look for
  47882. * @returns the lens flare system or null if not found
  47883. */
  47884. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47885. }
  47886. /**
  47887. * Defines the lens flare scene component responsible to manage any lens flares
  47888. * in a given scene.
  47889. */
  47890. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47891. /**
  47892. * The component name helpfull to identify the component in the list of scene components.
  47893. */
  47894. readonly name: string;
  47895. /**
  47896. * The scene the component belongs to.
  47897. */
  47898. scene: Scene;
  47899. /**
  47900. * Creates a new instance of the component for the given scene
  47901. * @param scene Defines the scene to register the component in
  47902. */
  47903. constructor(scene: Scene);
  47904. /**
  47905. * Registers the component in a given scene
  47906. */
  47907. register(): void;
  47908. /**
  47909. * Rebuilds the elements related to this component in case of
  47910. * context lost for instance.
  47911. */
  47912. rebuild(): void;
  47913. /**
  47914. * Adds all the element from the container to the scene
  47915. * @param container the container holding the elements
  47916. */
  47917. addFromContainer(container: AbstractScene): void;
  47918. /**
  47919. * Removes all the elements in the container from the scene
  47920. * @param container contains the elements to remove
  47921. * @param dispose if the removed element should be disposed (default: false)
  47922. */
  47923. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47924. /**
  47925. * Serializes the component data to the specified json object
  47926. * @param serializationObject The object to serialize to
  47927. */
  47928. serialize(serializationObject: any): void;
  47929. /**
  47930. * Disposes the component and the associated ressources.
  47931. */
  47932. dispose(): void;
  47933. private _draw;
  47934. }
  47935. }
  47936. declare module BABYLON {
  47937. /**
  47938. * Defines the shadow generator component responsible to manage any shadow generators
  47939. * in a given scene.
  47940. */
  47941. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47942. /**
  47943. * The component name helpfull to identify the component in the list of scene components.
  47944. */
  47945. readonly name: string;
  47946. /**
  47947. * The scene the component belongs to.
  47948. */
  47949. scene: Scene;
  47950. /**
  47951. * Creates a new instance of the component for the given scene
  47952. * @param scene Defines the scene to register the component in
  47953. */
  47954. constructor(scene: Scene);
  47955. /**
  47956. * Registers the component in a given scene
  47957. */
  47958. register(): void;
  47959. /**
  47960. * Rebuilds the elements related to this component in case of
  47961. * context lost for instance.
  47962. */
  47963. rebuild(): void;
  47964. /**
  47965. * Serializes the component data to the specified json object
  47966. * @param serializationObject The object to serialize to
  47967. */
  47968. serialize(serializationObject: any): void;
  47969. /**
  47970. * Adds all the element from the container to the scene
  47971. * @param container the container holding the elements
  47972. */
  47973. addFromContainer(container: AbstractScene): void;
  47974. /**
  47975. * Removes all the elements in the container from the scene
  47976. * @param container contains the elements to remove
  47977. * @param dispose if the removed element should be disposed (default: false)
  47978. */
  47979. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47980. /**
  47981. * Rebuilds the elements related to this component in case of
  47982. * context lost for instance.
  47983. */
  47984. dispose(): void;
  47985. private _gatherRenderTargets;
  47986. }
  47987. }
  47988. declare module BABYLON {
  47989. /**
  47990. * A point light is a light defined by an unique point in world space.
  47991. * The light is emitted in every direction from this point.
  47992. * A good example of a point light is a standard light bulb.
  47993. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47994. */
  47995. export class PointLight extends ShadowLight {
  47996. private _shadowAngle;
  47997. /**
  47998. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47999. * This specifies what angle the shadow will use to be created.
  48000. *
  48001. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48002. */
  48003. /**
  48004. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48005. * This specifies what angle the shadow will use to be created.
  48006. *
  48007. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48008. */
  48009. shadowAngle: number;
  48010. /**
  48011. * Gets the direction if it has been set.
  48012. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48013. */
  48014. /**
  48015. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48016. */
  48017. direction: Vector3;
  48018. /**
  48019. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48020. * A PointLight emits the light in every direction.
  48021. * It can cast shadows.
  48022. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48023. * ```javascript
  48024. * var pointLight = new PointLight("pl", camera.position, scene);
  48025. * ```
  48026. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48027. * @param name The light friendly name
  48028. * @param position The position of the point light in the scene
  48029. * @param scene The scene the lights belongs to
  48030. */
  48031. constructor(name: string, position: Vector3, scene: Scene);
  48032. /**
  48033. * Returns the string "PointLight"
  48034. * @returns the class name
  48035. */
  48036. getClassName(): string;
  48037. /**
  48038. * Returns the integer 0.
  48039. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48040. */
  48041. getTypeID(): number;
  48042. /**
  48043. * Specifies wether or not the shadowmap should be a cube texture.
  48044. * @returns true if the shadowmap needs to be a cube texture.
  48045. */
  48046. needCube(): boolean;
  48047. /**
  48048. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48049. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48050. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48051. */
  48052. getShadowDirection(faceIndex?: number): Vector3;
  48053. /**
  48054. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48055. * - fov = PI / 2
  48056. * - aspect ratio : 1.0
  48057. * - z-near and far equal to the active camera minZ and maxZ.
  48058. * Returns the PointLight.
  48059. */
  48060. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48061. protected _buildUniformLayout(): void;
  48062. /**
  48063. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48064. * @param effect The effect to update
  48065. * @param lightIndex The index of the light in the effect to update
  48066. * @returns The point light
  48067. */
  48068. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48069. /**
  48070. * Prepares the list of defines specific to the light type.
  48071. * @param defines the list of defines
  48072. * @param lightIndex defines the index of the light for the effect
  48073. */
  48074. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48075. }
  48076. }
  48077. declare module BABYLON {
  48078. /**
  48079. * Header information of HDR texture files.
  48080. */
  48081. export interface HDRInfo {
  48082. /**
  48083. * The height of the texture in pixels.
  48084. */
  48085. height: number;
  48086. /**
  48087. * The width of the texture in pixels.
  48088. */
  48089. width: number;
  48090. /**
  48091. * The index of the beginning of the data in the binary file.
  48092. */
  48093. dataPosition: number;
  48094. }
  48095. /**
  48096. * This groups tools to convert HDR texture to native colors array.
  48097. */
  48098. export class HDRTools {
  48099. private static Ldexp;
  48100. private static Rgbe2float;
  48101. private static readStringLine;
  48102. /**
  48103. * Reads header information from an RGBE texture stored in a native array.
  48104. * More information on this format are available here:
  48105. * https://en.wikipedia.org/wiki/RGBE_image_format
  48106. *
  48107. * @param uint8array The binary file stored in native array.
  48108. * @return The header information.
  48109. */
  48110. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48111. /**
  48112. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48113. * This RGBE texture needs to store the information as a panorama.
  48114. *
  48115. * More information on this format are available here:
  48116. * https://en.wikipedia.org/wiki/RGBE_image_format
  48117. *
  48118. * @param buffer The binary file stored in an array buffer.
  48119. * @param size The expected size of the extracted cubemap.
  48120. * @return The Cube Map information.
  48121. */
  48122. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48123. /**
  48124. * Returns the pixels data extracted from an RGBE texture.
  48125. * This pixels will be stored left to right up to down in the R G B order in one array.
  48126. *
  48127. * More information on this format are available here:
  48128. * https://en.wikipedia.org/wiki/RGBE_image_format
  48129. *
  48130. * @param uint8array The binary file stored in an array buffer.
  48131. * @param hdrInfo The header information of the file.
  48132. * @return The pixels data in RGB right to left up to down order.
  48133. */
  48134. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48135. private static RGBE_ReadPixels_RLE;
  48136. }
  48137. }
  48138. declare module BABYLON {
  48139. /**
  48140. * This represents a texture coming from an HDR input.
  48141. *
  48142. * The only supported format is currently panorama picture stored in RGBE format.
  48143. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48144. */
  48145. export class HDRCubeTexture extends BaseTexture {
  48146. private static _facesMapping;
  48147. private _generateHarmonics;
  48148. private _noMipmap;
  48149. private _textureMatrix;
  48150. private _size;
  48151. private _onLoad;
  48152. private _onError;
  48153. /**
  48154. * The texture URL.
  48155. */
  48156. url: string;
  48157. /**
  48158. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48159. */
  48160. coordinatesMode: number;
  48161. protected _isBlocking: boolean;
  48162. /**
  48163. * Sets wether or not the texture is blocking during loading.
  48164. */
  48165. /**
  48166. * Gets wether or not the texture is blocking during loading.
  48167. */
  48168. isBlocking: boolean;
  48169. protected _rotationY: number;
  48170. /**
  48171. * Sets texture matrix rotation angle around Y axis in radians.
  48172. */
  48173. /**
  48174. * Gets texture matrix rotation angle around Y axis radians.
  48175. */
  48176. rotationY: number;
  48177. /**
  48178. * Gets or sets the center of the bounding box associated with the cube texture
  48179. * It must define where the camera used to render the texture was set
  48180. */
  48181. boundingBoxPosition: Vector3;
  48182. private _boundingBoxSize;
  48183. /**
  48184. * Gets or sets the size of the bounding box associated with the cube texture
  48185. * When defined, the cubemap will switch to local mode
  48186. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48187. * @example https://www.babylonjs-playground.com/#RNASML
  48188. */
  48189. boundingBoxSize: Vector3;
  48190. /**
  48191. * Instantiates an HDRTexture from the following parameters.
  48192. *
  48193. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48194. * @param scene The scene the texture will be used in
  48195. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48196. * @param noMipmap Forces to not generate the mipmap if true
  48197. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48198. * @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)
  48199. * @param reserved Reserved flag for internal use.
  48200. */
  48201. 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>);
  48202. /**
  48203. * Get the current class name of the texture useful for serialization or dynamic coding.
  48204. * @returns "HDRCubeTexture"
  48205. */
  48206. getClassName(): string;
  48207. /**
  48208. * Occurs when the file is raw .hdr file.
  48209. */
  48210. private loadTexture;
  48211. clone(): HDRCubeTexture;
  48212. delayLoad(): void;
  48213. /**
  48214. * Get the texture reflection matrix used to rotate/transform the reflection.
  48215. * @returns the reflection matrix
  48216. */
  48217. getReflectionTextureMatrix(): Matrix;
  48218. /**
  48219. * Set the texture reflection matrix used to rotate/transform the reflection.
  48220. * @param value Define the reflection matrix to set
  48221. */
  48222. setReflectionTextureMatrix(value: Matrix): void;
  48223. /**
  48224. * Parses a JSON representation of an HDR Texture in order to create the texture
  48225. * @param parsedTexture Define the JSON representation
  48226. * @param scene Define the scene the texture should be created in
  48227. * @param rootUrl Define the root url in case we need to load relative dependencies
  48228. * @returns the newly created texture after parsing
  48229. */
  48230. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48231. serialize(): any;
  48232. }
  48233. }
  48234. declare module BABYLON {
  48235. /**
  48236. * Class used to control physics engine
  48237. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48238. */
  48239. export class PhysicsEngine implements IPhysicsEngine {
  48240. private _physicsPlugin;
  48241. /**
  48242. * Global value used to control the smallest number supported by the simulation
  48243. */
  48244. static Epsilon: number;
  48245. private _impostors;
  48246. private _joints;
  48247. /**
  48248. * Gets the gravity vector used by the simulation
  48249. */
  48250. gravity: Vector3;
  48251. /**
  48252. * Factory used to create the default physics plugin.
  48253. * @returns The default physics plugin
  48254. */
  48255. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48256. /**
  48257. * Creates a new Physics Engine
  48258. * @param gravity defines the gravity vector used by the simulation
  48259. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48260. */
  48261. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48262. /**
  48263. * Sets the gravity vector used by the simulation
  48264. * @param gravity defines the gravity vector to use
  48265. */
  48266. setGravity(gravity: Vector3): void;
  48267. /**
  48268. * Set the time step of the physics engine.
  48269. * Default is 1/60.
  48270. * To slow it down, enter 1/600 for example.
  48271. * To speed it up, 1/30
  48272. * @param newTimeStep defines the new timestep to apply to this world.
  48273. */
  48274. setTimeStep(newTimeStep?: number): void;
  48275. /**
  48276. * Get the time step of the physics engine.
  48277. * @returns the current time step
  48278. */
  48279. getTimeStep(): number;
  48280. /**
  48281. * Release all resources
  48282. */
  48283. dispose(): void;
  48284. /**
  48285. * Gets the name of the current physics plugin
  48286. * @returns the name of the plugin
  48287. */
  48288. getPhysicsPluginName(): string;
  48289. /**
  48290. * Adding a new impostor for the impostor tracking.
  48291. * This will be done by the impostor itself.
  48292. * @param impostor the impostor to add
  48293. */
  48294. addImpostor(impostor: PhysicsImpostor): void;
  48295. /**
  48296. * Remove an impostor from the engine.
  48297. * This impostor and its mesh will not longer be updated by the physics engine.
  48298. * @param impostor the impostor to remove
  48299. */
  48300. removeImpostor(impostor: PhysicsImpostor): void;
  48301. /**
  48302. * Add a joint to the physics engine
  48303. * @param mainImpostor defines the main impostor to which the joint is added.
  48304. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48305. * @param joint defines the joint that will connect both impostors.
  48306. */
  48307. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48308. /**
  48309. * Removes a joint from the simulation
  48310. * @param mainImpostor defines the impostor used with the joint
  48311. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48312. * @param joint defines the joint to remove
  48313. */
  48314. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48315. /**
  48316. * Called by the scene. No need to call it.
  48317. * @param delta defines the timespam between frames
  48318. */
  48319. _step(delta: number): void;
  48320. /**
  48321. * Gets the current plugin used to run the simulation
  48322. * @returns current plugin
  48323. */
  48324. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48325. /**
  48326. * Gets the list of physic impostors
  48327. * @returns an array of PhysicsImpostor
  48328. */
  48329. getImpostors(): Array<PhysicsImpostor>;
  48330. /**
  48331. * Gets the impostor for a physics enabled object
  48332. * @param object defines the object impersonated by the impostor
  48333. * @returns the PhysicsImpostor or null if not found
  48334. */
  48335. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48336. /**
  48337. * Gets the impostor for a physics body object
  48338. * @param body defines physics body used by the impostor
  48339. * @returns the PhysicsImpostor or null if not found
  48340. */
  48341. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48342. /**
  48343. * Does a raycast in the physics world
  48344. * @param from when should the ray start?
  48345. * @param to when should the ray end?
  48346. * @returns PhysicsRaycastResult
  48347. */
  48348. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48349. }
  48350. }
  48351. declare module BABYLON {
  48352. /** @hidden */
  48353. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48354. private _useDeltaForWorldStep;
  48355. world: any;
  48356. name: string;
  48357. private _physicsMaterials;
  48358. private _fixedTimeStep;
  48359. private _cannonRaycastResult;
  48360. private _raycastResult;
  48361. private _removeAfterStep;
  48362. BJSCANNON: any;
  48363. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48364. setGravity(gravity: Vector3): void;
  48365. setTimeStep(timeStep: number): void;
  48366. getTimeStep(): number;
  48367. executeStep(delta: number): void;
  48368. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48369. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48370. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48371. private _processChildMeshes;
  48372. removePhysicsBody(impostor: PhysicsImpostor): void;
  48373. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48374. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48375. private _addMaterial;
  48376. private _checkWithEpsilon;
  48377. private _createShape;
  48378. private _createHeightmap;
  48379. private _minus90X;
  48380. private _plus90X;
  48381. private _tmpPosition;
  48382. private _tmpDeltaPosition;
  48383. private _tmpUnityRotation;
  48384. private _updatePhysicsBodyTransformation;
  48385. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48386. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48387. isSupported(): boolean;
  48388. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48389. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48390. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48391. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48392. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48393. getBodyMass(impostor: PhysicsImpostor): number;
  48394. getBodyFriction(impostor: PhysicsImpostor): number;
  48395. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48396. getBodyRestitution(impostor: PhysicsImpostor): number;
  48397. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48398. sleepBody(impostor: PhysicsImpostor): void;
  48399. wakeUpBody(impostor: PhysicsImpostor): void;
  48400. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48401. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48402. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48403. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48404. getRadius(impostor: PhysicsImpostor): number;
  48405. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48406. dispose(): void;
  48407. private _extendNamespace;
  48408. /**
  48409. * Does a raycast in the physics world
  48410. * @param from when should the ray start?
  48411. * @param to when should the ray end?
  48412. * @returns PhysicsRaycastResult
  48413. */
  48414. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48415. }
  48416. }
  48417. declare module BABYLON {
  48418. /** @hidden */
  48419. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48420. world: any;
  48421. name: string;
  48422. BJSOIMO: any;
  48423. private _raycastResult;
  48424. constructor(iterations?: number, oimoInjection?: any);
  48425. setGravity(gravity: Vector3): void;
  48426. setTimeStep(timeStep: number): void;
  48427. getTimeStep(): number;
  48428. private _tmpImpostorsArray;
  48429. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48430. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48431. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48432. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48433. private _tmpPositionVector;
  48434. removePhysicsBody(impostor: PhysicsImpostor): void;
  48435. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48436. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48437. isSupported(): boolean;
  48438. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48439. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48440. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48441. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48442. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48443. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48444. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48445. getBodyMass(impostor: PhysicsImpostor): number;
  48446. getBodyFriction(impostor: PhysicsImpostor): number;
  48447. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48448. getBodyRestitution(impostor: PhysicsImpostor): number;
  48449. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48450. sleepBody(impostor: PhysicsImpostor): void;
  48451. wakeUpBody(impostor: PhysicsImpostor): void;
  48452. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48453. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48454. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48455. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48456. getRadius(impostor: PhysicsImpostor): number;
  48457. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48458. dispose(): void;
  48459. /**
  48460. * Does a raycast in the physics world
  48461. * @param from when should the ray start?
  48462. * @param to when should the ray end?
  48463. * @returns PhysicsRaycastResult
  48464. */
  48465. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48466. }
  48467. }
  48468. declare module BABYLON {
  48469. /**
  48470. * Class containing static functions to help procedurally build meshes
  48471. */
  48472. export class RibbonBuilder {
  48473. /**
  48474. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48475. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48476. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48477. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48478. * * 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
  48479. * * 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
  48480. * * 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
  48481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48482. * * 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
  48483. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48484. * * 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
  48485. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48486. * * 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
  48487. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48489. * @param name defines the name of the mesh
  48490. * @param options defines the options used to create the mesh
  48491. * @param scene defines the hosting scene
  48492. * @returns the ribbon mesh
  48493. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48494. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48495. */
  48496. static CreateRibbon(name: string, options: {
  48497. pathArray: Vector3[][];
  48498. closeArray?: boolean;
  48499. closePath?: boolean;
  48500. offset?: number;
  48501. updatable?: boolean;
  48502. sideOrientation?: number;
  48503. frontUVs?: Vector4;
  48504. backUVs?: Vector4;
  48505. instance?: Mesh;
  48506. invertUV?: boolean;
  48507. uvs?: Vector2[];
  48508. colors?: Color4[];
  48509. }, scene?: Nullable<Scene>): Mesh;
  48510. }
  48511. }
  48512. declare module BABYLON {
  48513. /**
  48514. * Class containing static functions to help procedurally build meshes
  48515. */
  48516. export class ShapeBuilder {
  48517. /**
  48518. * 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.
  48519. * * 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.
  48520. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48521. * * 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.
  48522. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48523. * * 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
  48524. * * 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
  48525. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48527. * * 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
  48528. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48530. * @param name defines the name of the mesh
  48531. * @param options defines the options used to create the mesh
  48532. * @param scene defines the hosting scene
  48533. * @returns the extruded shape mesh
  48534. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48535. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48536. */
  48537. static ExtrudeShape(name: string, options: {
  48538. shape: Vector3[];
  48539. path: Vector3[];
  48540. scale?: number;
  48541. rotation?: number;
  48542. cap?: number;
  48543. updatable?: boolean;
  48544. sideOrientation?: number;
  48545. frontUVs?: Vector4;
  48546. backUVs?: Vector4;
  48547. instance?: Mesh;
  48548. invertUV?: boolean;
  48549. }, scene?: Nullable<Scene>): Mesh;
  48550. /**
  48551. * Creates an custom extruded shape mesh.
  48552. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48553. * * 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.
  48554. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48555. * * 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
  48556. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48557. * * 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
  48558. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48559. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48560. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48561. * * 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
  48562. * * 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
  48563. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48565. * * 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
  48566. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48568. * @param name defines the name of the mesh
  48569. * @param options defines the options used to create the mesh
  48570. * @param scene defines the hosting scene
  48571. * @returns the custom extruded shape mesh
  48572. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48573. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48574. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48575. */
  48576. static ExtrudeShapeCustom(name: string, options: {
  48577. shape: Vector3[];
  48578. path: Vector3[];
  48579. scaleFunction?: any;
  48580. rotationFunction?: any;
  48581. ribbonCloseArray?: boolean;
  48582. ribbonClosePath?: boolean;
  48583. cap?: number;
  48584. updatable?: boolean;
  48585. sideOrientation?: number;
  48586. frontUVs?: Vector4;
  48587. backUVs?: Vector4;
  48588. instance?: Mesh;
  48589. invertUV?: boolean;
  48590. }, scene?: Nullable<Scene>): Mesh;
  48591. private static _ExtrudeShapeGeneric;
  48592. }
  48593. }
  48594. declare module BABYLON {
  48595. /**
  48596. * AmmoJS Physics plugin
  48597. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48598. * @see https://github.com/kripken/ammo.js/
  48599. */
  48600. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48601. private _useDeltaForWorldStep;
  48602. /**
  48603. * Reference to the Ammo library
  48604. */
  48605. bjsAMMO: any;
  48606. /**
  48607. * Created ammoJS world which physics bodies are added to
  48608. */
  48609. world: any;
  48610. /**
  48611. * Name of the plugin
  48612. */
  48613. name: string;
  48614. private _timeStep;
  48615. private _fixedTimeStep;
  48616. private _maxSteps;
  48617. private _tmpQuaternion;
  48618. private _tmpAmmoTransform;
  48619. private _tmpAmmoQuaternion;
  48620. private _tmpAmmoConcreteContactResultCallback;
  48621. private _collisionConfiguration;
  48622. private _dispatcher;
  48623. private _overlappingPairCache;
  48624. private _solver;
  48625. private _softBodySolver;
  48626. private _tmpAmmoVectorA;
  48627. private _tmpAmmoVectorB;
  48628. private _tmpAmmoVectorC;
  48629. private _tmpAmmoVectorD;
  48630. private _tmpContactCallbackResult;
  48631. private _tmpAmmoVectorRCA;
  48632. private _tmpAmmoVectorRCB;
  48633. private _raycastResult;
  48634. private static readonly DISABLE_COLLISION_FLAG;
  48635. private static readonly KINEMATIC_FLAG;
  48636. private static readonly DISABLE_DEACTIVATION_FLAG;
  48637. /**
  48638. * Initializes the ammoJS plugin
  48639. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48640. * @param ammoInjection can be used to inject your own ammo reference
  48641. */
  48642. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48643. /**
  48644. * Sets the gravity of the physics world (m/(s^2))
  48645. * @param gravity Gravity to set
  48646. */
  48647. setGravity(gravity: Vector3): void;
  48648. /**
  48649. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48650. * @param timeStep timestep to use in seconds
  48651. */
  48652. setTimeStep(timeStep: number): void;
  48653. /**
  48654. * 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)
  48655. * @param fixedTimeStep fixedTimeStep to use in seconds
  48656. */
  48657. setFixedTimeStep(fixedTimeStep: number): void;
  48658. /**
  48659. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48660. * @param maxSteps the maximum number of steps by the physics engine per frame
  48661. */
  48662. setMaxSteps(maxSteps: number): void;
  48663. /**
  48664. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48665. * @returns the current timestep in seconds
  48666. */
  48667. getTimeStep(): number;
  48668. private _isImpostorInContact;
  48669. private _isImpostorPairInContact;
  48670. private _stepSimulation;
  48671. /**
  48672. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48673. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48674. * After the step the babylon meshes are set to the position of the physics imposters
  48675. * @param delta amount of time to step forward
  48676. * @param impostors array of imposters to update before/after the step
  48677. */
  48678. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48679. /**
  48680. * Update babylon mesh to match physics world object
  48681. * @param impostor imposter to match
  48682. */
  48683. private _afterSoftStep;
  48684. /**
  48685. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48686. * @param impostor imposter to match
  48687. */
  48688. private _ropeStep;
  48689. /**
  48690. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48691. * @param impostor imposter to match
  48692. */
  48693. private _softbodyOrClothStep;
  48694. private _tmpVector;
  48695. private _tmpMatrix;
  48696. /**
  48697. * Applies an impulse on the imposter
  48698. * @param impostor imposter to apply impulse to
  48699. * @param force amount of force to be applied to the imposter
  48700. * @param contactPoint the location to apply the impulse on the imposter
  48701. */
  48702. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48703. /**
  48704. * Applies a force on the imposter
  48705. * @param impostor imposter to apply force
  48706. * @param force amount of force to be applied to the imposter
  48707. * @param contactPoint the location to apply the force on the imposter
  48708. */
  48709. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48710. /**
  48711. * Creates a physics body using the plugin
  48712. * @param impostor the imposter to create the physics body on
  48713. */
  48714. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48715. /**
  48716. * Removes the physics body from the imposter and disposes of the body's memory
  48717. * @param impostor imposter to remove the physics body from
  48718. */
  48719. removePhysicsBody(impostor: PhysicsImpostor): void;
  48720. /**
  48721. * Generates a joint
  48722. * @param impostorJoint the imposter joint to create the joint with
  48723. */
  48724. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48725. /**
  48726. * Removes a joint
  48727. * @param impostorJoint the imposter joint to remove the joint from
  48728. */
  48729. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48730. private _addMeshVerts;
  48731. /**
  48732. * Initialise the soft body vertices to match its object's (mesh) vertices
  48733. * Softbody vertices (nodes) are in world space and to match this
  48734. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48735. * @param impostor to create the softbody for
  48736. */
  48737. private _softVertexData;
  48738. /**
  48739. * Create an impostor's soft body
  48740. * @param impostor to create the softbody for
  48741. */
  48742. private _createSoftbody;
  48743. /**
  48744. * Create cloth for an impostor
  48745. * @param impostor to create the softbody for
  48746. */
  48747. private _createCloth;
  48748. /**
  48749. * Create rope for an impostor
  48750. * @param impostor to create the softbody for
  48751. */
  48752. private _createRope;
  48753. private _addHullVerts;
  48754. private _createShape;
  48755. /**
  48756. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48757. * @param impostor imposter containing the physics body and babylon object
  48758. */
  48759. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48760. /**
  48761. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48762. * @param impostor imposter containing the physics body and babylon object
  48763. * @param newPosition new position
  48764. * @param newRotation new rotation
  48765. */
  48766. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48767. /**
  48768. * If this plugin is supported
  48769. * @returns true if its supported
  48770. */
  48771. isSupported(): boolean;
  48772. /**
  48773. * Sets the linear velocity of the physics body
  48774. * @param impostor imposter to set the velocity on
  48775. * @param velocity velocity to set
  48776. */
  48777. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48778. /**
  48779. * Sets the angular velocity of the physics body
  48780. * @param impostor imposter to set the velocity on
  48781. * @param velocity velocity to set
  48782. */
  48783. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48784. /**
  48785. * gets the linear velocity
  48786. * @param impostor imposter to get linear velocity from
  48787. * @returns linear velocity
  48788. */
  48789. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48790. /**
  48791. * gets the angular velocity
  48792. * @param impostor imposter to get angular velocity from
  48793. * @returns angular velocity
  48794. */
  48795. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48796. /**
  48797. * Sets the mass of physics body
  48798. * @param impostor imposter to set the mass on
  48799. * @param mass mass to set
  48800. */
  48801. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48802. /**
  48803. * Gets the mass of the physics body
  48804. * @param impostor imposter to get the mass from
  48805. * @returns mass
  48806. */
  48807. getBodyMass(impostor: PhysicsImpostor): number;
  48808. /**
  48809. * Gets friction of the impostor
  48810. * @param impostor impostor to get friction from
  48811. * @returns friction value
  48812. */
  48813. getBodyFriction(impostor: PhysicsImpostor): number;
  48814. /**
  48815. * Sets friction of the impostor
  48816. * @param impostor impostor to set friction on
  48817. * @param friction friction value
  48818. */
  48819. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48820. /**
  48821. * Gets restitution of the impostor
  48822. * @param impostor impostor to get restitution from
  48823. * @returns restitution value
  48824. */
  48825. getBodyRestitution(impostor: PhysicsImpostor): number;
  48826. /**
  48827. * Sets resitution of the impostor
  48828. * @param impostor impostor to set resitution on
  48829. * @param restitution resitution value
  48830. */
  48831. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48832. /**
  48833. * Gets pressure inside the impostor
  48834. * @param impostor impostor to get pressure from
  48835. * @returns pressure value
  48836. */
  48837. getBodyPressure(impostor: PhysicsImpostor): number;
  48838. /**
  48839. * Sets pressure inside a soft body impostor
  48840. * Cloth and rope must remain 0 pressure
  48841. * @param impostor impostor to set pressure on
  48842. * @param pressure pressure value
  48843. */
  48844. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48845. /**
  48846. * Gets stiffness of the impostor
  48847. * @param impostor impostor to get stiffness from
  48848. * @returns pressure value
  48849. */
  48850. getBodyStiffness(impostor: PhysicsImpostor): number;
  48851. /**
  48852. * Sets stiffness of the impostor
  48853. * @param impostor impostor to set stiffness on
  48854. * @param stiffness stiffness value from 0 to 1
  48855. */
  48856. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48857. /**
  48858. * Gets velocityIterations of the impostor
  48859. * @param impostor impostor to get velocity iterations from
  48860. * @returns velocityIterations value
  48861. */
  48862. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48863. /**
  48864. * Sets velocityIterations of the impostor
  48865. * @param impostor impostor to set velocity iterations on
  48866. * @param velocityIterations velocityIterations value
  48867. */
  48868. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48869. /**
  48870. * Gets positionIterations of the impostor
  48871. * @param impostor impostor to get position iterations from
  48872. * @returns positionIterations value
  48873. */
  48874. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48875. /**
  48876. * Sets positionIterations of the impostor
  48877. * @param impostor impostor to set position on
  48878. * @param positionIterations positionIterations value
  48879. */
  48880. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48881. /**
  48882. * Append an anchor to a cloth object
  48883. * @param impostor is the cloth impostor to add anchor to
  48884. * @param otherImpostor is the rigid impostor to anchor to
  48885. * @param width ratio across width from 0 to 1
  48886. * @param height ratio up height from 0 to 1
  48887. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48888. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48889. */
  48890. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48891. /**
  48892. * Append an hook to a rope object
  48893. * @param impostor is the rope impostor to add hook to
  48894. * @param otherImpostor is the rigid impostor to hook to
  48895. * @param length ratio along the rope from 0 to 1
  48896. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48897. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48898. */
  48899. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48900. /**
  48901. * Sleeps the physics body and stops it from being active
  48902. * @param impostor impostor to sleep
  48903. */
  48904. sleepBody(impostor: PhysicsImpostor): void;
  48905. /**
  48906. * Activates the physics body
  48907. * @param impostor impostor to activate
  48908. */
  48909. wakeUpBody(impostor: PhysicsImpostor): void;
  48910. /**
  48911. * Updates the distance parameters of the joint
  48912. * @param joint joint to update
  48913. * @param maxDistance maximum distance of the joint
  48914. * @param minDistance minimum distance of the joint
  48915. */
  48916. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48917. /**
  48918. * Sets a motor on the joint
  48919. * @param joint joint to set motor on
  48920. * @param speed speed of the motor
  48921. * @param maxForce maximum force of the motor
  48922. * @param motorIndex index of the motor
  48923. */
  48924. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48925. /**
  48926. * Sets the motors limit
  48927. * @param joint joint to set limit on
  48928. * @param upperLimit upper limit
  48929. * @param lowerLimit lower limit
  48930. */
  48931. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48932. /**
  48933. * Syncs the position and rotation of a mesh with the impostor
  48934. * @param mesh mesh to sync
  48935. * @param impostor impostor to update the mesh with
  48936. */
  48937. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48938. /**
  48939. * Gets the radius of the impostor
  48940. * @param impostor impostor to get radius from
  48941. * @returns the radius
  48942. */
  48943. getRadius(impostor: PhysicsImpostor): number;
  48944. /**
  48945. * Gets the box size of the impostor
  48946. * @param impostor impostor to get box size from
  48947. * @param result the resulting box size
  48948. */
  48949. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48950. /**
  48951. * Disposes of the impostor
  48952. */
  48953. dispose(): void;
  48954. /**
  48955. * Does a raycast in the physics world
  48956. * @param from when should the ray start?
  48957. * @param to when should the ray end?
  48958. * @returns PhysicsRaycastResult
  48959. */
  48960. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48961. }
  48962. }
  48963. declare module BABYLON {
  48964. interface AbstractScene {
  48965. /**
  48966. * The list of reflection probes added to the scene
  48967. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48968. */
  48969. reflectionProbes: Array<ReflectionProbe>;
  48970. /**
  48971. * Removes the given reflection probe from this scene.
  48972. * @param toRemove The reflection probe to remove
  48973. * @returns The index of the removed reflection probe
  48974. */
  48975. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48976. /**
  48977. * Adds the given reflection probe to this scene.
  48978. * @param newReflectionProbe The reflection probe to add
  48979. */
  48980. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48981. }
  48982. /**
  48983. * Class used to generate realtime reflection / refraction cube textures
  48984. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48985. */
  48986. export class ReflectionProbe {
  48987. /** defines the name of the probe */
  48988. name: string;
  48989. private _scene;
  48990. private _renderTargetTexture;
  48991. private _projectionMatrix;
  48992. private _viewMatrix;
  48993. private _target;
  48994. private _add;
  48995. private _attachedMesh;
  48996. private _invertYAxis;
  48997. /** Gets or sets probe position (center of the cube map) */
  48998. position: Vector3;
  48999. /**
  49000. * Creates a new reflection probe
  49001. * @param name defines the name of the probe
  49002. * @param size defines the texture resolution (for each face)
  49003. * @param scene defines the hosting scene
  49004. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49005. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49006. */
  49007. constructor(
  49008. /** defines the name of the probe */
  49009. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49010. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49011. samples: number;
  49012. /** Gets or sets the refresh rate to use (on every frame by default) */
  49013. refreshRate: number;
  49014. /**
  49015. * Gets the hosting scene
  49016. * @returns a Scene
  49017. */
  49018. getScene(): Scene;
  49019. /** Gets the internal CubeTexture used to render to */
  49020. readonly cubeTexture: RenderTargetTexture;
  49021. /** Gets the list of meshes to render */
  49022. readonly renderList: Nullable<AbstractMesh[]>;
  49023. /**
  49024. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49025. * @param mesh defines the mesh to attach to
  49026. */
  49027. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49028. /**
  49029. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49030. * @param renderingGroupId The rendering group id corresponding to its index
  49031. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49032. */
  49033. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49034. /**
  49035. * Clean all associated resources
  49036. */
  49037. dispose(): void;
  49038. /**
  49039. * Converts the reflection probe information to a readable string for debug purpose.
  49040. * @param fullDetails Supports for multiple levels of logging within scene loading
  49041. * @returns the human readable reflection probe info
  49042. */
  49043. toString(fullDetails?: boolean): string;
  49044. /**
  49045. * Get the class name of the relfection probe.
  49046. * @returns "ReflectionProbe"
  49047. */
  49048. getClassName(): string;
  49049. /**
  49050. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49051. * @returns The JSON representation of the texture
  49052. */
  49053. serialize(): any;
  49054. /**
  49055. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49056. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49057. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49058. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49059. * @returns The parsed reflection probe if successful
  49060. */
  49061. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49062. }
  49063. }
  49064. declare module BABYLON {
  49065. /** @hidden */
  49066. export var _BabylonLoaderRegistered: boolean;
  49067. }
  49068. declare module BABYLON {
  49069. /**
  49070. * The Physically based simple base material of BJS.
  49071. *
  49072. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49073. * It is used as the base class for both the specGloss and metalRough conventions.
  49074. */
  49075. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49076. /**
  49077. * Number of Simultaneous lights allowed on the material.
  49078. */
  49079. maxSimultaneousLights: number;
  49080. /**
  49081. * If sets to true, disables all the lights affecting the material.
  49082. */
  49083. disableLighting: boolean;
  49084. /**
  49085. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49086. */
  49087. environmentTexture: BaseTexture;
  49088. /**
  49089. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49090. */
  49091. invertNormalMapX: boolean;
  49092. /**
  49093. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49094. */
  49095. invertNormalMapY: boolean;
  49096. /**
  49097. * Normal map used in the model.
  49098. */
  49099. normalTexture: BaseTexture;
  49100. /**
  49101. * Emissivie color used to self-illuminate the model.
  49102. */
  49103. emissiveColor: Color3;
  49104. /**
  49105. * Emissivie texture used to self-illuminate the model.
  49106. */
  49107. emissiveTexture: BaseTexture;
  49108. /**
  49109. * Occlusion Channel Strenght.
  49110. */
  49111. occlusionStrength: number;
  49112. /**
  49113. * Occlusion Texture of the material (adding extra occlusion effects).
  49114. */
  49115. occlusionTexture: BaseTexture;
  49116. /**
  49117. * Defines the alpha limits in alpha test mode.
  49118. */
  49119. alphaCutOff: number;
  49120. /**
  49121. * Gets the current double sided mode.
  49122. */
  49123. /**
  49124. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49125. */
  49126. doubleSided: boolean;
  49127. /**
  49128. * Stores the pre-calculated light information of a mesh in a texture.
  49129. */
  49130. lightmapTexture: BaseTexture;
  49131. /**
  49132. * If true, the light map contains occlusion information instead of lighting info.
  49133. */
  49134. useLightmapAsShadowmap: boolean;
  49135. /**
  49136. * Instantiates a new PBRMaterial instance.
  49137. *
  49138. * @param name The material name
  49139. * @param scene The scene the material will be use in.
  49140. */
  49141. constructor(name: string, scene: Scene);
  49142. getClassName(): string;
  49143. }
  49144. }
  49145. declare module BABYLON {
  49146. /**
  49147. * The PBR material of BJS following the metal roughness convention.
  49148. *
  49149. * This fits to the PBR convention in the GLTF definition:
  49150. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49151. */
  49152. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49153. /**
  49154. * The base color has two different interpretations depending on the value of metalness.
  49155. * When the material is a metal, the base color is the specific measured reflectance value
  49156. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49157. * of the material.
  49158. */
  49159. baseColor: Color3;
  49160. /**
  49161. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49162. * well as opacity information in the alpha channel.
  49163. */
  49164. baseTexture: BaseTexture;
  49165. /**
  49166. * Specifies the metallic scalar value of the material.
  49167. * Can also be used to scale the metalness values of the metallic texture.
  49168. */
  49169. metallic: number;
  49170. /**
  49171. * Specifies the roughness scalar value of the material.
  49172. * Can also be used to scale the roughness values of the metallic texture.
  49173. */
  49174. roughness: number;
  49175. /**
  49176. * Texture containing both the metallic value in the B channel and the
  49177. * roughness value in the G channel to keep better precision.
  49178. */
  49179. metallicRoughnessTexture: BaseTexture;
  49180. /**
  49181. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49182. *
  49183. * @param name The material name
  49184. * @param scene The scene the material will be use in.
  49185. */
  49186. constructor(name: string, scene: Scene);
  49187. /**
  49188. * Return the currrent class name of the material.
  49189. */
  49190. getClassName(): string;
  49191. /**
  49192. * Makes a duplicate of the current material.
  49193. * @param name - name to use for the new material.
  49194. */
  49195. clone(name: string): PBRMetallicRoughnessMaterial;
  49196. /**
  49197. * Serialize the material to a parsable JSON object.
  49198. */
  49199. serialize(): any;
  49200. /**
  49201. * Parses a JSON object correponding to the serialize function.
  49202. */
  49203. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49204. }
  49205. }
  49206. declare module BABYLON {
  49207. /**
  49208. * The PBR material of BJS following the specular glossiness convention.
  49209. *
  49210. * This fits to the PBR convention in the GLTF definition:
  49211. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49212. */
  49213. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49214. /**
  49215. * Specifies the diffuse color of the material.
  49216. */
  49217. diffuseColor: Color3;
  49218. /**
  49219. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49220. * channel.
  49221. */
  49222. diffuseTexture: BaseTexture;
  49223. /**
  49224. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49225. */
  49226. specularColor: Color3;
  49227. /**
  49228. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49229. */
  49230. glossiness: number;
  49231. /**
  49232. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49233. */
  49234. specularGlossinessTexture: BaseTexture;
  49235. /**
  49236. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49237. *
  49238. * @param name The material name
  49239. * @param scene The scene the material will be use in.
  49240. */
  49241. constructor(name: string, scene: Scene);
  49242. /**
  49243. * Return the currrent class name of the material.
  49244. */
  49245. getClassName(): string;
  49246. /**
  49247. * Makes a duplicate of the current material.
  49248. * @param name - name to use for the new material.
  49249. */
  49250. clone(name: string): PBRSpecularGlossinessMaterial;
  49251. /**
  49252. * Serialize the material to a parsable JSON object.
  49253. */
  49254. serialize(): any;
  49255. /**
  49256. * Parses a JSON object correponding to the serialize function.
  49257. */
  49258. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49259. }
  49260. }
  49261. declare module BABYLON {
  49262. /**
  49263. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49264. * It can help converting any input color in a desired output one. This can then be used to create effects
  49265. * from sepia, black and white to sixties or futuristic rendering...
  49266. *
  49267. * The only supported format is currently 3dl.
  49268. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49269. */
  49270. export class ColorGradingTexture extends BaseTexture {
  49271. /**
  49272. * The current texture matrix. (will always be identity in color grading texture)
  49273. */
  49274. private _textureMatrix;
  49275. /**
  49276. * The texture URL.
  49277. */
  49278. url: string;
  49279. /**
  49280. * Empty line regex stored for GC.
  49281. */
  49282. private static _noneEmptyLineRegex;
  49283. private _engine;
  49284. /**
  49285. * Instantiates a ColorGradingTexture from the following parameters.
  49286. *
  49287. * @param url The location of the color gradind data (currently only supporting 3dl)
  49288. * @param scene The scene the texture will be used in
  49289. */
  49290. constructor(url: string, scene: Scene);
  49291. /**
  49292. * Returns the texture matrix used in most of the material.
  49293. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49294. */
  49295. getTextureMatrix(): Matrix;
  49296. /**
  49297. * Occurs when the file being loaded is a .3dl LUT file.
  49298. */
  49299. private load3dlTexture;
  49300. /**
  49301. * Starts the loading process of the texture.
  49302. */
  49303. private loadTexture;
  49304. /**
  49305. * Clones the color gradind texture.
  49306. */
  49307. clone(): ColorGradingTexture;
  49308. /**
  49309. * Called during delayed load for textures.
  49310. */
  49311. delayLoad(): void;
  49312. /**
  49313. * Parses a color grading texture serialized by Babylon.
  49314. * @param parsedTexture The texture information being parsedTexture
  49315. * @param scene The scene to load the texture in
  49316. * @param rootUrl The root url of the data assets to load
  49317. * @return A color gradind texture
  49318. */
  49319. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49320. /**
  49321. * Serializes the LUT texture to json format.
  49322. */
  49323. serialize(): any;
  49324. }
  49325. }
  49326. declare module BABYLON {
  49327. /**
  49328. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49329. */
  49330. export class EquiRectangularCubeTexture extends BaseTexture {
  49331. /** The six faces of the cube. */
  49332. private static _FacesMapping;
  49333. private _noMipmap;
  49334. private _onLoad;
  49335. private _onError;
  49336. /** The size of the cubemap. */
  49337. private _size;
  49338. /** The buffer of the image. */
  49339. private _buffer;
  49340. /** The width of the input image. */
  49341. private _width;
  49342. /** The height of the input image. */
  49343. private _height;
  49344. /** The URL to the image. */
  49345. url: string;
  49346. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49347. coordinatesMode: number;
  49348. /**
  49349. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49350. * @param url The location of the image
  49351. * @param scene The scene the texture will be used in
  49352. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49353. * @param noMipmap Forces to not generate the mipmap if true
  49354. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49355. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49356. * @param onLoad — defines a callback called when texture is loaded
  49357. * @param onError — defines a callback called if there is an error
  49358. */
  49359. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49360. /**
  49361. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49362. */
  49363. private loadImage;
  49364. /**
  49365. * Convert the image buffer into a cubemap and create a CubeTexture.
  49366. */
  49367. private loadTexture;
  49368. /**
  49369. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49370. * @param buffer The ArrayBuffer that should be converted.
  49371. * @returns The buffer as Float32Array.
  49372. */
  49373. private getFloat32ArrayFromArrayBuffer;
  49374. /**
  49375. * Get the current class name of the texture useful for serialization or dynamic coding.
  49376. * @returns "EquiRectangularCubeTexture"
  49377. */
  49378. getClassName(): string;
  49379. /**
  49380. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49381. * @returns A clone of the current EquiRectangularCubeTexture.
  49382. */
  49383. clone(): EquiRectangularCubeTexture;
  49384. }
  49385. }
  49386. declare module BABYLON {
  49387. /**
  49388. * Based on jsTGALoader - Javascript loader for TGA file
  49389. * By Vincent Thibault
  49390. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49391. */
  49392. export class TGATools {
  49393. private static _TYPE_INDEXED;
  49394. private static _TYPE_RGB;
  49395. private static _TYPE_GREY;
  49396. private static _TYPE_RLE_INDEXED;
  49397. private static _TYPE_RLE_RGB;
  49398. private static _TYPE_RLE_GREY;
  49399. private static _ORIGIN_MASK;
  49400. private static _ORIGIN_SHIFT;
  49401. private static _ORIGIN_BL;
  49402. private static _ORIGIN_BR;
  49403. private static _ORIGIN_UL;
  49404. private static _ORIGIN_UR;
  49405. /**
  49406. * Gets the header of a TGA file
  49407. * @param data defines the TGA data
  49408. * @returns the header
  49409. */
  49410. static GetTGAHeader(data: Uint8Array): any;
  49411. /**
  49412. * Uploads TGA content to a Babylon Texture
  49413. * @hidden
  49414. */
  49415. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49416. /** @hidden */
  49417. 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;
  49418. /** @hidden */
  49419. 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;
  49420. /** @hidden */
  49421. 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;
  49422. /** @hidden */
  49423. 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;
  49424. /** @hidden */
  49425. 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;
  49426. /** @hidden */
  49427. 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;
  49428. }
  49429. }
  49430. declare module BABYLON {
  49431. /**
  49432. * Implementation of the TGA Texture Loader.
  49433. * @hidden
  49434. */
  49435. export class _TGATextureLoader implements IInternalTextureLoader {
  49436. /**
  49437. * Defines wether the loader supports cascade loading the different faces.
  49438. */
  49439. readonly supportCascades: boolean;
  49440. /**
  49441. * This returns if the loader support the current file information.
  49442. * @param extension defines the file extension of the file being loaded
  49443. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49444. * @param fallback defines the fallback internal texture if any
  49445. * @param isBase64 defines whether the texture is encoded as a base64
  49446. * @param isBuffer defines whether the texture data are stored as a buffer
  49447. * @returns true if the loader can load the specified file
  49448. */
  49449. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49450. /**
  49451. * Transform the url before loading if required.
  49452. * @param rootUrl the url of the texture
  49453. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49454. * @returns the transformed texture
  49455. */
  49456. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49457. /**
  49458. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49459. * @param rootUrl the url of the texture
  49460. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49461. * @returns the fallback texture
  49462. */
  49463. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49464. /**
  49465. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49466. * @param data contains the texture data
  49467. * @param texture defines the BabylonJS internal texture
  49468. * @param createPolynomials will be true if polynomials have been requested
  49469. * @param onLoad defines the callback to trigger once the texture is ready
  49470. * @param onError defines the callback to trigger in case of error
  49471. */
  49472. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49473. /**
  49474. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49475. * @param data contains the texture data
  49476. * @param texture defines the BabylonJS internal texture
  49477. * @param callback defines the method to call once ready to upload
  49478. */
  49479. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49480. }
  49481. }
  49482. declare module BABYLON {
  49483. /**
  49484. * 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.
  49485. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49486. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49487. */
  49488. export class CustomProceduralTexture extends ProceduralTexture {
  49489. private _animate;
  49490. private _time;
  49491. private _config;
  49492. private _texturePath;
  49493. /**
  49494. * Instantiates a new Custom Procedural Texture.
  49495. * 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.
  49496. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49497. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49498. * @param name Define the name of the texture
  49499. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49500. * @param size Define the size of the texture to create
  49501. * @param scene Define the scene the texture belongs to
  49502. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49503. * @param generateMipMaps Define if the texture should creates mip maps or not
  49504. */
  49505. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49506. private _loadJson;
  49507. /**
  49508. * Is the texture ready to be used ? (rendered at least once)
  49509. * @returns true if ready, otherwise, false.
  49510. */
  49511. isReady(): boolean;
  49512. /**
  49513. * Render the texture to its associated render target.
  49514. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49515. */
  49516. render(useCameraPostProcess?: boolean): void;
  49517. /**
  49518. * Update the list of dependant textures samplers in the shader.
  49519. */
  49520. updateTextures(): void;
  49521. /**
  49522. * Update the uniform values of the procedural texture in the shader.
  49523. */
  49524. updateShaderUniforms(): void;
  49525. /**
  49526. * Define if the texture animates or not.
  49527. */
  49528. animate: boolean;
  49529. }
  49530. }
  49531. declare module BABYLON {
  49532. /** @hidden */
  49533. export var noisePixelShader: {
  49534. name: string;
  49535. shader: string;
  49536. };
  49537. }
  49538. declare module BABYLON {
  49539. /**
  49540. * Class used to generate noise procedural textures
  49541. */
  49542. export class NoiseProceduralTexture extends ProceduralTexture {
  49543. private _time;
  49544. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49545. brightness: number;
  49546. /** Defines the number of octaves to process */
  49547. octaves: number;
  49548. /** Defines the level of persistence (0.8 by default) */
  49549. persistence: number;
  49550. /** Gets or sets animation speed factor (default is 1) */
  49551. animationSpeedFactor: number;
  49552. /**
  49553. * Creates a new NoiseProceduralTexture
  49554. * @param name defines the name fo the texture
  49555. * @param size defines the size of the texture (default is 256)
  49556. * @param scene defines the hosting scene
  49557. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49558. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49559. */
  49560. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49561. private _updateShaderUniforms;
  49562. protected _getDefines(): string;
  49563. /** Generate the current state of the procedural texture */
  49564. render(useCameraPostProcess?: boolean): void;
  49565. /**
  49566. * Serializes this noise procedural texture
  49567. * @returns a serialized noise procedural texture object
  49568. */
  49569. serialize(): any;
  49570. /**
  49571. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49572. * @param parsedTexture defines parsed texture data
  49573. * @param scene defines the current scene
  49574. * @param rootUrl defines the root URL containing noise procedural texture information
  49575. * @returns a parsed NoiseProceduralTexture
  49576. */
  49577. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49578. }
  49579. }
  49580. declare module BABYLON {
  49581. /**
  49582. * Raw cube texture where the raw buffers are passed in
  49583. */
  49584. export class RawCubeTexture extends CubeTexture {
  49585. /**
  49586. * Creates a cube texture where the raw buffers are passed in.
  49587. * @param scene defines the scene the texture is attached to
  49588. * @param data defines the array of data to use to create each face
  49589. * @param size defines the size of the textures
  49590. * @param format defines the format of the data
  49591. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49592. * @param generateMipMaps defines if the engine should generate the mip levels
  49593. * @param invertY defines if data must be stored with Y axis inverted
  49594. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49595. * @param compression defines the compression used (null by default)
  49596. */
  49597. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49598. /**
  49599. * Updates the raw cube texture.
  49600. * @param data defines the data to store
  49601. * @param format defines the data format
  49602. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49603. * @param invertY defines if data must be stored with Y axis inverted
  49604. * @param compression defines the compression used (null by default)
  49605. * @param level defines which level of the texture to update
  49606. */
  49607. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49608. /**
  49609. * Updates a raw cube texture with RGBD encoded data.
  49610. * @param data defines the array of data [mipmap][face] to use to create each face
  49611. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49612. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49613. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49614. * @returns a promsie that resolves when the operation is complete
  49615. */
  49616. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49617. /**
  49618. * Clones the raw cube texture.
  49619. * @return a new cube texture
  49620. */
  49621. clone(): CubeTexture;
  49622. /** @hidden */
  49623. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49624. }
  49625. }
  49626. declare module BABYLON {
  49627. /**
  49628. * Class used to store 3D textures containing user data
  49629. */
  49630. export class RawTexture3D extends Texture {
  49631. /** Gets or sets the texture format to use */
  49632. format: number;
  49633. private _engine;
  49634. /**
  49635. * Create a new RawTexture3D
  49636. * @param data defines the data of the texture
  49637. * @param width defines the width of the texture
  49638. * @param height defines the height of the texture
  49639. * @param depth defines the depth of the texture
  49640. * @param format defines the texture format to use
  49641. * @param scene defines the hosting scene
  49642. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49643. * @param invertY defines if texture must be stored with Y axis inverted
  49644. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49645. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49646. */
  49647. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49648. /** Gets or sets the texture format to use */
  49649. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49650. /**
  49651. * Update the texture with new data
  49652. * @param data defines the data to store in the texture
  49653. */
  49654. update(data: ArrayBufferView): void;
  49655. }
  49656. }
  49657. declare module BABYLON {
  49658. /**
  49659. * Creates a refraction texture used by refraction channel of the standard material.
  49660. * It is like a mirror but to see through a material.
  49661. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49662. */
  49663. export class RefractionTexture extends RenderTargetTexture {
  49664. /**
  49665. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49666. * 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.
  49667. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49668. */
  49669. refractionPlane: Plane;
  49670. /**
  49671. * Define how deep under the surface we should see.
  49672. */
  49673. depth: number;
  49674. /**
  49675. * Creates a refraction texture used by refraction channel of the standard material.
  49676. * It is like a mirror but to see through a material.
  49677. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49678. * @param name Define the texture name
  49679. * @param size Define the size of the underlying texture
  49680. * @param scene Define the scene the refraction belongs to
  49681. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49682. */
  49683. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49684. /**
  49685. * Clone the refraction texture.
  49686. * @returns the cloned texture
  49687. */
  49688. clone(): RefractionTexture;
  49689. /**
  49690. * Serialize the texture to a JSON representation you could use in Parse later on
  49691. * @returns the serialized JSON representation
  49692. */
  49693. serialize(): any;
  49694. }
  49695. }
  49696. declare module BABYLON {
  49697. /**
  49698. * Defines the options related to the creation of an HtmlElementTexture
  49699. */
  49700. export interface IHtmlElementTextureOptions {
  49701. /**
  49702. * Defines wether mip maps should be created or not.
  49703. */
  49704. generateMipMaps?: boolean;
  49705. /**
  49706. * Defines the sampling mode of the texture.
  49707. */
  49708. samplingMode?: number;
  49709. /**
  49710. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  49711. */
  49712. engine: Nullable<Engine>;
  49713. /**
  49714. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  49715. */
  49716. scene: Nullable<Scene>;
  49717. }
  49718. /**
  49719. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  49720. * To be as efficient as possible depending on your constraints nothing aside the first upload
  49721. * is automatically managed.
  49722. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  49723. * in your application.
  49724. *
  49725. * As the update is not automatic, you need to call them manually.
  49726. */
  49727. export class HtmlElementTexture extends BaseTexture {
  49728. /**
  49729. * The texture URL.
  49730. */
  49731. element: HTMLVideoElement | HTMLCanvasElement;
  49732. private static readonly DefaultOptions;
  49733. private _textureMatrix;
  49734. private _engine;
  49735. private _isVideo;
  49736. private _generateMipMaps;
  49737. private _samplingMode;
  49738. /**
  49739. * Instantiates a HtmlElementTexture from the following parameters.
  49740. *
  49741. * @param name Defines the name of the texture
  49742. * @param element Defines the video or canvas the texture is filled with
  49743. * @param options Defines the other none mandatory texture creation options
  49744. */
  49745. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  49746. private _createInternalTexture;
  49747. /**
  49748. * Returns the texture matrix used in most of the material.
  49749. */
  49750. getTextureMatrix(): Matrix;
  49751. /**
  49752. * Updates the content of the texture.
  49753. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  49754. */
  49755. update(invertY?: Nullable<boolean>): void;
  49756. }
  49757. }
  49758. declare module BABYLON {
  49759. /**
  49760. * Helper class to push actions to a pool of workers.
  49761. */
  49762. export class WorkerPool implements IDisposable {
  49763. private _workerInfos;
  49764. private _pendingActions;
  49765. /**
  49766. * Constructor
  49767. * @param workers Array of workers to use for actions
  49768. */
  49769. constructor(workers: Array<Worker>);
  49770. /**
  49771. * Terminates all workers and clears any pending actions.
  49772. */
  49773. dispose(): void;
  49774. /**
  49775. * Pushes an action to the worker pool. If all the workers are active, the action will be
  49776. * pended until a worker has completed its action.
  49777. * @param action The action to perform. Call onComplete when the action is complete.
  49778. */
  49779. push(action: (worker: Worker, onComplete: () => void) => void): void;
  49780. private _execute;
  49781. }
  49782. }
  49783. declare module BABYLON {
  49784. /**
  49785. * Configuration for Draco compression
  49786. */
  49787. export interface IDracoCompressionConfiguration {
  49788. /**
  49789. * Configuration for the decoder.
  49790. */
  49791. decoder: {
  49792. /**
  49793. * The url to the WebAssembly module.
  49794. */
  49795. wasmUrl?: string;
  49796. /**
  49797. * The url to the WebAssembly binary.
  49798. */
  49799. wasmBinaryUrl?: string;
  49800. /**
  49801. * The url to the fallback JavaScript module.
  49802. */
  49803. fallbackUrl?: string;
  49804. };
  49805. }
  49806. /**
  49807. * Draco compression (https://google.github.io/draco/)
  49808. *
  49809. * This class wraps the Draco module.
  49810. *
  49811. * **Encoder**
  49812. *
  49813. * The encoder is not currently implemented.
  49814. *
  49815. * **Decoder**
  49816. *
  49817. * 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.
  49818. *
  49819. * To update the configuration, use the following code:
  49820. * ```javascript
  49821. * DracoCompression.Configuration = {
  49822. * decoder: {
  49823. * wasmUrl: "<url to the WebAssembly library>",
  49824. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49825. * fallbackUrl: "<url to the fallback JavaScript library>",
  49826. * }
  49827. * };
  49828. * ```
  49829. *
  49830. * 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.
  49831. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49832. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  49833. *
  49834. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  49835. * ```javascript
  49836. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  49837. * ```
  49838. *
  49839. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49840. */
  49841. export class DracoCompression implements IDisposable {
  49842. private _workerPoolPromise?;
  49843. private _decoderModulePromise?;
  49844. /**
  49845. * The configuration. Defaults to the following urls:
  49846. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49847. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49848. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49849. */
  49850. static Configuration: IDracoCompressionConfiguration;
  49851. /**
  49852. * Returns true if the decoder configuration is available.
  49853. */
  49854. static readonly DecoderAvailable: boolean;
  49855. /**
  49856. * Default number of workers to create when creating the draco compression object.
  49857. */
  49858. static DefaultNumWorkers: number;
  49859. private static GetDefaultNumWorkers;
  49860. private static _Default;
  49861. /**
  49862. * Default instance for the draco compression object.
  49863. */
  49864. static readonly Default: DracoCompression;
  49865. /**
  49866. * Constructor
  49867. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  49868. */
  49869. constructor(numWorkers?: number);
  49870. /**
  49871. * Stop all async operations and release resources.
  49872. */
  49873. dispose(): void;
  49874. /**
  49875. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  49876. * @returns a promise that resolves when ready
  49877. */
  49878. whenReadyAsync(): Promise<void>;
  49879. /**
  49880. * Decode Draco compressed mesh data to vertex data.
  49881. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49882. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49883. * @returns A promise that resolves with the decoded vertex data
  49884. */
  49885. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  49886. [kind: string]: number;
  49887. }): Promise<VertexData>;
  49888. }
  49889. }
  49890. declare module BABYLON {
  49891. /**
  49892. * Class for building Constructive Solid Geometry
  49893. */
  49894. export class CSG {
  49895. private polygons;
  49896. /**
  49897. * The world matrix
  49898. */
  49899. matrix: Matrix;
  49900. /**
  49901. * Stores the position
  49902. */
  49903. position: Vector3;
  49904. /**
  49905. * Stores the rotation
  49906. */
  49907. rotation: Vector3;
  49908. /**
  49909. * Stores the rotation quaternion
  49910. */
  49911. rotationQuaternion: Nullable<Quaternion>;
  49912. /**
  49913. * Stores the scaling vector
  49914. */
  49915. scaling: Vector3;
  49916. /**
  49917. * Convert the Mesh to CSG
  49918. * @param mesh The Mesh to convert to CSG
  49919. * @returns A new CSG from the Mesh
  49920. */
  49921. static FromMesh(mesh: Mesh): CSG;
  49922. /**
  49923. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49924. * @param polygons Polygons used to construct a CSG solid
  49925. */
  49926. private static FromPolygons;
  49927. /**
  49928. * Clones, or makes a deep copy, of the CSG
  49929. * @returns A new CSG
  49930. */
  49931. clone(): CSG;
  49932. /**
  49933. * Unions this CSG with another CSG
  49934. * @param csg The CSG to union against this CSG
  49935. * @returns The unioned CSG
  49936. */
  49937. union(csg: CSG): CSG;
  49938. /**
  49939. * Unions this CSG with another CSG in place
  49940. * @param csg The CSG to union against this CSG
  49941. */
  49942. unionInPlace(csg: CSG): void;
  49943. /**
  49944. * Subtracts this CSG with another CSG
  49945. * @param csg The CSG to subtract against this CSG
  49946. * @returns A new CSG
  49947. */
  49948. subtract(csg: CSG): CSG;
  49949. /**
  49950. * Subtracts this CSG with another CSG in place
  49951. * @param csg The CSG to subtact against this CSG
  49952. */
  49953. subtractInPlace(csg: CSG): void;
  49954. /**
  49955. * Intersect this CSG with another CSG
  49956. * @param csg The CSG to intersect against this CSG
  49957. * @returns A new CSG
  49958. */
  49959. intersect(csg: CSG): CSG;
  49960. /**
  49961. * Intersects this CSG with another CSG in place
  49962. * @param csg The CSG to intersect against this CSG
  49963. */
  49964. intersectInPlace(csg: CSG): void;
  49965. /**
  49966. * Return a new CSG solid with solid and empty space switched. This solid is
  49967. * not modified.
  49968. * @returns A new CSG solid with solid and empty space switched
  49969. */
  49970. inverse(): CSG;
  49971. /**
  49972. * Inverses the CSG in place
  49973. */
  49974. inverseInPlace(): void;
  49975. /**
  49976. * This is used to keep meshes transformations so they can be restored
  49977. * when we build back a Babylon Mesh
  49978. * NB : All CSG operations are performed in world coordinates
  49979. * @param csg The CSG to copy the transform attributes from
  49980. * @returns This CSG
  49981. */
  49982. copyTransformAttributes(csg: CSG): CSG;
  49983. /**
  49984. * Build Raw mesh from CSG
  49985. * Coordinates here are in world space
  49986. * @param name The name of the mesh geometry
  49987. * @param scene The Scene
  49988. * @param keepSubMeshes Specifies if the submeshes should be kept
  49989. * @returns A new Mesh
  49990. */
  49991. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49992. /**
  49993. * Build Mesh from CSG taking material and transforms into account
  49994. * @param name The name of the Mesh
  49995. * @param material The material of the Mesh
  49996. * @param scene The Scene
  49997. * @param keepSubMeshes Specifies if submeshes should be kept
  49998. * @returns The new Mesh
  49999. */
  50000. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  50001. }
  50002. }
  50003. declare module BABYLON {
  50004. /**
  50005. * Class used to create a trail following a mesh
  50006. */
  50007. export class TrailMesh extends Mesh {
  50008. private _generator;
  50009. private _autoStart;
  50010. private _running;
  50011. private _diameter;
  50012. private _length;
  50013. private _sectionPolygonPointsCount;
  50014. private _sectionVectors;
  50015. private _sectionNormalVectors;
  50016. private _beforeRenderObserver;
  50017. /**
  50018. * @constructor
  50019. * @param name The value used by scene.getMeshByName() to do a lookup.
  50020. * @param generator The mesh to generate a trail.
  50021. * @param scene The scene to add this mesh to.
  50022. * @param diameter Diameter of trailing mesh. Default is 1.
  50023. * @param length Length of trailing mesh. Default is 60.
  50024. * @param autoStart Automatically start trailing mesh. Default true.
  50025. */
  50026. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  50027. /**
  50028. * "TrailMesh"
  50029. * @returns "TrailMesh"
  50030. */
  50031. getClassName(): string;
  50032. private _createMesh;
  50033. /**
  50034. * Start trailing mesh.
  50035. */
  50036. start(): void;
  50037. /**
  50038. * Stop trailing mesh.
  50039. */
  50040. stop(): void;
  50041. /**
  50042. * Update trailing mesh geometry.
  50043. */
  50044. update(): void;
  50045. /**
  50046. * Returns a new TrailMesh object.
  50047. * @param name is a string, the name given to the new mesh
  50048. * @param newGenerator use new generator object for cloned trail mesh
  50049. * @returns a new mesh
  50050. */
  50051. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  50052. /**
  50053. * Serializes this trail mesh
  50054. * @param serializationObject object to write serialization to
  50055. */
  50056. serialize(serializationObject: any): void;
  50057. /**
  50058. * Parses a serialized trail mesh
  50059. * @param parsedMesh the serialized mesh
  50060. * @param scene the scene to create the trail mesh in
  50061. * @returns the created trail mesh
  50062. */
  50063. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50064. }
  50065. }
  50066. declare module BABYLON {
  50067. /**
  50068. * Class containing static functions to help procedurally build meshes
  50069. */
  50070. export class TorusKnotBuilder {
  50071. /**
  50072. * Creates a torus knot mesh
  50073. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50074. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50075. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50076. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50078. * * 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
  50079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50080. * @param name defines the name of the mesh
  50081. * @param options defines the options used to create the mesh
  50082. * @param scene defines the hosting scene
  50083. * @returns the torus knot mesh
  50084. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50085. */
  50086. static CreateTorusKnot(name: string, options: {
  50087. radius?: number;
  50088. tube?: number;
  50089. radialSegments?: number;
  50090. tubularSegments?: number;
  50091. p?: number;
  50092. q?: number;
  50093. updatable?: boolean;
  50094. sideOrientation?: number;
  50095. frontUVs?: Vector4;
  50096. backUVs?: Vector4;
  50097. }, scene: any): Mesh;
  50098. }
  50099. }
  50100. declare module BABYLON {
  50101. /**
  50102. * Polygon
  50103. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50104. */
  50105. export class Polygon {
  50106. /**
  50107. * Creates a rectangle
  50108. * @param xmin bottom X coord
  50109. * @param ymin bottom Y coord
  50110. * @param xmax top X coord
  50111. * @param ymax top Y coord
  50112. * @returns points that make the resulting rectation
  50113. */
  50114. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50115. /**
  50116. * Creates a circle
  50117. * @param radius radius of circle
  50118. * @param cx scale in x
  50119. * @param cy scale in y
  50120. * @param numberOfSides number of sides that make up the circle
  50121. * @returns points that make the resulting circle
  50122. */
  50123. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50124. /**
  50125. * Creates a polygon from input string
  50126. * @param input Input polygon data
  50127. * @returns the parsed points
  50128. */
  50129. static Parse(input: string): Vector2[];
  50130. /**
  50131. * Starts building a polygon from x and y coordinates
  50132. * @param x x coordinate
  50133. * @param y y coordinate
  50134. * @returns the started path2
  50135. */
  50136. static StartingAt(x: number, y: number): Path2;
  50137. }
  50138. /**
  50139. * Builds a polygon
  50140. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50141. */
  50142. export class PolygonMeshBuilder {
  50143. private _points;
  50144. private _outlinepoints;
  50145. private _holes;
  50146. private _name;
  50147. private _scene;
  50148. private _epoints;
  50149. private _eholes;
  50150. private _addToepoint;
  50151. /**
  50152. * Babylon reference to the earcut plugin.
  50153. */
  50154. bjsEarcut: any;
  50155. /**
  50156. * Creates a PolygonMeshBuilder
  50157. * @param name name of the builder
  50158. * @param contours Path of the polygon
  50159. * @param scene scene to add to when creating the mesh
  50160. * @param earcutInjection can be used to inject your own earcut reference
  50161. */
  50162. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  50163. /**
  50164. * Adds a whole within the polygon
  50165. * @param hole Array of points defining the hole
  50166. * @returns this
  50167. */
  50168. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50169. /**
  50170. * Creates the polygon
  50171. * @param updatable If the mesh should be updatable
  50172. * @param depth The depth of the mesh created
  50173. * @returns the created mesh
  50174. */
  50175. build(updatable?: boolean, depth?: number): Mesh;
  50176. /**
  50177. * Creates the polygon
  50178. * @param depth The depth of the mesh created
  50179. * @returns the created VertexData
  50180. */
  50181. buildVertexData(depth?: number): VertexData;
  50182. /**
  50183. * Adds a side to the polygon
  50184. * @param positions points that make the polygon
  50185. * @param normals normals of the polygon
  50186. * @param uvs uvs of the polygon
  50187. * @param indices indices of the polygon
  50188. * @param bounds bounds of the polygon
  50189. * @param points points of the polygon
  50190. * @param depth depth of the polygon
  50191. * @param flip flip of the polygon
  50192. */
  50193. private addSide;
  50194. }
  50195. }
  50196. declare module BABYLON {
  50197. /**
  50198. * Class containing static functions to help procedurally build meshes
  50199. */
  50200. export class PolygonBuilder {
  50201. /**
  50202. * Creates a polygon mesh
  50203. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50204. * * 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
  50205. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50207. * * 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)
  50208. * * Remember you can only change the shape positions, not their number when updating a polygon
  50209. * @param name defines the name of the mesh
  50210. * @param options defines the options used to create the mesh
  50211. * @param scene defines the hosting scene
  50212. * @param earcutInjection can be used to inject your own earcut reference
  50213. * @returns the polygon mesh
  50214. */
  50215. static CreatePolygon(name: string, options: {
  50216. shape: Vector3[];
  50217. holes?: Vector3[][];
  50218. depth?: number;
  50219. faceUV?: Vector4[];
  50220. faceColors?: Color4[];
  50221. updatable?: boolean;
  50222. sideOrientation?: number;
  50223. frontUVs?: Vector4;
  50224. backUVs?: Vector4;
  50225. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50226. /**
  50227. * Creates an extruded polygon mesh, with depth in the Y direction.
  50228. * * 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)
  50229. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50230. * @param name defines the name of the mesh
  50231. * @param options defines the options used to create the mesh
  50232. * @param scene defines the hosting scene
  50233. * @param earcutInjection can be used to inject your own earcut reference
  50234. * @returns the polygon mesh
  50235. */
  50236. static ExtrudePolygon(name: string, options: {
  50237. shape: Vector3[];
  50238. holes?: Vector3[][];
  50239. depth?: number;
  50240. faceUV?: Vector4[];
  50241. faceColors?: Color4[];
  50242. updatable?: boolean;
  50243. sideOrientation?: number;
  50244. frontUVs?: Vector4;
  50245. backUVs?: Vector4;
  50246. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50247. }
  50248. }
  50249. declare module BABYLON {
  50250. /**
  50251. * Class containing static functions to help procedurally build meshes
  50252. */
  50253. export class LatheBuilder {
  50254. /**
  50255. * Creates lathe mesh.
  50256. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50257. * * 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
  50258. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50259. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50260. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50261. * * 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
  50262. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50263. * * 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
  50264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50265. * * 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
  50266. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50268. * @param name defines the name of the mesh
  50269. * @param options defines the options used to create the mesh
  50270. * @param scene defines the hosting scene
  50271. * @returns the lathe mesh
  50272. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50273. */
  50274. static CreateLathe(name: string, options: {
  50275. shape: Vector3[];
  50276. radius?: number;
  50277. tessellation?: number;
  50278. clip?: number;
  50279. arc?: number;
  50280. closed?: boolean;
  50281. updatable?: boolean;
  50282. sideOrientation?: number;
  50283. frontUVs?: Vector4;
  50284. backUVs?: Vector4;
  50285. cap?: number;
  50286. invertUV?: boolean;
  50287. }, scene?: Nullable<Scene>): Mesh;
  50288. }
  50289. }
  50290. declare module BABYLON {
  50291. /**
  50292. * Class containing static functions to help procedurally build meshes
  50293. */
  50294. export class TubeBuilder {
  50295. /**
  50296. * Creates a tube mesh.
  50297. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50298. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50299. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50300. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50301. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50302. * * 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)
  50303. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50304. * * 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
  50305. * * 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
  50306. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50307. * * 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
  50308. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50310. * @param name defines the name of the mesh
  50311. * @param options defines the options used to create the mesh
  50312. * @param scene defines the hosting scene
  50313. * @returns the tube mesh
  50314. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50315. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50316. */
  50317. static CreateTube(name: string, options: {
  50318. path: Vector3[];
  50319. radius?: number;
  50320. tessellation?: number;
  50321. radiusFunction?: {
  50322. (i: number, distance: number): number;
  50323. };
  50324. cap?: number;
  50325. arc?: number;
  50326. updatable?: boolean;
  50327. sideOrientation?: number;
  50328. frontUVs?: Vector4;
  50329. backUVs?: Vector4;
  50330. instance?: Mesh;
  50331. invertUV?: boolean;
  50332. }, scene?: Nullable<Scene>): Mesh;
  50333. }
  50334. }
  50335. declare module BABYLON {
  50336. /**
  50337. * Class containing static functions to help procedurally build meshes
  50338. */
  50339. export class IcoSphereBuilder {
  50340. /**
  50341. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50342. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50343. * * 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`)
  50344. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50345. * * 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
  50346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50347. * * 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
  50348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50349. * @param name defines the name of the mesh
  50350. * @param options defines the options used to create the mesh
  50351. * @param scene defines the hosting scene
  50352. * @returns the icosahedron mesh
  50353. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50354. */
  50355. static CreateIcoSphere(name: string, options: {
  50356. radius?: number;
  50357. radiusX?: number;
  50358. radiusY?: number;
  50359. radiusZ?: number;
  50360. flat?: boolean;
  50361. subdivisions?: number;
  50362. sideOrientation?: number;
  50363. frontUVs?: Vector4;
  50364. backUVs?: Vector4;
  50365. updatable?: boolean;
  50366. }, scene?: Nullable<Scene>): Mesh;
  50367. }
  50368. }
  50369. declare module BABYLON {
  50370. /**
  50371. * Class containing static functions to help procedurally build meshes
  50372. */
  50373. export class DecalBuilder {
  50374. /**
  50375. * Creates a decal mesh.
  50376. * 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
  50377. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50378. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50379. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50380. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50381. * @param name defines the name of the mesh
  50382. * @param sourceMesh defines the mesh where the decal must be applied
  50383. * @param options defines the options used to create the mesh
  50384. * @param scene defines the hosting scene
  50385. * @returns the decal mesh
  50386. * @see https://doc.babylonjs.com/how_to/decals
  50387. */
  50388. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50389. position?: Vector3;
  50390. normal?: Vector3;
  50391. size?: Vector3;
  50392. angle?: number;
  50393. }): Mesh;
  50394. }
  50395. }
  50396. declare module BABYLON {
  50397. /**
  50398. * Class containing static functions to help procedurally build meshes
  50399. */
  50400. export class MeshBuilder {
  50401. /**
  50402. * Creates a box mesh
  50403. * * The parameter `size` sets the size (float) of each box side (default 1)
  50404. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50405. * * 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)
  50406. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50407. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50408. * * 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
  50409. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50410. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50411. * @param name defines the name of the mesh
  50412. * @param options defines the options used to create the mesh
  50413. * @param scene defines the hosting scene
  50414. * @returns the box mesh
  50415. */
  50416. static CreateBox(name: string, options: {
  50417. size?: number;
  50418. width?: number;
  50419. height?: number;
  50420. depth?: number;
  50421. faceUV?: Vector4[];
  50422. faceColors?: Color4[];
  50423. sideOrientation?: number;
  50424. frontUVs?: Vector4;
  50425. backUVs?: Vector4;
  50426. updatable?: boolean;
  50427. }, scene?: Nullable<Scene>): Mesh;
  50428. /**
  50429. * Creates a sphere mesh
  50430. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50431. * * 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`)
  50432. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50433. * * 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
  50434. * * 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)
  50435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50436. * * 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
  50437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50438. * @param name defines the name of the mesh
  50439. * @param options defines the options used to create the mesh
  50440. * @param scene defines the hosting scene
  50441. * @returns the sphere mesh
  50442. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50443. */
  50444. static CreateSphere(name: string, options: {
  50445. segments?: number;
  50446. diameter?: number;
  50447. diameterX?: number;
  50448. diameterY?: number;
  50449. diameterZ?: number;
  50450. arc?: number;
  50451. slice?: number;
  50452. sideOrientation?: number;
  50453. frontUVs?: Vector4;
  50454. backUVs?: Vector4;
  50455. updatable?: boolean;
  50456. }, scene?: Nullable<Scene>): Mesh;
  50457. /**
  50458. * Creates a plane polygonal mesh. By default, this is a disc
  50459. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50460. * * 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
  50461. * * 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
  50462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50463. * * 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
  50464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50465. * @param name defines the name of the mesh
  50466. * @param options defines the options used to create the mesh
  50467. * @param scene defines the hosting scene
  50468. * @returns the plane polygonal mesh
  50469. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50470. */
  50471. static CreateDisc(name: string, options: {
  50472. radius?: number;
  50473. tessellation?: number;
  50474. arc?: number;
  50475. updatable?: boolean;
  50476. sideOrientation?: number;
  50477. frontUVs?: Vector4;
  50478. backUVs?: Vector4;
  50479. }, scene?: Nullable<Scene>): Mesh;
  50480. /**
  50481. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50482. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50483. * * 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`)
  50484. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50485. * * 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
  50486. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50487. * * 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
  50488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50489. * @param name defines the name of the mesh
  50490. * @param options defines the options used to create the mesh
  50491. * @param scene defines the hosting scene
  50492. * @returns the icosahedron mesh
  50493. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50494. */
  50495. static CreateIcoSphere(name: string, options: {
  50496. radius?: number;
  50497. radiusX?: number;
  50498. radiusY?: number;
  50499. radiusZ?: number;
  50500. flat?: boolean;
  50501. subdivisions?: number;
  50502. sideOrientation?: number;
  50503. frontUVs?: Vector4;
  50504. backUVs?: Vector4;
  50505. updatable?: boolean;
  50506. }, scene?: Nullable<Scene>): Mesh;
  50507. /**
  50508. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50509. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50510. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50511. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50512. * * 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
  50513. * * 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
  50514. * * 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
  50515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50516. * * 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
  50517. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50518. * * 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
  50519. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50520. * * 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
  50521. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50523. * @param name defines the name of the mesh
  50524. * @param options defines the options used to create the mesh
  50525. * @param scene defines the hosting scene
  50526. * @returns the ribbon mesh
  50527. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50528. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50529. */
  50530. static CreateRibbon(name: string, options: {
  50531. pathArray: Vector3[][];
  50532. closeArray?: boolean;
  50533. closePath?: boolean;
  50534. offset?: number;
  50535. updatable?: boolean;
  50536. sideOrientation?: number;
  50537. frontUVs?: Vector4;
  50538. backUVs?: Vector4;
  50539. instance?: Mesh;
  50540. invertUV?: boolean;
  50541. uvs?: Vector2[];
  50542. colors?: Color4[];
  50543. }, scene?: Nullable<Scene>): Mesh;
  50544. /**
  50545. * Creates a cylinder or a cone mesh
  50546. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50547. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50548. * * 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.
  50549. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50550. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50551. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50552. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50553. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50554. * * 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).
  50555. * * 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
  50556. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50557. * * 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
  50558. * * 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.
  50559. * * If `enclose` is false, a ring surface is one element.
  50560. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50561. * * 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
  50562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50563. * * 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
  50564. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50565. * @param name defines the name of the mesh
  50566. * @param options defines the options used to create the mesh
  50567. * @param scene defines the hosting scene
  50568. * @returns the cylinder mesh
  50569. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50570. */
  50571. static CreateCylinder(name: string, options: {
  50572. height?: number;
  50573. diameterTop?: number;
  50574. diameterBottom?: number;
  50575. diameter?: number;
  50576. tessellation?: number;
  50577. subdivisions?: number;
  50578. arc?: number;
  50579. faceColors?: Color4[];
  50580. faceUV?: Vector4[];
  50581. updatable?: boolean;
  50582. hasRings?: boolean;
  50583. enclose?: boolean;
  50584. sideOrientation?: number;
  50585. frontUVs?: Vector4;
  50586. backUVs?: Vector4;
  50587. }, scene?: Nullable<Scene>): Mesh;
  50588. /**
  50589. * Creates a torus mesh
  50590. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50591. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50592. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50593. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50594. * * 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
  50595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50596. * @param name defines the name of the mesh
  50597. * @param options defines the options used to create the mesh
  50598. * @param scene defines the hosting scene
  50599. * @returns the torus mesh
  50600. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50601. */
  50602. static CreateTorus(name: string, options: {
  50603. diameter?: number;
  50604. thickness?: number;
  50605. tessellation?: number;
  50606. updatable?: boolean;
  50607. sideOrientation?: number;
  50608. frontUVs?: Vector4;
  50609. backUVs?: Vector4;
  50610. }, scene?: Nullable<Scene>): Mesh;
  50611. /**
  50612. * Creates a torus knot mesh
  50613. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50614. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50615. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50616. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50618. * * 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
  50619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50620. * @param name defines the name of the mesh
  50621. * @param options defines the options used to create the mesh
  50622. * @param scene defines the hosting scene
  50623. * @returns the torus knot mesh
  50624. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50625. */
  50626. static CreateTorusKnot(name: string, options: {
  50627. radius?: number;
  50628. tube?: number;
  50629. radialSegments?: number;
  50630. tubularSegments?: number;
  50631. p?: number;
  50632. q?: number;
  50633. updatable?: boolean;
  50634. sideOrientation?: number;
  50635. frontUVs?: Vector4;
  50636. backUVs?: Vector4;
  50637. }, scene?: Nullable<Scene>): Mesh;
  50638. /**
  50639. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50640. * * 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
  50641. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50642. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50643. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50644. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50645. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50646. * * 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
  50647. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50649. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50650. * @param name defines the name of the new line system
  50651. * @param options defines the options used to create the line system
  50652. * @param scene defines the hosting scene
  50653. * @returns a new line system mesh
  50654. */
  50655. static CreateLineSystem(name: string, options: {
  50656. lines: Vector3[][];
  50657. updatable?: boolean;
  50658. instance?: Nullable<LinesMesh>;
  50659. colors?: Nullable<Color4[][]>;
  50660. useVertexAlpha?: boolean;
  50661. }, scene: Nullable<Scene>): LinesMesh;
  50662. /**
  50663. * Creates a line mesh
  50664. * 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
  50665. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50666. * * The parameter `points` is an array successive Vector3
  50667. * * 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
  50668. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50669. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50670. * * When updating an instance, remember that only point positions can change, not the number of points
  50671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50672. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50673. * @param name defines the name of the new line system
  50674. * @param options defines the options used to create the line system
  50675. * @param scene defines the hosting scene
  50676. * @returns a new line mesh
  50677. */
  50678. static CreateLines(name: string, options: {
  50679. points: Vector3[];
  50680. updatable?: boolean;
  50681. instance?: Nullable<LinesMesh>;
  50682. colors?: Color4[];
  50683. useVertexAlpha?: boolean;
  50684. }, scene?: Nullable<Scene>): LinesMesh;
  50685. /**
  50686. * Creates a dashed line mesh
  50687. * * 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
  50688. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50689. * * The parameter `points` is an array successive Vector3
  50690. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50691. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50692. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50693. * * 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
  50694. * * When updating an instance, remember that only point positions can change, not the number of points
  50695. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50696. * @param name defines the name of the mesh
  50697. * @param options defines the options used to create the mesh
  50698. * @param scene defines the hosting scene
  50699. * @returns the dashed line mesh
  50700. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50701. */
  50702. static CreateDashedLines(name: string, options: {
  50703. points: Vector3[];
  50704. dashSize?: number;
  50705. gapSize?: number;
  50706. dashNb?: number;
  50707. updatable?: boolean;
  50708. instance?: LinesMesh;
  50709. }, scene?: Nullable<Scene>): LinesMesh;
  50710. /**
  50711. * 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.
  50712. * * 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.
  50713. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50714. * * 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.
  50715. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50716. * * 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
  50717. * * 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
  50718. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50720. * * 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
  50721. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50723. * @param name defines the name of the mesh
  50724. * @param options defines the options used to create the mesh
  50725. * @param scene defines the hosting scene
  50726. * @returns the extruded shape mesh
  50727. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50728. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50729. */
  50730. static ExtrudeShape(name: string, options: {
  50731. shape: Vector3[];
  50732. path: Vector3[];
  50733. scale?: number;
  50734. rotation?: number;
  50735. cap?: number;
  50736. updatable?: boolean;
  50737. sideOrientation?: number;
  50738. frontUVs?: Vector4;
  50739. backUVs?: Vector4;
  50740. instance?: Mesh;
  50741. invertUV?: boolean;
  50742. }, scene?: Nullable<Scene>): Mesh;
  50743. /**
  50744. * Creates an custom extruded shape mesh.
  50745. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50746. * * 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.
  50747. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50748. * * 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
  50749. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50750. * * 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
  50751. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50752. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50753. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50754. * * 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
  50755. * * 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
  50756. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50758. * * 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
  50759. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50761. * @param name defines the name of the mesh
  50762. * @param options defines the options used to create the mesh
  50763. * @param scene defines the hosting scene
  50764. * @returns the custom extruded shape mesh
  50765. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50766. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50767. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50768. */
  50769. static ExtrudeShapeCustom(name: string, options: {
  50770. shape: Vector3[];
  50771. path: Vector3[];
  50772. scaleFunction?: any;
  50773. rotationFunction?: any;
  50774. ribbonCloseArray?: boolean;
  50775. ribbonClosePath?: boolean;
  50776. cap?: number;
  50777. updatable?: boolean;
  50778. sideOrientation?: number;
  50779. frontUVs?: Vector4;
  50780. backUVs?: Vector4;
  50781. instance?: Mesh;
  50782. invertUV?: boolean;
  50783. }, scene?: Nullable<Scene>): Mesh;
  50784. /**
  50785. * Creates lathe mesh.
  50786. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50787. * * 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
  50788. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50789. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50790. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50791. * * 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
  50792. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50793. * * 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
  50794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50795. * * 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
  50796. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50798. * @param name defines the name of the mesh
  50799. * @param options defines the options used to create the mesh
  50800. * @param scene defines the hosting scene
  50801. * @returns the lathe mesh
  50802. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50803. */
  50804. static CreateLathe(name: string, options: {
  50805. shape: Vector3[];
  50806. radius?: number;
  50807. tessellation?: number;
  50808. clip?: number;
  50809. arc?: number;
  50810. closed?: boolean;
  50811. updatable?: boolean;
  50812. sideOrientation?: number;
  50813. frontUVs?: Vector4;
  50814. backUVs?: Vector4;
  50815. cap?: number;
  50816. invertUV?: boolean;
  50817. }, scene?: Nullable<Scene>): Mesh;
  50818. /**
  50819. * Creates a plane mesh
  50820. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50821. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50822. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50824. * * 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
  50825. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50826. * @param name defines the name of the mesh
  50827. * @param options defines the options used to create the mesh
  50828. * @param scene defines the hosting scene
  50829. * @returns the plane mesh
  50830. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50831. */
  50832. static CreatePlane(name: string, options: {
  50833. size?: number;
  50834. width?: number;
  50835. height?: number;
  50836. sideOrientation?: number;
  50837. frontUVs?: Vector4;
  50838. backUVs?: Vector4;
  50839. updatable?: boolean;
  50840. sourcePlane?: Plane;
  50841. }, scene?: Nullable<Scene>): Mesh;
  50842. /**
  50843. * Creates a ground mesh
  50844. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50845. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50847. * @param name defines the name of the mesh
  50848. * @param options defines the options used to create the mesh
  50849. * @param scene defines the hosting scene
  50850. * @returns the ground mesh
  50851. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50852. */
  50853. static CreateGround(name: string, options: {
  50854. width?: number;
  50855. height?: number;
  50856. subdivisions?: number;
  50857. subdivisionsX?: number;
  50858. subdivisionsY?: number;
  50859. updatable?: boolean;
  50860. }, scene?: Nullable<Scene>): Mesh;
  50861. /**
  50862. * Creates a tiled ground mesh
  50863. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50864. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50865. * * 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
  50866. * * 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
  50867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50868. * @param name defines the name of the mesh
  50869. * @param options defines the options used to create the mesh
  50870. * @param scene defines the hosting scene
  50871. * @returns the tiled ground mesh
  50872. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50873. */
  50874. static CreateTiledGround(name: string, options: {
  50875. xmin: number;
  50876. zmin: number;
  50877. xmax: number;
  50878. zmax: number;
  50879. subdivisions?: {
  50880. w: number;
  50881. h: number;
  50882. };
  50883. precision?: {
  50884. w: number;
  50885. h: number;
  50886. };
  50887. updatable?: boolean;
  50888. }, scene?: Nullable<Scene>): Mesh;
  50889. /**
  50890. * Creates a ground mesh from a height map
  50891. * * The parameter `url` sets the URL of the height map image resource.
  50892. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50893. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50894. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50895. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50896. * * 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.
  50897. * * 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).
  50898. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50900. * @param name defines the name of the mesh
  50901. * @param url defines the url to the height map
  50902. * @param options defines the options used to create the mesh
  50903. * @param scene defines the hosting scene
  50904. * @returns the ground mesh
  50905. * @see https://doc.babylonjs.com/babylon101/height_map
  50906. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50907. */
  50908. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50909. width?: number;
  50910. height?: number;
  50911. subdivisions?: number;
  50912. minHeight?: number;
  50913. maxHeight?: number;
  50914. colorFilter?: Color3;
  50915. alphaFilter?: number;
  50916. updatable?: boolean;
  50917. onReady?: (mesh: GroundMesh) => void;
  50918. }, scene?: Nullable<Scene>): GroundMesh;
  50919. /**
  50920. * Creates a polygon mesh
  50921. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50922. * * 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
  50923. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50925. * * 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)
  50926. * * Remember you can only change the shape positions, not their number when updating a polygon
  50927. * @param name defines the name of the mesh
  50928. * @param options defines the options used to create the mesh
  50929. * @param scene defines the hosting scene
  50930. * @param earcutInjection can be used to inject your own earcut reference
  50931. * @returns the polygon mesh
  50932. */
  50933. static CreatePolygon(name: string, options: {
  50934. shape: Vector3[];
  50935. holes?: Vector3[][];
  50936. depth?: number;
  50937. faceUV?: Vector4[];
  50938. faceColors?: Color4[];
  50939. updatable?: boolean;
  50940. sideOrientation?: number;
  50941. frontUVs?: Vector4;
  50942. backUVs?: Vector4;
  50943. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50944. /**
  50945. * Creates an extruded polygon mesh, with depth in the Y direction.
  50946. * * 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)
  50947. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50948. * @param name defines the name of the mesh
  50949. * @param options defines the options used to create the mesh
  50950. * @param scene defines the hosting scene
  50951. * @param earcutInjection can be used to inject your own earcut reference
  50952. * @returns the polygon mesh
  50953. */
  50954. static ExtrudePolygon(name: string, options: {
  50955. shape: Vector3[];
  50956. holes?: Vector3[][];
  50957. depth?: number;
  50958. faceUV?: Vector4[];
  50959. faceColors?: Color4[];
  50960. updatable?: boolean;
  50961. sideOrientation?: number;
  50962. frontUVs?: Vector4;
  50963. backUVs?: Vector4;
  50964. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50965. /**
  50966. * Creates a tube mesh.
  50967. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50968. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50969. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50970. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50971. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50972. * * 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)
  50973. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50974. * * 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
  50975. * * 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
  50976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50977. * * 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
  50978. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50980. * @param name defines the name of the mesh
  50981. * @param options defines the options used to create the mesh
  50982. * @param scene defines the hosting scene
  50983. * @returns the tube mesh
  50984. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50985. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50986. */
  50987. static CreateTube(name: string, options: {
  50988. path: Vector3[];
  50989. radius?: number;
  50990. tessellation?: number;
  50991. radiusFunction?: {
  50992. (i: number, distance: number): number;
  50993. };
  50994. cap?: number;
  50995. arc?: number;
  50996. updatable?: boolean;
  50997. sideOrientation?: number;
  50998. frontUVs?: Vector4;
  50999. backUVs?: Vector4;
  51000. instance?: Mesh;
  51001. invertUV?: boolean;
  51002. }, scene?: Nullable<Scene>): Mesh;
  51003. /**
  51004. * Creates a polyhedron mesh
  51005. * * 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
  51006. * * The parameter `size` (positive float, default 1) sets the polygon size
  51007. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51008. * * 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`
  51009. * * 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
  51010. * * 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)`)
  51011. * * 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
  51012. * * 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
  51013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51014. * * 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
  51015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51016. * @param name defines the name of the mesh
  51017. * @param options defines the options used to create the mesh
  51018. * @param scene defines the hosting scene
  51019. * @returns the polyhedron mesh
  51020. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51021. */
  51022. static CreatePolyhedron(name: string, options: {
  51023. type?: number;
  51024. size?: number;
  51025. sizeX?: number;
  51026. sizeY?: number;
  51027. sizeZ?: number;
  51028. custom?: any;
  51029. faceUV?: Vector4[];
  51030. faceColors?: Color4[];
  51031. flat?: boolean;
  51032. updatable?: boolean;
  51033. sideOrientation?: number;
  51034. frontUVs?: Vector4;
  51035. backUVs?: Vector4;
  51036. }, scene?: Nullable<Scene>): Mesh;
  51037. /**
  51038. * Creates a decal mesh.
  51039. * 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
  51040. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51041. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51042. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51043. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51044. * @param name defines the name of the mesh
  51045. * @param sourceMesh defines the mesh where the decal must be applied
  51046. * @param options defines the options used to create the mesh
  51047. * @param scene defines the hosting scene
  51048. * @returns the decal mesh
  51049. * @see https://doc.babylonjs.com/how_to/decals
  51050. */
  51051. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51052. position?: Vector3;
  51053. normal?: Vector3;
  51054. size?: Vector3;
  51055. angle?: number;
  51056. }): Mesh;
  51057. }
  51058. }
  51059. declare module BABYLON {
  51060. /**
  51061. * A simplifier interface for future simplification implementations
  51062. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51063. */
  51064. export interface ISimplifier {
  51065. /**
  51066. * Simplification of a given mesh according to the given settings.
  51067. * Since this requires computation, it is assumed that the function runs async.
  51068. * @param settings The settings of the simplification, including quality and distance
  51069. * @param successCallback A callback that will be called after the mesh was simplified.
  51070. * @param errorCallback in case of an error, this callback will be called. optional.
  51071. */
  51072. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51073. }
  51074. /**
  51075. * Expected simplification settings.
  51076. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51077. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51078. */
  51079. export interface ISimplificationSettings {
  51080. /**
  51081. * Gets or sets the expected quality
  51082. */
  51083. quality: number;
  51084. /**
  51085. * Gets or sets the distance when this optimized version should be used
  51086. */
  51087. distance: number;
  51088. /**
  51089. * Gets an already optimized mesh
  51090. */
  51091. optimizeMesh?: boolean;
  51092. }
  51093. /**
  51094. * Class used to specify simplification options
  51095. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51096. */
  51097. export class SimplificationSettings implements ISimplificationSettings {
  51098. /** expected quality */
  51099. quality: number;
  51100. /** distance when this optimized version should be used */
  51101. distance: number;
  51102. /** already optimized mesh */
  51103. optimizeMesh?: boolean | undefined;
  51104. /**
  51105. * Creates a SimplificationSettings
  51106. * @param quality expected quality
  51107. * @param distance distance when this optimized version should be used
  51108. * @param optimizeMesh already optimized mesh
  51109. */
  51110. constructor(
  51111. /** expected quality */
  51112. quality: number,
  51113. /** distance when this optimized version should be used */
  51114. distance: number,
  51115. /** already optimized mesh */
  51116. optimizeMesh?: boolean | undefined);
  51117. }
  51118. /**
  51119. * Interface used to define a simplification task
  51120. */
  51121. export interface ISimplificationTask {
  51122. /**
  51123. * Array of settings
  51124. */
  51125. settings: Array<ISimplificationSettings>;
  51126. /**
  51127. * Simplification type
  51128. */
  51129. simplificationType: SimplificationType;
  51130. /**
  51131. * Mesh to simplify
  51132. */
  51133. mesh: Mesh;
  51134. /**
  51135. * Callback called on success
  51136. */
  51137. successCallback?: () => void;
  51138. /**
  51139. * Defines if parallel processing can be used
  51140. */
  51141. parallelProcessing: boolean;
  51142. }
  51143. /**
  51144. * Queue used to order the simplification tasks
  51145. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51146. */
  51147. export class SimplificationQueue {
  51148. private _simplificationArray;
  51149. /**
  51150. * Gets a boolean indicating that the process is still running
  51151. */
  51152. running: boolean;
  51153. /**
  51154. * Creates a new queue
  51155. */
  51156. constructor();
  51157. /**
  51158. * Adds a new simplification task
  51159. * @param task defines a task to add
  51160. */
  51161. addTask(task: ISimplificationTask): void;
  51162. /**
  51163. * Execute next task
  51164. */
  51165. executeNext(): void;
  51166. /**
  51167. * Execute a simplification task
  51168. * @param task defines the task to run
  51169. */
  51170. runSimplification(task: ISimplificationTask): void;
  51171. private getSimplifier;
  51172. }
  51173. /**
  51174. * The implemented types of simplification
  51175. * At the moment only Quadratic Error Decimation is implemented
  51176. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51177. */
  51178. export enum SimplificationType {
  51179. /** Quadratic error decimation */
  51180. QUADRATIC = 0
  51181. }
  51182. }
  51183. declare module BABYLON {
  51184. interface Scene {
  51185. /** @hidden (Backing field) */
  51186. _simplificationQueue: SimplificationQueue;
  51187. /**
  51188. * Gets or sets the simplification queue attached to the scene
  51189. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51190. */
  51191. simplificationQueue: SimplificationQueue;
  51192. }
  51193. interface Mesh {
  51194. /**
  51195. * Simplify the mesh according to the given array of settings.
  51196. * Function will return immediately and will simplify async
  51197. * @param settings a collection of simplification settings
  51198. * @param parallelProcessing should all levels calculate parallel or one after the other
  51199. * @param simplificationType the type of simplification to run
  51200. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51201. * @returns the current mesh
  51202. */
  51203. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51204. }
  51205. /**
  51206. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51207. * created in a scene
  51208. */
  51209. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51210. /**
  51211. * The component name helpfull to identify the component in the list of scene components.
  51212. */
  51213. readonly name: string;
  51214. /**
  51215. * The scene the component belongs to.
  51216. */
  51217. scene: Scene;
  51218. /**
  51219. * Creates a new instance of the component for the given scene
  51220. * @param scene Defines the scene to register the component in
  51221. */
  51222. constructor(scene: Scene);
  51223. /**
  51224. * Registers the component in a given scene
  51225. */
  51226. register(): void;
  51227. /**
  51228. * Rebuilds the elements related to this component in case of
  51229. * context lost for instance.
  51230. */
  51231. rebuild(): void;
  51232. /**
  51233. * Disposes the component and the associated ressources
  51234. */
  51235. dispose(): void;
  51236. private _beforeCameraUpdate;
  51237. }
  51238. }
  51239. declare module BABYLON {
  51240. /**
  51241. * Class used to enable access to IndexedDB
  51242. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51243. */
  51244. export class Database implements IOfflineProvider {
  51245. private _callbackManifestChecked;
  51246. private _currentSceneUrl;
  51247. private _db;
  51248. private _enableSceneOffline;
  51249. private _enableTexturesOffline;
  51250. private _manifestVersionFound;
  51251. private _mustUpdateRessources;
  51252. private _hasReachedQuota;
  51253. private _isSupported;
  51254. private _idbFactory;
  51255. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51256. private static IsUASupportingBlobStorage;
  51257. /**
  51258. * Gets a boolean indicating if Database storate is enabled (off by default)
  51259. */
  51260. static IDBStorageEnabled: boolean;
  51261. /**
  51262. * Gets a boolean indicating if scene must be saved in the database
  51263. */
  51264. readonly enableSceneOffline: boolean;
  51265. /**
  51266. * Gets a boolean indicating if textures must be saved in the database
  51267. */
  51268. readonly enableTexturesOffline: boolean;
  51269. /**
  51270. * Creates a new Database
  51271. * @param urlToScene defines the url to load the scene
  51272. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51273. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51274. */
  51275. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51276. private static _ParseURL;
  51277. private static _ReturnFullUrlLocation;
  51278. private _checkManifestFile;
  51279. /**
  51280. * Open the database and make it available
  51281. * @param successCallback defines the callback to call on success
  51282. * @param errorCallback defines the callback to call on error
  51283. */
  51284. open(successCallback: () => void, errorCallback: () => void): void;
  51285. /**
  51286. * Loads an image from the database
  51287. * @param url defines the url to load from
  51288. * @param image defines the target DOM image
  51289. */
  51290. loadImage(url: string, image: HTMLImageElement): void;
  51291. private _loadImageFromDBAsync;
  51292. private _saveImageIntoDBAsync;
  51293. private _checkVersionFromDB;
  51294. private _loadVersionFromDBAsync;
  51295. private _saveVersionIntoDBAsync;
  51296. /**
  51297. * Loads a file from database
  51298. * @param url defines the URL to load from
  51299. * @param sceneLoaded defines a callback to call on success
  51300. * @param progressCallBack defines a callback to call when progress changed
  51301. * @param errorCallback defines a callback to call on error
  51302. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51303. */
  51304. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51305. private _loadFileAsync;
  51306. private _saveFileAsync;
  51307. /**
  51308. * Validates if xhr data is correct
  51309. * @param xhr defines the request to validate
  51310. * @param dataType defines the expected data type
  51311. * @returns true if data is correct
  51312. */
  51313. private static _ValidateXHRData;
  51314. }
  51315. }
  51316. declare module BABYLON {
  51317. /** @hidden */
  51318. export var gpuUpdateParticlesPixelShader: {
  51319. name: string;
  51320. shader: string;
  51321. };
  51322. }
  51323. declare module BABYLON {
  51324. /** @hidden */
  51325. export var gpuUpdateParticlesVertexShader: {
  51326. name: string;
  51327. shader: string;
  51328. };
  51329. }
  51330. declare module BABYLON {
  51331. /** @hidden */
  51332. export var clipPlaneFragmentDeclaration2: {
  51333. name: string;
  51334. shader: string;
  51335. };
  51336. }
  51337. declare module BABYLON {
  51338. /** @hidden */
  51339. export var gpuRenderParticlesPixelShader: {
  51340. name: string;
  51341. shader: string;
  51342. };
  51343. }
  51344. declare module BABYLON {
  51345. /** @hidden */
  51346. export var clipPlaneVertexDeclaration2: {
  51347. name: string;
  51348. shader: string;
  51349. };
  51350. }
  51351. declare module BABYLON {
  51352. /** @hidden */
  51353. export var gpuRenderParticlesVertexShader: {
  51354. name: string;
  51355. shader: string;
  51356. };
  51357. }
  51358. declare module BABYLON {
  51359. /**
  51360. * This represents a GPU particle system in Babylon
  51361. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51362. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51363. */
  51364. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51365. /**
  51366. * The layer mask we are rendering the particles through.
  51367. */
  51368. layerMask: number;
  51369. private _capacity;
  51370. private _activeCount;
  51371. private _currentActiveCount;
  51372. private _accumulatedCount;
  51373. private _renderEffect;
  51374. private _updateEffect;
  51375. private _buffer0;
  51376. private _buffer1;
  51377. private _spriteBuffer;
  51378. private _updateVAO;
  51379. private _renderVAO;
  51380. private _targetIndex;
  51381. private _sourceBuffer;
  51382. private _targetBuffer;
  51383. private _engine;
  51384. private _currentRenderId;
  51385. private _started;
  51386. private _stopped;
  51387. private _timeDelta;
  51388. private _randomTexture;
  51389. private _randomTexture2;
  51390. private _attributesStrideSize;
  51391. private _updateEffectOptions;
  51392. private _randomTextureSize;
  51393. private _actualFrame;
  51394. private readonly _rawTextureWidth;
  51395. /**
  51396. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51397. */
  51398. static readonly IsSupported: boolean;
  51399. /**
  51400. * An event triggered when the system is disposed.
  51401. */
  51402. onDisposeObservable: Observable<GPUParticleSystem>;
  51403. /**
  51404. * Gets the maximum number of particles active at the same time.
  51405. * @returns The max number of active particles.
  51406. */
  51407. getCapacity(): number;
  51408. /**
  51409. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51410. * to override the particles.
  51411. */
  51412. forceDepthWrite: boolean;
  51413. /**
  51414. * Gets or set the number of active particles
  51415. */
  51416. activeParticleCount: number;
  51417. private _preWarmDone;
  51418. /**
  51419. * Is this system ready to be used/rendered
  51420. * @return true if the system is ready
  51421. */
  51422. isReady(): boolean;
  51423. /**
  51424. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51425. * @returns True if it has been started, otherwise false.
  51426. */
  51427. isStarted(): boolean;
  51428. /**
  51429. * Starts the particle system and begins to emit
  51430. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51431. */
  51432. start(delay?: number): void;
  51433. /**
  51434. * Stops the particle system.
  51435. */
  51436. stop(): void;
  51437. /**
  51438. * Remove all active particles
  51439. */
  51440. reset(): void;
  51441. /**
  51442. * Returns the string "GPUParticleSystem"
  51443. * @returns a string containing the class name
  51444. */
  51445. getClassName(): string;
  51446. private _colorGradientsTexture;
  51447. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51448. /**
  51449. * Adds a new color gradient
  51450. * @param gradient defines the gradient to use (between 0 and 1)
  51451. * @param color1 defines the color to affect to the specified gradient
  51452. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51453. * @returns the current particle system
  51454. */
  51455. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51456. /**
  51457. * Remove a specific color gradient
  51458. * @param gradient defines the gradient to remove
  51459. * @returns the current particle system
  51460. */
  51461. removeColorGradient(gradient: number): GPUParticleSystem;
  51462. private _angularSpeedGradientsTexture;
  51463. private _sizeGradientsTexture;
  51464. private _velocityGradientsTexture;
  51465. private _limitVelocityGradientsTexture;
  51466. private _dragGradientsTexture;
  51467. private _addFactorGradient;
  51468. /**
  51469. * Adds a new size gradient
  51470. * @param gradient defines the gradient to use (between 0 and 1)
  51471. * @param factor defines the size factor to affect to the specified gradient
  51472. * @returns the current particle system
  51473. */
  51474. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51475. /**
  51476. * Remove a specific size gradient
  51477. * @param gradient defines the gradient to remove
  51478. * @returns the current particle system
  51479. */
  51480. removeSizeGradient(gradient: number): GPUParticleSystem;
  51481. /**
  51482. * Adds a new angular speed gradient
  51483. * @param gradient defines the gradient to use (between 0 and 1)
  51484. * @param factor defines the angular speed to affect to the specified gradient
  51485. * @returns the current particle system
  51486. */
  51487. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51488. /**
  51489. * Remove a specific angular speed gradient
  51490. * @param gradient defines the gradient to remove
  51491. * @returns the current particle system
  51492. */
  51493. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51494. /**
  51495. * Adds a new velocity gradient
  51496. * @param gradient defines the gradient to use (between 0 and 1)
  51497. * @param factor defines the velocity to affect to the specified gradient
  51498. * @returns the current particle system
  51499. */
  51500. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51501. /**
  51502. * Remove a specific velocity gradient
  51503. * @param gradient defines the gradient to remove
  51504. * @returns the current particle system
  51505. */
  51506. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51507. /**
  51508. * Adds a new limit velocity gradient
  51509. * @param gradient defines the gradient to use (between 0 and 1)
  51510. * @param factor defines the limit velocity value to affect to the specified gradient
  51511. * @returns the current particle system
  51512. */
  51513. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51514. /**
  51515. * Remove a specific limit velocity gradient
  51516. * @param gradient defines the gradient to remove
  51517. * @returns the current particle system
  51518. */
  51519. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51520. /**
  51521. * Adds a new drag gradient
  51522. * @param gradient defines the gradient to use (between 0 and 1)
  51523. * @param factor defines the drag value to affect to the specified gradient
  51524. * @returns the current particle system
  51525. */
  51526. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51527. /**
  51528. * Remove a specific drag gradient
  51529. * @param gradient defines the gradient to remove
  51530. * @returns the current particle system
  51531. */
  51532. removeDragGradient(gradient: number): GPUParticleSystem;
  51533. /**
  51534. * Not supported by GPUParticleSystem
  51535. * @param gradient defines the gradient to use (between 0 and 1)
  51536. * @param factor defines the emit rate value to affect to the specified gradient
  51537. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51538. * @returns the current particle system
  51539. */
  51540. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51541. /**
  51542. * Not supported by GPUParticleSystem
  51543. * @param gradient defines the gradient to remove
  51544. * @returns the current particle system
  51545. */
  51546. removeEmitRateGradient(gradient: number): IParticleSystem;
  51547. /**
  51548. * Not supported by GPUParticleSystem
  51549. * @param gradient defines the gradient to use (between 0 and 1)
  51550. * @param factor defines the start size value to affect to the specified gradient
  51551. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51552. * @returns the current particle system
  51553. */
  51554. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51555. /**
  51556. * Not supported by GPUParticleSystem
  51557. * @param gradient defines the gradient to remove
  51558. * @returns the current particle system
  51559. */
  51560. removeStartSizeGradient(gradient: number): IParticleSystem;
  51561. /**
  51562. * Not supported by GPUParticleSystem
  51563. * @param gradient defines the gradient to use (between 0 and 1)
  51564. * @param min defines the color remap minimal range
  51565. * @param max defines the color remap maximal range
  51566. * @returns the current particle system
  51567. */
  51568. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51569. /**
  51570. * Not supported by GPUParticleSystem
  51571. * @param gradient defines the gradient to remove
  51572. * @returns the current particle system
  51573. */
  51574. removeColorRemapGradient(): IParticleSystem;
  51575. /**
  51576. * Not supported by GPUParticleSystem
  51577. * @param gradient defines the gradient to use (between 0 and 1)
  51578. * @param min defines the alpha remap minimal range
  51579. * @param max defines the alpha remap maximal range
  51580. * @returns the current particle system
  51581. */
  51582. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51583. /**
  51584. * Not supported by GPUParticleSystem
  51585. * @param gradient defines the gradient to remove
  51586. * @returns the current particle system
  51587. */
  51588. removeAlphaRemapGradient(): IParticleSystem;
  51589. /**
  51590. * Not supported by GPUParticleSystem
  51591. * @param gradient defines the gradient to use (between 0 and 1)
  51592. * @param color defines the color to affect to the specified gradient
  51593. * @returns the current particle system
  51594. */
  51595. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51596. /**
  51597. * Not supported by GPUParticleSystem
  51598. * @param gradient defines the gradient to remove
  51599. * @returns the current particle system
  51600. */
  51601. removeRampGradient(): IParticleSystem;
  51602. /**
  51603. * Not supported by GPUParticleSystem
  51604. * @returns the list of ramp gradients
  51605. */
  51606. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51607. /**
  51608. * Not supported by GPUParticleSystem
  51609. * Gets or sets a boolean indicating that ramp gradients must be used
  51610. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51611. */
  51612. useRampGradients: boolean;
  51613. /**
  51614. * Not supported by GPUParticleSystem
  51615. * @param gradient defines the gradient to use (between 0 and 1)
  51616. * @param factor defines the life time factor to affect to the specified gradient
  51617. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51618. * @returns the current particle system
  51619. */
  51620. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51621. /**
  51622. * Not supported by GPUParticleSystem
  51623. * @param gradient defines the gradient to remove
  51624. * @returns the current particle system
  51625. */
  51626. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51627. /**
  51628. * Instantiates a GPU particle system.
  51629. * 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.
  51630. * @param name The name of the particle system
  51631. * @param options The options used to create the system
  51632. * @param scene The scene the particle system belongs to
  51633. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51634. */
  51635. constructor(name: string, options: Partial<{
  51636. capacity: number;
  51637. randomTextureSize: number;
  51638. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51639. protected _reset(): void;
  51640. private _createUpdateVAO;
  51641. private _createRenderVAO;
  51642. private _initialize;
  51643. /** @hidden */
  51644. _recreateUpdateEffect(): void;
  51645. /** @hidden */
  51646. _recreateRenderEffect(): void;
  51647. /**
  51648. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51649. * @param preWarm defines if we are in the pre-warmimg phase
  51650. */
  51651. animate(preWarm?: boolean): void;
  51652. private _createFactorGradientTexture;
  51653. private _createSizeGradientTexture;
  51654. private _createAngularSpeedGradientTexture;
  51655. private _createVelocityGradientTexture;
  51656. private _createLimitVelocityGradientTexture;
  51657. private _createDragGradientTexture;
  51658. private _createColorGradientTexture;
  51659. /**
  51660. * Renders the particle system in its current state
  51661. * @param preWarm defines if the system should only update the particles but not render them
  51662. * @returns the current number of particles
  51663. */
  51664. render(preWarm?: boolean): number;
  51665. /**
  51666. * Rebuilds the particle system
  51667. */
  51668. rebuild(): void;
  51669. private _releaseBuffers;
  51670. private _releaseVAOs;
  51671. /**
  51672. * Disposes the particle system and free the associated resources
  51673. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51674. */
  51675. dispose(disposeTexture?: boolean): void;
  51676. /**
  51677. * Clones the particle system.
  51678. * @param name The name of the cloned object
  51679. * @param newEmitter The new emitter to use
  51680. * @returns the cloned particle system
  51681. */
  51682. clone(name: string, newEmitter: any): GPUParticleSystem;
  51683. /**
  51684. * Serializes the particle system to a JSON object.
  51685. * @returns the JSON object
  51686. */
  51687. serialize(): any;
  51688. /**
  51689. * Parses a JSON object to create a GPU particle system.
  51690. * @param parsedParticleSystem The JSON object to parse
  51691. * @param scene The scene to create the particle system in
  51692. * @param rootUrl The root url to use to load external dependencies like texture
  51693. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51694. * @returns the parsed GPU particle system
  51695. */
  51696. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51697. }
  51698. }
  51699. declare module BABYLON {
  51700. /**
  51701. * Represents a set of particle systems working together to create a specific effect
  51702. */
  51703. export class ParticleSystemSet implements IDisposable {
  51704. private _emitterCreationOptions;
  51705. private _emitterNode;
  51706. /**
  51707. * Gets the particle system list
  51708. */
  51709. systems: IParticleSystem[];
  51710. /**
  51711. * Gets the emitter node used with this set
  51712. */
  51713. readonly emitterNode: Nullable<TransformNode>;
  51714. /**
  51715. * Creates a new emitter mesh as a sphere
  51716. * @param options defines the options used to create the sphere
  51717. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51718. * @param scene defines the hosting scene
  51719. */
  51720. setEmitterAsSphere(options: {
  51721. diameter: number;
  51722. segments: number;
  51723. color: Color3;
  51724. }, renderingGroupId: number, scene: Scene): void;
  51725. /**
  51726. * Starts all particle systems of the set
  51727. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51728. */
  51729. start(emitter?: AbstractMesh): void;
  51730. /**
  51731. * Release all associated resources
  51732. */
  51733. dispose(): void;
  51734. /**
  51735. * Serialize the set into a JSON compatible object
  51736. * @returns a JSON compatible representation of the set
  51737. */
  51738. serialize(): any;
  51739. /**
  51740. * Parse a new ParticleSystemSet from a serialized source
  51741. * @param data defines a JSON compatible representation of the set
  51742. * @param scene defines the hosting scene
  51743. * @param gpu defines if we want GPU particles or CPU particles
  51744. * @returns a new ParticleSystemSet
  51745. */
  51746. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51747. }
  51748. }
  51749. declare module BABYLON {
  51750. /**
  51751. * This class is made for on one-liner static method to help creating particle system set.
  51752. */
  51753. export class ParticleHelper {
  51754. /**
  51755. * Gets or sets base Assets URL
  51756. */
  51757. static BaseAssetsUrl: string;
  51758. /**
  51759. * Create a default particle system that you can tweak
  51760. * @param emitter defines the emitter to use
  51761. * @param capacity defines the system capacity (default is 500 particles)
  51762. * @param scene defines the hosting scene
  51763. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51764. * @returns the new Particle system
  51765. */
  51766. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51767. /**
  51768. * This is the main static method (one-liner) of this helper to create different particle systems
  51769. * @param type This string represents the type to the particle system to create
  51770. * @param scene The scene where the particle system should live
  51771. * @param gpu If the system will use gpu
  51772. * @returns the ParticleSystemSet created
  51773. */
  51774. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51775. /**
  51776. * Static function used to export a particle system to a ParticleSystemSet variable.
  51777. * Please note that the emitter shape is not exported
  51778. * @param systems defines the particle systems to export
  51779. * @returns the created particle system set
  51780. */
  51781. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51782. }
  51783. }
  51784. declare module BABYLON {
  51785. interface Engine {
  51786. /**
  51787. * Create an effect to use with particle systems.
  51788. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51789. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51790. * @param uniformsNames defines a list of attribute names
  51791. * @param samplers defines an array of string used to represent textures
  51792. * @param defines defines the string containing the defines to use to compile the shaders
  51793. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51794. * @param onCompiled defines a function to call when the effect creation is successful
  51795. * @param onError defines a function to call when the effect creation has failed
  51796. * @returns the new Effect
  51797. */
  51798. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51799. }
  51800. interface Mesh {
  51801. /**
  51802. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51803. * @returns an array of IParticleSystem
  51804. */
  51805. getEmittedParticleSystems(): IParticleSystem[];
  51806. /**
  51807. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51808. * @returns an array of IParticleSystem
  51809. */
  51810. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51811. }
  51812. /**
  51813. * @hidden
  51814. */
  51815. export var _IDoNeedToBeInTheBuild: number;
  51816. }
  51817. declare module BABYLON {
  51818. interface Scene {
  51819. /** @hidden (Backing field) */
  51820. _physicsEngine: Nullable<IPhysicsEngine>;
  51821. /**
  51822. * Gets the current physics engine
  51823. * @returns a IPhysicsEngine or null if none attached
  51824. */
  51825. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51826. /**
  51827. * Enables physics to the current scene
  51828. * @param gravity defines the scene's gravity for the physics engine
  51829. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51830. * @return a boolean indicating if the physics engine was initialized
  51831. */
  51832. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51833. /**
  51834. * Disables and disposes the physics engine associated with the scene
  51835. */
  51836. disablePhysicsEngine(): void;
  51837. /**
  51838. * Gets a boolean indicating if there is an active physics engine
  51839. * @returns a boolean indicating if there is an active physics engine
  51840. */
  51841. isPhysicsEnabled(): boolean;
  51842. /**
  51843. * Deletes a physics compound impostor
  51844. * @param compound defines the compound to delete
  51845. */
  51846. deleteCompoundImpostor(compound: any): void;
  51847. /**
  51848. * An event triggered when physic simulation is about to be run
  51849. */
  51850. onBeforePhysicsObservable: Observable<Scene>;
  51851. /**
  51852. * An event triggered when physic simulation has been done
  51853. */
  51854. onAfterPhysicsObservable: Observable<Scene>;
  51855. }
  51856. interface AbstractMesh {
  51857. /** @hidden */
  51858. _physicsImpostor: Nullable<PhysicsImpostor>;
  51859. /**
  51860. * Gets or sets impostor used for physic simulation
  51861. * @see http://doc.babylonjs.com/features/physics_engine
  51862. */
  51863. physicsImpostor: Nullable<PhysicsImpostor>;
  51864. /**
  51865. * Gets the current physics impostor
  51866. * @see http://doc.babylonjs.com/features/physics_engine
  51867. * @returns a physics impostor or null
  51868. */
  51869. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51870. /** Apply a physic impulse to the mesh
  51871. * @param force defines the force to apply
  51872. * @param contactPoint defines where to apply the force
  51873. * @returns the current mesh
  51874. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51875. */
  51876. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51877. /**
  51878. * Creates a physic joint between two meshes
  51879. * @param otherMesh defines the other mesh to use
  51880. * @param pivot1 defines the pivot to use on this mesh
  51881. * @param pivot2 defines the pivot to use on the other mesh
  51882. * @param options defines additional options (can be plugin dependent)
  51883. * @returns the current mesh
  51884. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51885. */
  51886. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51887. /** @hidden */
  51888. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51889. }
  51890. /**
  51891. * Defines the physics engine scene component responsible to manage a physics engine
  51892. */
  51893. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51894. /**
  51895. * The component name helpful to identify the component in the list of scene components.
  51896. */
  51897. readonly name: string;
  51898. /**
  51899. * The scene the component belongs to.
  51900. */
  51901. scene: Scene;
  51902. /**
  51903. * Creates a new instance of the component for the given scene
  51904. * @param scene Defines the scene to register the component in
  51905. */
  51906. constructor(scene: Scene);
  51907. /**
  51908. * Registers the component in a given scene
  51909. */
  51910. register(): void;
  51911. /**
  51912. * Rebuilds the elements related to this component in case of
  51913. * context lost for instance.
  51914. */
  51915. rebuild(): void;
  51916. /**
  51917. * Disposes the component and the associated ressources
  51918. */
  51919. dispose(): void;
  51920. }
  51921. }
  51922. declare module BABYLON {
  51923. /**
  51924. * A helper for physics simulations
  51925. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51926. */
  51927. export class PhysicsHelper {
  51928. private _scene;
  51929. private _physicsEngine;
  51930. /**
  51931. * Initializes the Physics helper
  51932. * @param scene Babylon.js scene
  51933. */
  51934. constructor(scene: Scene);
  51935. /**
  51936. * Applies a radial explosion impulse
  51937. * @param origin the origin of the explosion
  51938. * @param radiusOrEventOptions the radius or the options of radial explosion
  51939. * @param strength the explosion strength
  51940. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51941. * @returns A physics radial explosion event, or null
  51942. */
  51943. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51944. /**
  51945. * Applies a radial explosion force
  51946. * @param origin the origin of the explosion
  51947. * @param radiusOrEventOptions the radius or the options of radial explosion
  51948. * @param strength the explosion strength
  51949. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51950. * @returns A physics radial explosion event, or null
  51951. */
  51952. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51953. /**
  51954. * Creates a gravitational field
  51955. * @param origin the origin of the explosion
  51956. * @param radiusOrEventOptions the radius or the options of radial explosion
  51957. * @param strength the explosion strength
  51958. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51959. * @returns A physics gravitational field event, or null
  51960. */
  51961. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51962. /**
  51963. * Creates a physics updraft event
  51964. * @param origin the origin of the updraft
  51965. * @param radiusOrEventOptions the radius or the options of the updraft
  51966. * @param strength the strength of the updraft
  51967. * @param height the height of the updraft
  51968. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51969. * @returns A physics updraft event, or null
  51970. */
  51971. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51972. /**
  51973. * Creates a physics vortex event
  51974. * @param origin the of the vortex
  51975. * @param radiusOrEventOptions the radius or the options of the vortex
  51976. * @param strength the strength of the vortex
  51977. * @param height the height of the vortex
  51978. * @returns a Physics vortex event, or null
  51979. * A physics vortex event or null
  51980. */
  51981. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  51982. }
  51983. /**
  51984. * Represents a physics radial explosion event
  51985. */
  51986. class PhysicsRadialExplosionEvent {
  51987. private _scene;
  51988. private _options;
  51989. private _sphere;
  51990. private _dataFetched;
  51991. /**
  51992. * Initializes a radial explosioin event
  51993. * @param _scene BabylonJS scene
  51994. * @param _options The options for the vortex event
  51995. */
  51996. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  51997. /**
  51998. * Returns the data related to the radial explosion event (sphere).
  51999. * @returns The radial explosion event data
  52000. */
  52001. getData(): PhysicsRadialExplosionEventData;
  52002. /**
  52003. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52004. * @param impostor A physics imposter
  52005. * @param origin the origin of the explosion
  52006. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  52007. */
  52008. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  52009. /**
  52010. * Triggers affecterd impostors callbacks
  52011. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  52012. */
  52013. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  52014. /**
  52015. * Disposes the sphere.
  52016. * @param force Specifies if the sphere should be disposed by force
  52017. */
  52018. dispose(force?: boolean): void;
  52019. /*** Helpers ***/
  52020. private _prepareSphere;
  52021. private _intersectsWithSphere;
  52022. }
  52023. /**
  52024. * Represents a gravitational field event
  52025. */
  52026. class PhysicsGravitationalFieldEvent {
  52027. private _physicsHelper;
  52028. private _scene;
  52029. private _origin;
  52030. private _options;
  52031. private _tickCallback;
  52032. private _sphere;
  52033. private _dataFetched;
  52034. /**
  52035. * Initializes the physics gravitational field event
  52036. * @param _physicsHelper A physics helper
  52037. * @param _scene BabylonJS scene
  52038. * @param _origin The origin position of the gravitational field event
  52039. * @param _options The options for the vortex event
  52040. */
  52041. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  52042. /**
  52043. * Returns the data related to the gravitational field event (sphere).
  52044. * @returns A gravitational field event
  52045. */
  52046. getData(): PhysicsGravitationalFieldEventData;
  52047. /**
  52048. * Enables the gravitational field.
  52049. */
  52050. enable(): void;
  52051. /**
  52052. * Disables the gravitational field.
  52053. */
  52054. disable(): void;
  52055. /**
  52056. * Disposes the sphere.
  52057. * @param force The force to dispose from the gravitational field event
  52058. */
  52059. dispose(force?: boolean): void;
  52060. private _tick;
  52061. }
  52062. /**
  52063. * Represents a physics updraft event
  52064. */
  52065. class PhysicsUpdraftEvent {
  52066. private _scene;
  52067. private _origin;
  52068. private _options;
  52069. private _physicsEngine;
  52070. private _originTop;
  52071. private _originDirection;
  52072. private _tickCallback;
  52073. private _cylinder;
  52074. private _cylinderPosition;
  52075. private _dataFetched;
  52076. /**
  52077. * Initializes the physics updraft event
  52078. * @param _scene BabylonJS scene
  52079. * @param _origin The origin position of the updraft
  52080. * @param _options The options for the updraft event
  52081. */
  52082. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  52083. /**
  52084. * Returns the data related to the updraft event (cylinder).
  52085. * @returns A physics updraft event
  52086. */
  52087. getData(): PhysicsUpdraftEventData;
  52088. /**
  52089. * Enables the updraft.
  52090. */
  52091. enable(): void;
  52092. /**
  52093. * Disables the updraft.
  52094. */
  52095. disable(): void;
  52096. /**
  52097. * Disposes the cylinder.
  52098. * @param force Specifies if the updraft should be disposed by force
  52099. */
  52100. dispose(force?: boolean): void;
  52101. private getImpostorHitData;
  52102. private _tick;
  52103. /*** Helpers ***/
  52104. private _prepareCylinder;
  52105. private _intersectsWithCylinder;
  52106. }
  52107. /**
  52108. * Represents a physics vortex event
  52109. */
  52110. class PhysicsVortexEvent {
  52111. private _scene;
  52112. private _origin;
  52113. private _options;
  52114. private _physicsEngine;
  52115. private _originTop;
  52116. private _tickCallback;
  52117. private _cylinder;
  52118. private _cylinderPosition;
  52119. private _dataFetched;
  52120. /**
  52121. * Initializes the physics vortex event
  52122. * @param _scene The BabylonJS scene
  52123. * @param _origin The origin position of the vortex
  52124. * @param _options The options for the vortex event
  52125. */
  52126. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  52127. /**
  52128. * Returns the data related to the vortex event (cylinder).
  52129. * @returns The physics vortex event data
  52130. */
  52131. getData(): PhysicsVortexEventData;
  52132. /**
  52133. * Enables the vortex.
  52134. */
  52135. enable(): void;
  52136. /**
  52137. * Disables the cortex.
  52138. */
  52139. disable(): void;
  52140. /**
  52141. * Disposes the sphere.
  52142. * @param force
  52143. */
  52144. dispose(force?: boolean): void;
  52145. private getImpostorHitData;
  52146. private _tick;
  52147. /*** Helpers ***/
  52148. private _prepareCylinder;
  52149. private _intersectsWithCylinder;
  52150. }
  52151. /**
  52152. * Options fot the radial explosion event
  52153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52154. */
  52155. export class PhysicsRadialExplosionEventOptions {
  52156. /**
  52157. * The radius of the sphere for the radial explosion.
  52158. */
  52159. radius: number;
  52160. /**
  52161. * The strenth of the explosion.
  52162. */
  52163. strength: number;
  52164. /**
  52165. * The strenght of the force in correspondence to the distance of the affected object
  52166. */
  52167. falloff: PhysicsRadialImpulseFalloff;
  52168. /**
  52169. * Sphere options for the radial explosion.
  52170. */
  52171. sphere: {
  52172. segments: number;
  52173. diameter: number;
  52174. };
  52175. /**
  52176. * Sphere options for the radial explosion.
  52177. */
  52178. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  52179. }
  52180. /**
  52181. * Options fot the updraft event
  52182. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52183. */
  52184. export class PhysicsUpdraftEventOptions {
  52185. /**
  52186. * The radius of the cylinder for the vortex
  52187. */
  52188. radius: number;
  52189. /**
  52190. * The strenth of the updraft.
  52191. */
  52192. strength: number;
  52193. /**
  52194. * The height of the cylinder for the updraft.
  52195. */
  52196. height: number;
  52197. /**
  52198. * The mode for the the updraft.
  52199. */
  52200. updraftMode: PhysicsUpdraftMode;
  52201. }
  52202. /**
  52203. * Options fot the vortex event
  52204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52205. */
  52206. export class PhysicsVortexEventOptions {
  52207. /**
  52208. * The radius of the cylinder for the vortex
  52209. */
  52210. radius: number;
  52211. /**
  52212. * The strenth of the vortex.
  52213. */
  52214. strength: number;
  52215. /**
  52216. * The height of the cylinder for the vortex.
  52217. */
  52218. height: number;
  52219. /**
  52220. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  52221. */
  52222. centripetalForceThreshold: number;
  52223. /**
  52224. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  52225. */
  52226. centripetalForceMultiplier: number;
  52227. /**
  52228. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  52229. */
  52230. centrifugalForceMultiplier: number;
  52231. /**
  52232. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  52233. */
  52234. updraftForceMultiplier: number;
  52235. }
  52236. /**
  52237. * The strenght of the force in correspondence to the distance of the affected object
  52238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52239. */
  52240. export enum PhysicsRadialImpulseFalloff {
  52241. /** Defines that impulse is constant in strength across it's whole radius */
  52242. Constant = 0,
  52243. /** Defines that impulse gets weaker if it's further from the origin */
  52244. Linear = 1
  52245. }
  52246. /**
  52247. * The strength of the force in correspondence to the distance of the affected object
  52248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52249. */
  52250. export enum PhysicsUpdraftMode {
  52251. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52252. Center = 0,
  52253. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52254. Perpendicular = 1
  52255. }
  52256. /**
  52257. * Interface for a physics hit data
  52258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52259. */
  52260. export interface PhysicsHitData {
  52261. /**
  52262. * The force applied at the contact point
  52263. */
  52264. force: Vector3;
  52265. /**
  52266. * The contact point
  52267. */
  52268. contactPoint: Vector3;
  52269. /**
  52270. * The distance from the origin to the contact point
  52271. */
  52272. distanceFromOrigin: number;
  52273. }
  52274. /**
  52275. * Interface for radial explosion event data
  52276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52277. */
  52278. export interface PhysicsRadialExplosionEventData {
  52279. /**
  52280. * A sphere used for the radial explosion event
  52281. */
  52282. sphere: Mesh;
  52283. }
  52284. /**
  52285. * Interface for gravitational field event data
  52286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52287. */
  52288. export interface PhysicsGravitationalFieldEventData {
  52289. /**
  52290. * A sphere mesh used for the gravitational field event
  52291. */
  52292. sphere: Mesh;
  52293. }
  52294. /**
  52295. * Interface for updraft event data
  52296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52297. */
  52298. export interface PhysicsUpdraftEventData {
  52299. /**
  52300. * A cylinder used for the updraft event
  52301. */
  52302. cylinder: Mesh;
  52303. }
  52304. /**
  52305. * Interface for vortex event data
  52306. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52307. */
  52308. export interface PhysicsVortexEventData {
  52309. /**
  52310. * A cylinder used for the vortex event
  52311. */
  52312. cylinder: Mesh;
  52313. }
  52314. /**
  52315. * Interface for an affected physics impostor
  52316. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52317. */
  52318. export interface PhysicsAffectedImpostorWithData {
  52319. /**
  52320. * The impostor affected by the effect
  52321. */
  52322. impostor: PhysicsImpostor;
  52323. /**
  52324. * The data about the hit/horce from the explosion
  52325. */
  52326. hitData: PhysicsHitData;
  52327. }
  52328. }
  52329. declare module BABYLON {
  52330. /** @hidden */
  52331. export var blackAndWhitePixelShader: {
  52332. name: string;
  52333. shader: string;
  52334. };
  52335. }
  52336. declare module BABYLON {
  52337. /**
  52338. * Post process used to render in black and white
  52339. */
  52340. export class BlackAndWhitePostProcess extends PostProcess {
  52341. /**
  52342. * Linear about to convert he result to black and white (default: 1)
  52343. */
  52344. degree: number;
  52345. /**
  52346. * Creates a black and white post process
  52347. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52348. * @param name The name of the effect.
  52349. * @param options The required width/height ratio to downsize to before computing the render pass.
  52350. * @param camera The camera to apply the render pass to.
  52351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52352. * @param engine The engine which the post process will be applied. (default: current engine)
  52353. * @param reusable If the post process can be reused on the same frame. (default: false)
  52354. */
  52355. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52356. }
  52357. }
  52358. declare module BABYLON {
  52359. /**
  52360. * This represents a set of one or more post processes in Babylon.
  52361. * A post process can be used to apply a shader to a texture after it is rendered.
  52362. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52363. */
  52364. export class PostProcessRenderEffect {
  52365. private _postProcesses;
  52366. private _getPostProcesses;
  52367. private _singleInstance;
  52368. private _cameras;
  52369. private _indicesForCamera;
  52370. /**
  52371. * Name of the effect
  52372. * @hidden
  52373. */
  52374. _name: string;
  52375. /**
  52376. * Instantiates a post process render effect.
  52377. * A post process can be used to apply a shader to a texture after it is rendered.
  52378. * @param engine The engine the effect is tied to
  52379. * @param name The name of the effect
  52380. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52381. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52382. */
  52383. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52384. /**
  52385. * Checks if all the post processes in the effect are supported.
  52386. */
  52387. readonly isSupported: boolean;
  52388. /**
  52389. * Updates the current state of the effect
  52390. * @hidden
  52391. */
  52392. _update(): void;
  52393. /**
  52394. * Attaches the effect on cameras
  52395. * @param cameras The camera to attach to.
  52396. * @hidden
  52397. */
  52398. _attachCameras(cameras: Camera): void;
  52399. /**
  52400. * Attaches the effect on cameras
  52401. * @param cameras The camera to attach to.
  52402. * @hidden
  52403. */
  52404. _attachCameras(cameras: Camera[]): void;
  52405. /**
  52406. * Detaches the effect on cameras
  52407. * @param cameras The camera to detatch from.
  52408. * @hidden
  52409. */
  52410. _detachCameras(cameras: Camera): void;
  52411. /**
  52412. * Detatches the effect on cameras
  52413. * @param cameras The camera to detatch from.
  52414. * @hidden
  52415. */
  52416. _detachCameras(cameras: Camera[]): void;
  52417. /**
  52418. * Enables the effect on given cameras
  52419. * @param cameras The camera to enable.
  52420. * @hidden
  52421. */
  52422. _enable(cameras: Camera): void;
  52423. /**
  52424. * Enables the effect on given cameras
  52425. * @param cameras The camera to enable.
  52426. * @hidden
  52427. */
  52428. _enable(cameras: Nullable<Camera[]>): void;
  52429. /**
  52430. * Disables the effect on the given cameras
  52431. * @param cameras The camera to disable.
  52432. * @hidden
  52433. */
  52434. _disable(cameras: Camera): void;
  52435. /**
  52436. * Disables the effect on the given cameras
  52437. * @param cameras The camera to disable.
  52438. * @hidden
  52439. */
  52440. _disable(cameras: Nullable<Camera[]>): void;
  52441. /**
  52442. * Gets a list of the post processes contained in the effect.
  52443. * @param camera The camera to get the post processes on.
  52444. * @returns The list of the post processes in the effect.
  52445. */
  52446. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52447. }
  52448. }
  52449. declare module BABYLON {
  52450. /** @hidden */
  52451. export var extractHighlightsPixelShader: {
  52452. name: string;
  52453. shader: string;
  52454. };
  52455. }
  52456. declare module BABYLON {
  52457. /**
  52458. * 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.
  52459. */
  52460. export class ExtractHighlightsPostProcess extends PostProcess {
  52461. /**
  52462. * The luminance threshold, pixels below this value will be set to black.
  52463. */
  52464. threshold: number;
  52465. /** @hidden */
  52466. _exposure: number;
  52467. /**
  52468. * Post process which has the input texture to be used when performing highlight extraction
  52469. * @hidden
  52470. */
  52471. _inputPostProcess: Nullable<PostProcess>;
  52472. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52473. }
  52474. }
  52475. declare module BABYLON {
  52476. /** @hidden */
  52477. export var bloomMergePixelShader: {
  52478. name: string;
  52479. shader: string;
  52480. };
  52481. }
  52482. declare module BABYLON {
  52483. /**
  52484. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52485. */
  52486. export class BloomMergePostProcess extends PostProcess {
  52487. /** Weight of the bloom to be added to the original input. */
  52488. weight: number;
  52489. /**
  52490. * Creates a new instance of @see BloomMergePostProcess
  52491. * @param name The name of the effect.
  52492. * @param originalFromInput Post process which's input will be used for the merge.
  52493. * @param blurred Blurred highlights post process which's output will be used.
  52494. * @param weight Weight of the bloom to be added to the original input.
  52495. * @param options The required width/height ratio to downsize to before computing the render pass.
  52496. * @param camera The camera to apply the render pass to.
  52497. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52498. * @param engine The engine which the post process will be applied. (default: current engine)
  52499. * @param reusable If the post process can be reused on the same frame. (default: false)
  52500. * @param textureType Type of textures used when performing the post process. (default: 0)
  52501. * @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)
  52502. */
  52503. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52504. /** Weight of the bloom to be added to the original input. */
  52505. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52506. }
  52507. }
  52508. declare module BABYLON {
  52509. /**
  52510. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52511. */
  52512. export class BloomEffect extends PostProcessRenderEffect {
  52513. private bloomScale;
  52514. /**
  52515. * @hidden Internal
  52516. */
  52517. _effects: Array<PostProcess>;
  52518. /**
  52519. * @hidden Internal
  52520. */
  52521. _downscale: ExtractHighlightsPostProcess;
  52522. private _blurX;
  52523. private _blurY;
  52524. private _merge;
  52525. /**
  52526. * The luminance threshold to find bright areas of the image to bloom.
  52527. */
  52528. threshold: number;
  52529. /**
  52530. * The strength of the bloom.
  52531. */
  52532. weight: number;
  52533. /**
  52534. * Specifies the size of the bloom blur kernel, relative to the final output size
  52535. */
  52536. kernel: number;
  52537. /**
  52538. * Creates a new instance of @see BloomEffect
  52539. * @param scene The scene the effect belongs to.
  52540. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52541. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52542. * @param bloomWeight The the strength of bloom.
  52543. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52544. * @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)
  52545. */
  52546. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52547. /**
  52548. * Disposes each of the internal effects for a given camera.
  52549. * @param camera The camera to dispose the effect on.
  52550. */
  52551. disposeEffects(camera: Camera): void;
  52552. /**
  52553. * @hidden Internal
  52554. */
  52555. _updateEffects(): void;
  52556. /**
  52557. * Internal
  52558. * @returns if all the contained post processes are ready.
  52559. * @hidden
  52560. */
  52561. _isReady(): boolean;
  52562. }
  52563. }
  52564. declare module BABYLON {
  52565. /** @hidden */
  52566. export var chromaticAberrationPixelShader: {
  52567. name: string;
  52568. shader: string;
  52569. };
  52570. }
  52571. declare module BABYLON {
  52572. /**
  52573. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52574. */
  52575. export class ChromaticAberrationPostProcess extends PostProcess {
  52576. /**
  52577. * The amount of seperation of rgb channels (default: 30)
  52578. */
  52579. aberrationAmount: number;
  52580. /**
  52581. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52582. */
  52583. radialIntensity: number;
  52584. /**
  52585. * 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))
  52586. */
  52587. direction: Vector2;
  52588. /**
  52589. * 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))
  52590. */
  52591. centerPosition: Vector2;
  52592. /**
  52593. * Creates a new instance ChromaticAberrationPostProcess
  52594. * @param name The name of the effect.
  52595. * @param screenWidth The width of the screen to apply the effect on.
  52596. * @param screenHeight The height of the screen to apply the effect on.
  52597. * @param options The required width/height ratio to downsize to before computing the render pass.
  52598. * @param camera The camera to apply the render pass to.
  52599. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52600. * @param engine The engine which the post process will be applied. (default: current engine)
  52601. * @param reusable If the post process can be reused on the same frame. (default: false)
  52602. * @param textureType Type of textures used when performing the post process. (default: 0)
  52603. * @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)
  52604. */
  52605. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52606. }
  52607. }
  52608. declare module BABYLON {
  52609. /** @hidden */
  52610. export var circleOfConfusionPixelShader: {
  52611. name: string;
  52612. shader: string;
  52613. };
  52614. }
  52615. declare module BABYLON {
  52616. /**
  52617. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52618. */
  52619. export class CircleOfConfusionPostProcess extends PostProcess {
  52620. /**
  52621. * 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.
  52622. */
  52623. lensSize: number;
  52624. /**
  52625. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52626. */
  52627. fStop: number;
  52628. /**
  52629. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52630. */
  52631. focusDistance: number;
  52632. /**
  52633. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52634. */
  52635. focalLength: number;
  52636. private _depthTexture;
  52637. /**
  52638. * Creates a new instance CircleOfConfusionPostProcess
  52639. * @param name The name of the effect.
  52640. * @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.
  52641. * @param options The required width/height ratio to downsize to before computing the render pass.
  52642. * @param camera The camera to apply the render pass to.
  52643. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52644. * @param engine The engine which the post process will be applied. (default: current engine)
  52645. * @param reusable If the post process can be reused on the same frame. (default: false)
  52646. * @param textureType Type of textures used when performing the post process. (default: 0)
  52647. * @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)
  52648. */
  52649. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52650. /**
  52651. * 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.
  52652. */
  52653. depthTexture: RenderTargetTexture;
  52654. }
  52655. }
  52656. declare module BABYLON {
  52657. /** @hidden */
  52658. export var colorCorrectionPixelShader: {
  52659. name: string;
  52660. shader: string;
  52661. };
  52662. }
  52663. declare module BABYLON {
  52664. /**
  52665. *
  52666. * This post-process allows the modification of rendered colors by using
  52667. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52668. *
  52669. * The object needs to be provided an url to a texture containing the color
  52670. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52671. * Use an image editing software to tweak the LUT to match your needs.
  52672. *
  52673. * For an example of a color LUT, see here:
  52674. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52675. * For explanations on color grading, see here:
  52676. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52677. *
  52678. */
  52679. export class ColorCorrectionPostProcess extends PostProcess {
  52680. private _colorTableTexture;
  52681. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52682. }
  52683. }
  52684. declare module BABYLON {
  52685. /** @hidden */
  52686. export var convolutionPixelShader: {
  52687. name: string;
  52688. shader: string;
  52689. };
  52690. }
  52691. declare module BABYLON {
  52692. /**
  52693. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52694. * input texture to perform effects such as edge detection or sharpening
  52695. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52696. */
  52697. export class ConvolutionPostProcess extends PostProcess {
  52698. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52699. kernel: number[];
  52700. /**
  52701. * Creates a new instance ConvolutionPostProcess
  52702. * @param name The name of the effect.
  52703. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52704. * @param options The required width/height ratio to downsize to before computing the render pass.
  52705. * @param camera The camera to apply the render pass to.
  52706. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52707. * @param engine The engine which the post process will be applied. (default: current engine)
  52708. * @param reusable If the post process can be reused on the same frame. (default: false)
  52709. * @param textureType Type of textures used when performing the post process. (default: 0)
  52710. */
  52711. constructor(name: string,
  52712. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52713. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52714. /**
  52715. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52716. */
  52717. static EdgeDetect0Kernel: number[];
  52718. /**
  52719. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52720. */
  52721. static EdgeDetect1Kernel: number[];
  52722. /**
  52723. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52724. */
  52725. static EdgeDetect2Kernel: number[];
  52726. /**
  52727. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52728. */
  52729. static SharpenKernel: number[];
  52730. /**
  52731. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52732. */
  52733. static EmbossKernel: number[];
  52734. /**
  52735. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52736. */
  52737. static GaussianKernel: number[];
  52738. }
  52739. }
  52740. declare module BABYLON {
  52741. /**
  52742. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52743. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52744. * based on samples that have a large difference in distance than the center pixel.
  52745. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52746. */
  52747. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52748. direction: Vector2;
  52749. /**
  52750. * Creates a new instance CircleOfConfusionPostProcess
  52751. * @param name The name of the effect.
  52752. * @param scene The scene the effect belongs to.
  52753. * @param direction The direction the blur should be applied.
  52754. * @param kernel The size of the kernel used to blur.
  52755. * @param options The required width/height ratio to downsize to before computing the render pass.
  52756. * @param camera The camera to apply the render pass to.
  52757. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52758. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52759. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52760. * @param engine The engine which the post process will be applied. (default: current engine)
  52761. * @param reusable If the post process can be reused on the same frame. (default: false)
  52762. * @param textureType Type of textures used when performing the post process. (default: 0)
  52763. * @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)
  52764. */
  52765. 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);
  52766. }
  52767. }
  52768. declare module BABYLON {
  52769. /** @hidden */
  52770. export var depthOfFieldMergePixelShader: {
  52771. name: string;
  52772. shader: string;
  52773. };
  52774. }
  52775. declare module BABYLON {
  52776. /**
  52777. * Options to be set when merging outputs from the default pipeline.
  52778. */
  52779. export class DepthOfFieldMergePostProcessOptions {
  52780. /**
  52781. * The original image to merge on top of
  52782. */
  52783. originalFromInput: PostProcess;
  52784. /**
  52785. * Parameters to perform the merge of the depth of field effect
  52786. */
  52787. depthOfField?: {
  52788. circleOfConfusion: PostProcess;
  52789. blurSteps: Array<PostProcess>;
  52790. };
  52791. /**
  52792. * Parameters to perform the merge of bloom effect
  52793. */
  52794. bloom?: {
  52795. blurred: PostProcess;
  52796. weight: number;
  52797. };
  52798. }
  52799. /**
  52800. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52801. */
  52802. export class DepthOfFieldMergePostProcess extends PostProcess {
  52803. private blurSteps;
  52804. /**
  52805. * Creates a new instance of DepthOfFieldMergePostProcess
  52806. * @param name The name of the effect.
  52807. * @param originalFromInput Post process which's input will be used for the merge.
  52808. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52809. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52810. * @param options The required width/height ratio to downsize to before computing the render pass.
  52811. * @param camera The camera to apply the render pass to.
  52812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52813. * @param engine The engine which the post process will be applied. (default: current engine)
  52814. * @param reusable If the post process can be reused on the same frame. (default: false)
  52815. * @param textureType Type of textures used when performing the post process. (default: 0)
  52816. * @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)
  52817. */
  52818. 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);
  52819. /**
  52820. * Updates the effect with the current post process compile time values and recompiles the shader.
  52821. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52822. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52823. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52824. * @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
  52825. * @param onCompiled Called when the shader has been compiled.
  52826. * @param onError Called if there is an error when compiling a shader.
  52827. */
  52828. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52829. }
  52830. }
  52831. declare module BABYLON {
  52832. /**
  52833. * Specifies the level of max blur that should be applied when using the depth of field effect
  52834. */
  52835. export enum DepthOfFieldEffectBlurLevel {
  52836. /**
  52837. * Subtle blur
  52838. */
  52839. Low = 0,
  52840. /**
  52841. * Medium blur
  52842. */
  52843. Medium = 1,
  52844. /**
  52845. * Large blur
  52846. */
  52847. High = 2
  52848. }
  52849. /**
  52850. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52851. */
  52852. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52853. private _circleOfConfusion;
  52854. /**
  52855. * @hidden Internal, blurs from high to low
  52856. */
  52857. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52858. private _depthOfFieldBlurY;
  52859. private _dofMerge;
  52860. /**
  52861. * @hidden Internal post processes in depth of field effect
  52862. */
  52863. _effects: Array<PostProcess>;
  52864. /**
  52865. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52866. */
  52867. focalLength: number;
  52868. /**
  52869. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52870. */
  52871. fStop: number;
  52872. /**
  52873. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52874. */
  52875. focusDistance: number;
  52876. /**
  52877. * 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.
  52878. */
  52879. lensSize: number;
  52880. /**
  52881. * Creates a new instance DepthOfFieldEffect
  52882. * @param scene The scene the effect belongs to.
  52883. * @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.
  52884. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52885. * @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)
  52886. */
  52887. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52888. /**
  52889. * Get the current class name of the current effet
  52890. * @returns "DepthOfFieldEffect"
  52891. */
  52892. getClassName(): string;
  52893. /**
  52894. * 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.
  52895. */
  52896. depthTexture: RenderTargetTexture;
  52897. /**
  52898. * Disposes each of the internal effects for a given camera.
  52899. * @param camera The camera to dispose the effect on.
  52900. */
  52901. disposeEffects(camera: Camera): void;
  52902. /**
  52903. * @hidden Internal
  52904. */
  52905. _updateEffects(): void;
  52906. /**
  52907. * Internal
  52908. * @returns if all the contained post processes are ready.
  52909. * @hidden
  52910. */
  52911. _isReady(): boolean;
  52912. }
  52913. }
  52914. declare module BABYLON {
  52915. /** @hidden */
  52916. export var displayPassPixelShader: {
  52917. name: string;
  52918. shader: string;
  52919. };
  52920. }
  52921. declare module BABYLON {
  52922. /**
  52923. * DisplayPassPostProcess which produces an output the same as it's input
  52924. */
  52925. export class DisplayPassPostProcess extends PostProcess {
  52926. /**
  52927. * Creates the DisplayPassPostProcess
  52928. * @param name The name of the effect.
  52929. * @param options The required width/height ratio to downsize to before computing the render pass.
  52930. * @param camera The camera to apply the render pass to.
  52931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52932. * @param engine The engine which the post process will be applied. (default: current engine)
  52933. * @param reusable If the post process can be reused on the same frame. (default: false)
  52934. */
  52935. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52936. }
  52937. }
  52938. declare module BABYLON {
  52939. /** @hidden */
  52940. export var filterPixelShader: {
  52941. name: string;
  52942. shader: string;
  52943. };
  52944. }
  52945. declare module BABYLON {
  52946. /**
  52947. * Applies a kernel filter to the image
  52948. */
  52949. export class FilterPostProcess extends PostProcess {
  52950. /** The matrix to be applied to the image */
  52951. kernelMatrix: Matrix;
  52952. /**
  52953. *
  52954. * @param name The name of the effect.
  52955. * @param kernelMatrix The matrix to be applied to the image
  52956. * @param options The required width/height ratio to downsize to before computing the render pass.
  52957. * @param camera The camera to apply the render pass to.
  52958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52959. * @param engine The engine which the post process will be applied. (default: current engine)
  52960. * @param reusable If the post process can be reused on the same frame. (default: false)
  52961. */
  52962. constructor(name: string,
  52963. /** The matrix to be applied to the image */
  52964. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52965. }
  52966. }
  52967. declare module BABYLON {
  52968. /** @hidden */
  52969. export var fxaaPixelShader: {
  52970. name: string;
  52971. shader: string;
  52972. };
  52973. }
  52974. declare module BABYLON {
  52975. /** @hidden */
  52976. export var fxaaVertexShader: {
  52977. name: string;
  52978. shader: string;
  52979. };
  52980. }
  52981. declare module BABYLON {
  52982. /**
  52983. * Fxaa post process
  52984. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52985. */
  52986. export class FxaaPostProcess extends PostProcess {
  52987. /** @hidden */
  52988. texelWidth: number;
  52989. /** @hidden */
  52990. texelHeight: number;
  52991. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52992. private _getDefines;
  52993. }
  52994. }
  52995. declare module BABYLON {
  52996. /** @hidden */
  52997. export var grainPixelShader: {
  52998. name: string;
  52999. shader: string;
  53000. };
  53001. }
  53002. declare module BABYLON {
  53003. /**
  53004. * The GrainPostProcess adds noise to the image at mid luminance levels
  53005. */
  53006. export class GrainPostProcess extends PostProcess {
  53007. /**
  53008. * The intensity of the grain added (default: 30)
  53009. */
  53010. intensity: number;
  53011. /**
  53012. * If the grain should be randomized on every frame
  53013. */
  53014. animated: boolean;
  53015. /**
  53016. * Creates a new instance of @see GrainPostProcess
  53017. * @param name The name of the effect.
  53018. * @param options The required width/height ratio to downsize to before computing the render pass.
  53019. * @param camera The camera to apply the render pass to.
  53020. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53021. * @param engine The engine which the post process will be applied. (default: current engine)
  53022. * @param reusable If the post process can be reused on the same frame. (default: false)
  53023. * @param textureType Type of textures used when performing the post process. (default: 0)
  53024. * @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)
  53025. */
  53026. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53027. }
  53028. }
  53029. declare module BABYLON {
  53030. /** @hidden */
  53031. export var highlightsPixelShader: {
  53032. name: string;
  53033. shader: string;
  53034. };
  53035. }
  53036. declare module BABYLON {
  53037. /**
  53038. * Extracts highlights from the image
  53039. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53040. */
  53041. export class HighlightsPostProcess extends PostProcess {
  53042. /**
  53043. * Extracts highlights from the image
  53044. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53045. * @param name The name of the effect.
  53046. * @param options The required width/height ratio to downsize to before computing the render pass.
  53047. * @param camera The camera to apply the render pass to.
  53048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53049. * @param engine The engine which the post process will be applied. (default: current engine)
  53050. * @param reusable If the post process can be reused on the same frame. (default: false)
  53051. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53052. */
  53053. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53054. }
  53055. }
  53056. declare module BABYLON {
  53057. /** @hidden */
  53058. export var mrtFragmentDeclaration: {
  53059. name: string;
  53060. shader: string;
  53061. };
  53062. }
  53063. declare module BABYLON {
  53064. /** @hidden */
  53065. export var geometryPixelShader: {
  53066. name: string;
  53067. shader: string;
  53068. };
  53069. }
  53070. declare module BABYLON {
  53071. /** @hidden */
  53072. export var geometryVertexShader: {
  53073. name: string;
  53074. shader: string;
  53075. };
  53076. }
  53077. declare module BABYLON {
  53078. /** @hidden */
  53079. interface ISavedTransformationMatrix {
  53080. world: Matrix;
  53081. viewProjection: Matrix;
  53082. }
  53083. /**
  53084. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53085. */
  53086. export class GeometryBufferRenderer {
  53087. /**
  53088. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53089. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53090. */
  53091. static readonly POSITION_TEXTURE_TYPE: number;
  53092. /**
  53093. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53094. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53095. */
  53096. static readonly VELOCITY_TEXTURE_TYPE: number;
  53097. /**
  53098. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53099. * in order to compute objects velocities when enableVelocity is set to "true"
  53100. * @hidden
  53101. */
  53102. _previousTransformationMatrices: {
  53103. [index: number]: ISavedTransformationMatrix;
  53104. };
  53105. /**
  53106. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  53107. * in order to compute objects velocities when enableVelocity is set to "true"
  53108. * @hidden
  53109. */
  53110. _previousBonesTransformationMatrices: {
  53111. [index: number]: Float32Array;
  53112. };
  53113. /**
  53114. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  53115. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  53116. */
  53117. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  53118. private _scene;
  53119. private _multiRenderTarget;
  53120. private _ratio;
  53121. private _enablePosition;
  53122. private _enableVelocity;
  53123. private _positionIndex;
  53124. private _velocityIndex;
  53125. protected _effect: Effect;
  53126. protected _cachedDefines: string;
  53127. /**
  53128. * Set the render list (meshes to be rendered) used in the G buffer.
  53129. */
  53130. renderList: Mesh[];
  53131. /**
  53132. * Gets wether or not G buffer are supported by the running hardware.
  53133. * This requires draw buffer supports
  53134. */
  53135. readonly isSupported: boolean;
  53136. /**
  53137. * Returns the index of the given texture type in the G-Buffer textures array
  53138. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53139. * @returns the index of the given texture type in the G-Buffer textures array
  53140. */
  53141. getTextureIndex(textureType: number): number;
  53142. /**
  53143. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53144. */
  53145. /**
  53146. * Sets whether or not objects positions are enabled for the G buffer.
  53147. */
  53148. enablePosition: boolean;
  53149. /**
  53150. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53151. */
  53152. /**
  53153. * Sets wether or not objects velocities are enabled for the G buffer.
  53154. */
  53155. enableVelocity: boolean;
  53156. /**
  53157. * Gets the scene associated with the buffer.
  53158. */
  53159. readonly scene: Scene;
  53160. /**
  53161. * Gets the ratio used by the buffer during its creation.
  53162. * How big is the buffer related to the main canvas.
  53163. */
  53164. readonly ratio: number;
  53165. /** @hidden */
  53166. static _SceneComponentInitialization: (scene: Scene) => void;
  53167. /**
  53168. * Creates a new G Buffer for the scene
  53169. * @param scene The scene the buffer belongs to
  53170. * @param ratio How big is the buffer related to the main canvas.
  53171. */
  53172. constructor(scene: Scene, ratio?: number);
  53173. /**
  53174. * Checks wether everything is ready to render a submesh to the G buffer.
  53175. * @param subMesh the submesh to check readiness for
  53176. * @param useInstances is the mesh drawn using instance or not
  53177. * @returns true if ready otherwise false
  53178. */
  53179. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53180. /**
  53181. * Gets the current underlying G Buffer.
  53182. * @returns the buffer
  53183. */
  53184. getGBuffer(): MultiRenderTarget;
  53185. /**
  53186. * Gets the number of samples used to render the buffer (anti aliasing).
  53187. */
  53188. /**
  53189. * Sets the number of samples used to render the buffer (anti aliasing).
  53190. */
  53191. samples: number;
  53192. /**
  53193. * Disposes the renderer and frees up associated resources.
  53194. */
  53195. dispose(): void;
  53196. protected _createRenderTargets(): void;
  53197. private _copyBonesTransformationMatrices;
  53198. }
  53199. }
  53200. declare module BABYLON {
  53201. interface Scene {
  53202. /** @hidden (Backing field) */
  53203. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53204. /**
  53205. * Gets or Sets the current geometry buffer associated to the scene.
  53206. */
  53207. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53208. /**
  53209. * Enables a GeometryBufferRender and associates it with the scene
  53210. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53211. * @returns the GeometryBufferRenderer
  53212. */
  53213. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53214. /**
  53215. * Disables the GeometryBufferRender associated with the scene
  53216. */
  53217. disableGeometryBufferRenderer(): void;
  53218. }
  53219. /**
  53220. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53221. * in several rendering techniques.
  53222. */
  53223. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53224. /**
  53225. * The component name helpful to identify the component in the list of scene components.
  53226. */
  53227. readonly name: string;
  53228. /**
  53229. * The scene the component belongs to.
  53230. */
  53231. scene: Scene;
  53232. /**
  53233. * Creates a new instance of the component for the given scene
  53234. * @param scene Defines the scene to register the component in
  53235. */
  53236. constructor(scene: Scene);
  53237. /**
  53238. * Registers the component in a given scene
  53239. */
  53240. register(): void;
  53241. /**
  53242. * Rebuilds the elements related to this component in case of
  53243. * context lost for instance.
  53244. */
  53245. rebuild(): void;
  53246. /**
  53247. * Disposes the component and the associated ressources
  53248. */
  53249. dispose(): void;
  53250. private _gatherRenderTargets;
  53251. }
  53252. }
  53253. declare module BABYLON {
  53254. /** @hidden */
  53255. export var motionBlurPixelShader: {
  53256. name: string;
  53257. shader: string;
  53258. };
  53259. }
  53260. declare module BABYLON {
  53261. /**
  53262. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53263. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53264. * As an example, all you have to do is to create the post-process:
  53265. * var mb = new BABYLON.MotionBlurPostProcess(
  53266. * 'mb', // The name of the effect.
  53267. * scene, // The scene containing the objects to blur according to their velocity.
  53268. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53269. * camera // The camera to apply the render pass to.
  53270. * );
  53271. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53272. */
  53273. export class MotionBlurPostProcess extends PostProcess {
  53274. /**
  53275. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53276. */
  53277. motionStrength: number;
  53278. /**
  53279. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53280. */
  53281. /**
  53282. * Sets the number of iterations to be used for motion blur quality
  53283. */
  53284. motionBlurSamples: number;
  53285. private _motionBlurSamples;
  53286. private _geometryBufferRenderer;
  53287. /**
  53288. * Creates a new instance MotionBlurPostProcess
  53289. * @param name The name of the effect.
  53290. * @param scene The scene containing the objects to blur according to their velocity.
  53291. * @param options The required width/height ratio to downsize to before computing the render pass.
  53292. * @param camera The camera to apply the render pass to.
  53293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53294. * @param engine The engine which the post process will be applied. (default: current engine)
  53295. * @param reusable If the post process can be reused on the same frame. (default: false)
  53296. * @param textureType Type of textures used when performing the post process. (default: 0)
  53297. * @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)
  53298. */
  53299. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53300. /**
  53301. * Excludes the given skinned mesh from computing bones velocities.
  53302. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  53303. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  53304. */
  53305. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  53306. /**
  53307. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  53308. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  53309. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  53310. */
  53311. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  53312. /**
  53313. * Disposes the post process.
  53314. * @param camera The camera to dispose the post process on.
  53315. */
  53316. dispose(camera?: Camera): void;
  53317. }
  53318. }
  53319. declare module BABYLON {
  53320. /** @hidden */
  53321. export var refractionPixelShader: {
  53322. name: string;
  53323. shader: string;
  53324. };
  53325. }
  53326. declare module BABYLON {
  53327. /**
  53328. * Post process which applies a refractin texture
  53329. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53330. */
  53331. export class RefractionPostProcess extends PostProcess {
  53332. /** the base color of the refraction (used to taint the rendering) */
  53333. color: Color3;
  53334. /** simulated refraction depth */
  53335. depth: number;
  53336. /** the coefficient of the base color (0 to remove base color tainting) */
  53337. colorLevel: number;
  53338. private _refTexture;
  53339. private _ownRefractionTexture;
  53340. /**
  53341. * Gets or sets the refraction texture
  53342. * Please note that you are responsible for disposing the texture if you set it manually
  53343. */
  53344. refractionTexture: Texture;
  53345. /**
  53346. * Initializes the RefractionPostProcess
  53347. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53348. * @param name The name of the effect.
  53349. * @param refractionTextureUrl Url of the refraction texture to use
  53350. * @param color the base color of the refraction (used to taint the rendering)
  53351. * @param depth simulated refraction depth
  53352. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53353. * @param camera The camera to apply the render pass to.
  53354. * @param options The required width/height ratio to downsize to before computing the render pass.
  53355. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53356. * @param engine The engine which the post process will be applied. (default: current engine)
  53357. * @param reusable If the post process can be reused on the same frame. (default: false)
  53358. */
  53359. constructor(name: string, refractionTextureUrl: string,
  53360. /** the base color of the refraction (used to taint the rendering) */
  53361. color: Color3,
  53362. /** simulated refraction depth */
  53363. depth: number,
  53364. /** the coefficient of the base color (0 to remove base color tainting) */
  53365. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53366. /**
  53367. * Disposes of the post process
  53368. * @param camera Camera to dispose post process on
  53369. */
  53370. dispose(camera: Camera): void;
  53371. }
  53372. }
  53373. declare module BABYLON {
  53374. /** @hidden */
  53375. export var sharpenPixelShader: {
  53376. name: string;
  53377. shader: string;
  53378. };
  53379. }
  53380. declare module BABYLON {
  53381. /**
  53382. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53383. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53384. */
  53385. export class SharpenPostProcess extends PostProcess {
  53386. /**
  53387. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53388. */
  53389. colorAmount: number;
  53390. /**
  53391. * How much sharpness should be applied (default: 0.3)
  53392. */
  53393. edgeAmount: number;
  53394. /**
  53395. * Creates a new instance ConvolutionPostProcess
  53396. * @param name The name of the effect.
  53397. * @param options The required width/height ratio to downsize to before computing the render pass.
  53398. * @param camera The camera to apply the render pass to.
  53399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53400. * @param engine The engine which the post process will be applied. (default: current engine)
  53401. * @param reusable If the post process can be reused on the same frame. (default: false)
  53402. * @param textureType Type of textures used when performing the post process. (default: 0)
  53403. * @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)
  53404. */
  53405. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53406. }
  53407. }
  53408. declare module BABYLON {
  53409. /**
  53410. * PostProcessRenderPipeline
  53411. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53412. */
  53413. export class PostProcessRenderPipeline {
  53414. private engine;
  53415. private _renderEffects;
  53416. private _renderEffectsForIsolatedPass;
  53417. /**
  53418. * List of inspectable custom properties (used by the Inspector)
  53419. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  53420. */
  53421. inspectableCustomProperties: IInspectable[];
  53422. /**
  53423. * @hidden
  53424. */
  53425. protected _cameras: Camera[];
  53426. /** @hidden */
  53427. _name: string;
  53428. /**
  53429. * Gets pipeline name
  53430. */
  53431. readonly name: string;
  53432. /**
  53433. * Initializes a PostProcessRenderPipeline
  53434. * @param engine engine to add the pipeline to
  53435. * @param name name of the pipeline
  53436. */
  53437. constructor(engine: Engine, name: string);
  53438. /**
  53439. * Gets the class name
  53440. * @returns "PostProcessRenderPipeline"
  53441. */
  53442. getClassName(): string;
  53443. /**
  53444. * If all the render effects in the pipeline are supported
  53445. */
  53446. readonly isSupported: boolean;
  53447. /**
  53448. * Adds an effect to the pipeline
  53449. * @param renderEffect the effect to add
  53450. */
  53451. addEffect(renderEffect: PostProcessRenderEffect): void;
  53452. /** @hidden */
  53453. _rebuild(): void;
  53454. /** @hidden */
  53455. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53456. /** @hidden */
  53457. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53458. /** @hidden */
  53459. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53460. /** @hidden */
  53461. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53462. /** @hidden */
  53463. _attachCameras(cameras: Camera, unique: boolean): void;
  53464. /** @hidden */
  53465. _attachCameras(cameras: Camera[], unique: boolean): void;
  53466. /** @hidden */
  53467. _detachCameras(cameras: Camera): void;
  53468. /** @hidden */
  53469. _detachCameras(cameras: Nullable<Camera[]>): void;
  53470. /** @hidden */
  53471. _update(): void;
  53472. /** @hidden */
  53473. _reset(): void;
  53474. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53475. /**
  53476. * Disposes of the pipeline
  53477. */
  53478. dispose(): void;
  53479. }
  53480. }
  53481. declare module BABYLON {
  53482. /**
  53483. * PostProcessRenderPipelineManager class
  53484. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53485. */
  53486. export class PostProcessRenderPipelineManager {
  53487. private _renderPipelines;
  53488. /**
  53489. * Initializes a PostProcessRenderPipelineManager
  53490. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53491. */
  53492. constructor();
  53493. /**
  53494. * Gets the list of supported render pipelines
  53495. */
  53496. readonly supportedPipelines: PostProcessRenderPipeline[];
  53497. /**
  53498. * Adds a pipeline to the manager
  53499. * @param renderPipeline The pipeline to add
  53500. */
  53501. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53502. /**
  53503. * Attaches a camera to the pipeline
  53504. * @param renderPipelineName The name of the pipeline to attach to
  53505. * @param cameras the camera to attach
  53506. * @param unique if the camera can be attached multiple times to the pipeline
  53507. */
  53508. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53509. /**
  53510. * Detaches a camera from the pipeline
  53511. * @param renderPipelineName The name of the pipeline to detach from
  53512. * @param cameras the camera to detach
  53513. */
  53514. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53515. /**
  53516. * Enables an effect by name on a pipeline
  53517. * @param renderPipelineName the name of the pipeline to enable the effect in
  53518. * @param renderEffectName the name of the effect to enable
  53519. * @param cameras the cameras that the effect should be enabled on
  53520. */
  53521. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53522. /**
  53523. * Disables an effect by name on a pipeline
  53524. * @param renderPipelineName the name of the pipeline to disable the effect in
  53525. * @param renderEffectName the name of the effect to disable
  53526. * @param cameras the cameras that the effect should be disabled on
  53527. */
  53528. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53529. /**
  53530. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53531. */
  53532. update(): void;
  53533. /** @hidden */
  53534. _rebuild(): void;
  53535. /**
  53536. * Disposes of the manager and pipelines
  53537. */
  53538. dispose(): void;
  53539. }
  53540. }
  53541. declare module BABYLON {
  53542. interface Scene {
  53543. /** @hidden (Backing field) */
  53544. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53545. /**
  53546. * Gets the postprocess render pipeline manager
  53547. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53548. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53549. */
  53550. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53551. }
  53552. /**
  53553. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53554. */
  53555. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53556. /**
  53557. * The component name helpfull to identify the component in the list of scene components.
  53558. */
  53559. readonly name: string;
  53560. /**
  53561. * The scene the component belongs to.
  53562. */
  53563. scene: Scene;
  53564. /**
  53565. * Creates a new instance of the component for the given scene
  53566. * @param scene Defines the scene to register the component in
  53567. */
  53568. constructor(scene: Scene);
  53569. /**
  53570. * Registers the component in a given scene
  53571. */
  53572. register(): void;
  53573. /**
  53574. * Rebuilds the elements related to this component in case of
  53575. * context lost for instance.
  53576. */
  53577. rebuild(): void;
  53578. /**
  53579. * Disposes the component and the associated ressources
  53580. */
  53581. dispose(): void;
  53582. private _gatherRenderTargets;
  53583. }
  53584. }
  53585. declare module BABYLON {
  53586. /**
  53587. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53588. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53589. */
  53590. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53591. private _scene;
  53592. private _camerasToBeAttached;
  53593. /**
  53594. * ID of the sharpen post process,
  53595. */
  53596. private readonly SharpenPostProcessId;
  53597. /**
  53598. * @ignore
  53599. * ID of the image processing post process;
  53600. */
  53601. readonly ImageProcessingPostProcessId: string;
  53602. /**
  53603. * @ignore
  53604. * ID of the Fast Approximate Anti-Aliasing post process;
  53605. */
  53606. readonly FxaaPostProcessId: string;
  53607. /**
  53608. * ID of the chromatic aberration post process,
  53609. */
  53610. private readonly ChromaticAberrationPostProcessId;
  53611. /**
  53612. * ID of the grain post process
  53613. */
  53614. private readonly GrainPostProcessId;
  53615. /**
  53616. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53617. */
  53618. sharpen: SharpenPostProcess;
  53619. private _sharpenEffect;
  53620. private bloom;
  53621. /**
  53622. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53623. */
  53624. depthOfField: DepthOfFieldEffect;
  53625. /**
  53626. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53627. */
  53628. fxaa: FxaaPostProcess;
  53629. /**
  53630. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53631. */
  53632. imageProcessing: ImageProcessingPostProcess;
  53633. /**
  53634. * Chromatic aberration post process which will shift rgb colors in the image
  53635. */
  53636. chromaticAberration: ChromaticAberrationPostProcess;
  53637. private _chromaticAberrationEffect;
  53638. /**
  53639. * Grain post process which add noise to the image
  53640. */
  53641. grain: GrainPostProcess;
  53642. private _grainEffect;
  53643. /**
  53644. * Glow post process which adds a glow to emissive areas of the image
  53645. */
  53646. private _glowLayer;
  53647. /**
  53648. * Animations which can be used to tweak settings over a period of time
  53649. */
  53650. animations: Animation[];
  53651. private _imageProcessingConfigurationObserver;
  53652. private _sharpenEnabled;
  53653. private _bloomEnabled;
  53654. private _depthOfFieldEnabled;
  53655. private _depthOfFieldBlurLevel;
  53656. private _fxaaEnabled;
  53657. private _imageProcessingEnabled;
  53658. private _defaultPipelineTextureType;
  53659. private _bloomScale;
  53660. private _chromaticAberrationEnabled;
  53661. private _grainEnabled;
  53662. private _buildAllowed;
  53663. /**
  53664. * Gets active scene
  53665. */
  53666. readonly scene: Scene;
  53667. /**
  53668. * Enable or disable the sharpen process from the pipeline
  53669. */
  53670. sharpenEnabled: boolean;
  53671. private _resizeObserver;
  53672. private _hardwareScaleLevel;
  53673. private _bloomKernel;
  53674. /**
  53675. * Specifies the size of the bloom blur kernel, relative to the final output size
  53676. */
  53677. bloomKernel: number;
  53678. /**
  53679. * Specifies the weight of the bloom in the final rendering
  53680. */
  53681. private _bloomWeight;
  53682. /**
  53683. * Specifies the luma threshold for the area that will be blurred by the bloom
  53684. */
  53685. private _bloomThreshold;
  53686. private _hdr;
  53687. /**
  53688. * The strength of the bloom.
  53689. */
  53690. bloomWeight: number;
  53691. /**
  53692. * The strength of the bloom.
  53693. */
  53694. bloomThreshold: number;
  53695. /**
  53696. * The scale of the bloom, lower value will provide better performance.
  53697. */
  53698. bloomScale: number;
  53699. /**
  53700. * Enable or disable the bloom from the pipeline
  53701. */
  53702. bloomEnabled: boolean;
  53703. private _rebuildBloom;
  53704. /**
  53705. * If the depth of field is enabled.
  53706. */
  53707. depthOfFieldEnabled: boolean;
  53708. /**
  53709. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53710. */
  53711. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53712. /**
  53713. * If the anti aliasing is enabled.
  53714. */
  53715. fxaaEnabled: boolean;
  53716. private _samples;
  53717. /**
  53718. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53719. */
  53720. samples: number;
  53721. /**
  53722. * If image processing is enabled.
  53723. */
  53724. imageProcessingEnabled: boolean;
  53725. /**
  53726. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53727. */
  53728. glowLayerEnabled: boolean;
  53729. /**
  53730. * Gets the glow layer (or null if not defined)
  53731. */
  53732. readonly glowLayer: Nullable<GlowLayer>;
  53733. /**
  53734. * Enable or disable the chromaticAberration process from the pipeline
  53735. */
  53736. chromaticAberrationEnabled: boolean;
  53737. /**
  53738. * Enable or disable the grain process from the pipeline
  53739. */
  53740. grainEnabled: boolean;
  53741. /**
  53742. * @constructor
  53743. * @param name - The rendering pipeline name (default: "")
  53744. * @param hdr - If high dynamic range textures should be used (default: true)
  53745. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53746. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53747. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53748. */
  53749. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53750. /**
  53751. * Get the class name
  53752. * @returns "DefaultRenderingPipeline"
  53753. */
  53754. getClassName(): string;
  53755. /**
  53756. * Force the compilation of the entire pipeline.
  53757. */
  53758. prepare(): void;
  53759. private _hasCleared;
  53760. private _prevPostProcess;
  53761. private _prevPrevPostProcess;
  53762. private _setAutoClearAndTextureSharing;
  53763. private _depthOfFieldSceneObserver;
  53764. private _buildPipeline;
  53765. private _disposePostProcesses;
  53766. /**
  53767. * Adds a camera to the pipeline
  53768. * @param camera the camera to be added
  53769. */
  53770. addCamera(camera: Camera): void;
  53771. /**
  53772. * Removes a camera from the pipeline
  53773. * @param camera the camera to remove
  53774. */
  53775. removeCamera(camera: Camera): void;
  53776. /**
  53777. * Dispose of the pipeline and stop all post processes
  53778. */
  53779. dispose(): void;
  53780. /**
  53781. * Serialize the rendering pipeline (Used when exporting)
  53782. * @returns the serialized object
  53783. */
  53784. serialize(): any;
  53785. /**
  53786. * Parse the serialized pipeline
  53787. * @param source Source pipeline.
  53788. * @param scene The scene to load the pipeline to.
  53789. * @param rootUrl The URL of the serialized pipeline.
  53790. * @returns An instantiated pipeline from the serialized object.
  53791. */
  53792. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53793. }
  53794. }
  53795. declare module BABYLON {
  53796. /** @hidden */
  53797. export var lensHighlightsPixelShader: {
  53798. name: string;
  53799. shader: string;
  53800. };
  53801. }
  53802. declare module BABYLON {
  53803. /** @hidden */
  53804. export var depthOfFieldPixelShader: {
  53805. name: string;
  53806. shader: string;
  53807. };
  53808. }
  53809. declare module BABYLON {
  53810. /**
  53811. * BABYLON.JS Chromatic Aberration GLSL Shader
  53812. * Author: Olivier Guyot
  53813. * Separates very slightly R, G and B colors on the edges of the screen
  53814. * Inspired by Francois Tarlier & Martins Upitis
  53815. */
  53816. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53817. /**
  53818. * @ignore
  53819. * The chromatic aberration PostProcess id in the pipeline
  53820. */
  53821. LensChromaticAberrationEffect: string;
  53822. /**
  53823. * @ignore
  53824. * The highlights enhancing PostProcess id in the pipeline
  53825. */
  53826. HighlightsEnhancingEffect: string;
  53827. /**
  53828. * @ignore
  53829. * The depth-of-field PostProcess id in the pipeline
  53830. */
  53831. LensDepthOfFieldEffect: string;
  53832. private _scene;
  53833. private _depthTexture;
  53834. private _grainTexture;
  53835. private _chromaticAberrationPostProcess;
  53836. private _highlightsPostProcess;
  53837. private _depthOfFieldPostProcess;
  53838. private _edgeBlur;
  53839. private _grainAmount;
  53840. private _chromaticAberration;
  53841. private _distortion;
  53842. private _highlightsGain;
  53843. private _highlightsThreshold;
  53844. private _dofDistance;
  53845. private _dofAperture;
  53846. private _dofDarken;
  53847. private _dofPentagon;
  53848. private _blurNoise;
  53849. /**
  53850. * @constructor
  53851. *
  53852. * Effect parameters are as follow:
  53853. * {
  53854. * chromatic_aberration: number; // from 0 to x (1 for realism)
  53855. * edge_blur: number; // from 0 to x (1 for realism)
  53856. * distortion: number; // from 0 to x (1 for realism)
  53857. * grain_amount: number; // from 0 to 1
  53858. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53859. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53860. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53861. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53862. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53863. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53864. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53865. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53866. * }
  53867. * Note: if an effect parameter is unset, effect is disabled
  53868. *
  53869. * @param name The rendering pipeline name
  53870. * @param parameters - An object containing all parameters (see above)
  53871. * @param scene The scene linked to this pipeline
  53872. * @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)
  53873. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53874. */
  53875. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53876. /**
  53877. * Get the class name
  53878. * @returns "LensRenderingPipeline"
  53879. */
  53880. getClassName(): string;
  53881. /**
  53882. * Gets associated scene
  53883. */
  53884. readonly scene: Scene;
  53885. /**
  53886. * Gets or sets the edge blur
  53887. */
  53888. edgeBlur: number;
  53889. /**
  53890. * Gets or sets the grain amount
  53891. */
  53892. grainAmount: number;
  53893. /**
  53894. * Gets or sets the chromatic aberration amount
  53895. */
  53896. chromaticAberration: number;
  53897. /**
  53898. * Gets or sets the depth of field aperture
  53899. */
  53900. dofAperture: number;
  53901. /**
  53902. * Gets or sets the edge distortion
  53903. */
  53904. edgeDistortion: number;
  53905. /**
  53906. * Gets or sets the depth of field distortion
  53907. */
  53908. dofDistortion: number;
  53909. /**
  53910. * Gets or sets the darken out of focus amount
  53911. */
  53912. darkenOutOfFocus: number;
  53913. /**
  53914. * Gets or sets a boolean indicating if blur noise is enabled
  53915. */
  53916. blurNoise: boolean;
  53917. /**
  53918. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  53919. */
  53920. pentagonBokeh: boolean;
  53921. /**
  53922. * Gets or sets the highlight grain amount
  53923. */
  53924. highlightsGain: number;
  53925. /**
  53926. * Gets or sets the highlight threshold
  53927. */
  53928. highlightsThreshold: number;
  53929. /**
  53930. * Sets the amount of blur at the edges
  53931. * @param amount blur amount
  53932. */
  53933. setEdgeBlur(amount: number): void;
  53934. /**
  53935. * Sets edge blur to 0
  53936. */
  53937. disableEdgeBlur(): void;
  53938. /**
  53939. * Sets the amout of grain
  53940. * @param amount Amount of grain
  53941. */
  53942. setGrainAmount(amount: number): void;
  53943. /**
  53944. * Set grain amount to 0
  53945. */
  53946. disableGrain(): void;
  53947. /**
  53948. * Sets the chromatic aberration amount
  53949. * @param amount amount of chromatic aberration
  53950. */
  53951. setChromaticAberration(amount: number): void;
  53952. /**
  53953. * Sets chromatic aberration amount to 0
  53954. */
  53955. disableChromaticAberration(): void;
  53956. /**
  53957. * Sets the EdgeDistortion amount
  53958. * @param amount amount of EdgeDistortion
  53959. */
  53960. setEdgeDistortion(amount: number): void;
  53961. /**
  53962. * Sets edge distortion to 0
  53963. */
  53964. disableEdgeDistortion(): void;
  53965. /**
  53966. * Sets the FocusDistance amount
  53967. * @param amount amount of FocusDistance
  53968. */
  53969. setFocusDistance(amount: number): void;
  53970. /**
  53971. * Disables depth of field
  53972. */
  53973. disableDepthOfField(): void;
  53974. /**
  53975. * Sets the Aperture amount
  53976. * @param amount amount of Aperture
  53977. */
  53978. setAperture(amount: number): void;
  53979. /**
  53980. * Sets the DarkenOutOfFocus amount
  53981. * @param amount amount of DarkenOutOfFocus
  53982. */
  53983. setDarkenOutOfFocus(amount: number): void;
  53984. private _pentagonBokehIsEnabled;
  53985. /**
  53986. * Creates a pentagon bokeh effect
  53987. */
  53988. enablePentagonBokeh(): void;
  53989. /**
  53990. * Disables the pentagon bokeh effect
  53991. */
  53992. disablePentagonBokeh(): void;
  53993. /**
  53994. * Enables noise blur
  53995. */
  53996. enableNoiseBlur(): void;
  53997. /**
  53998. * Disables noise blur
  53999. */
  54000. disableNoiseBlur(): void;
  54001. /**
  54002. * Sets the HighlightsGain amount
  54003. * @param amount amount of HighlightsGain
  54004. */
  54005. setHighlightsGain(amount: number): void;
  54006. /**
  54007. * Sets the HighlightsThreshold amount
  54008. * @param amount amount of HighlightsThreshold
  54009. */
  54010. setHighlightsThreshold(amount: number): void;
  54011. /**
  54012. * Disables highlights
  54013. */
  54014. disableHighlights(): void;
  54015. /**
  54016. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  54017. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  54018. */
  54019. dispose(disableDepthRender?: boolean): void;
  54020. private _createChromaticAberrationPostProcess;
  54021. private _createHighlightsPostProcess;
  54022. private _createDepthOfFieldPostProcess;
  54023. private _createGrainTexture;
  54024. }
  54025. }
  54026. declare module BABYLON {
  54027. /** @hidden */
  54028. export var ssao2PixelShader: {
  54029. name: string;
  54030. shader: string;
  54031. };
  54032. }
  54033. declare module BABYLON {
  54034. /** @hidden */
  54035. export var ssaoCombinePixelShader: {
  54036. name: string;
  54037. shader: string;
  54038. };
  54039. }
  54040. declare module BABYLON {
  54041. /**
  54042. * Render pipeline to produce ssao effect
  54043. */
  54044. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  54045. /**
  54046. * @ignore
  54047. * The PassPostProcess id in the pipeline that contains the original scene color
  54048. */
  54049. SSAOOriginalSceneColorEffect: string;
  54050. /**
  54051. * @ignore
  54052. * The SSAO PostProcess id in the pipeline
  54053. */
  54054. SSAORenderEffect: string;
  54055. /**
  54056. * @ignore
  54057. * The horizontal blur PostProcess id in the pipeline
  54058. */
  54059. SSAOBlurHRenderEffect: string;
  54060. /**
  54061. * @ignore
  54062. * The vertical blur PostProcess id in the pipeline
  54063. */
  54064. SSAOBlurVRenderEffect: string;
  54065. /**
  54066. * @ignore
  54067. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54068. */
  54069. SSAOCombineRenderEffect: string;
  54070. /**
  54071. * The output strength of the SSAO post-process. Default value is 1.0.
  54072. */
  54073. totalStrength: number;
  54074. /**
  54075. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  54076. */
  54077. maxZ: number;
  54078. /**
  54079. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  54080. */
  54081. minZAspect: number;
  54082. private _samples;
  54083. /**
  54084. * Number of samples used for the SSAO calculations. Default value is 8
  54085. */
  54086. samples: number;
  54087. private _textureSamples;
  54088. /**
  54089. * Number of samples to use for antialiasing
  54090. */
  54091. textureSamples: number;
  54092. /**
  54093. * Ratio object used for SSAO ratio and blur ratio
  54094. */
  54095. private _ratio;
  54096. /**
  54097. * Dynamically generated sphere sampler.
  54098. */
  54099. private _sampleSphere;
  54100. /**
  54101. * Blur filter offsets
  54102. */
  54103. private _samplerOffsets;
  54104. private _expensiveBlur;
  54105. /**
  54106. * If bilateral blur should be used
  54107. */
  54108. expensiveBlur: boolean;
  54109. /**
  54110. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54111. */
  54112. radius: number;
  54113. /**
  54114. * The base color of the SSAO post-process
  54115. * The final result is "base + ssao" between [0, 1]
  54116. */
  54117. base: number;
  54118. /**
  54119. * Support test.
  54120. */
  54121. static readonly IsSupported: boolean;
  54122. private _scene;
  54123. private _depthTexture;
  54124. private _normalTexture;
  54125. private _randomTexture;
  54126. private _originalColorPostProcess;
  54127. private _ssaoPostProcess;
  54128. private _blurHPostProcess;
  54129. private _blurVPostProcess;
  54130. private _ssaoCombinePostProcess;
  54131. private _firstUpdate;
  54132. /**
  54133. * Gets active scene
  54134. */
  54135. readonly scene: Scene;
  54136. /**
  54137. * @constructor
  54138. * @param name The rendering pipeline name
  54139. * @param scene The scene linked to this pipeline
  54140. * @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 }
  54141. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54142. */
  54143. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54144. /**
  54145. * Get the class name
  54146. * @returns "SSAO2RenderingPipeline"
  54147. */
  54148. getClassName(): string;
  54149. /**
  54150. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54151. */
  54152. dispose(disableGeometryBufferRenderer?: boolean): void;
  54153. private _createBlurPostProcess;
  54154. /** @hidden */
  54155. _rebuild(): void;
  54156. private _bits;
  54157. private _radicalInverse_VdC;
  54158. private _hammersley;
  54159. private _hemisphereSample_uniform;
  54160. private _generateHemisphere;
  54161. private _createSSAOPostProcess;
  54162. private _createSSAOCombinePostProcess;
  54163. private _createRandomTexture;
  54164. /**
  54165. * Serialize the rendering pipeline (Used when exporting)
  54166. * @returns the serialized object
  54167. */
  54168. serialize(): any;
  54169. /**
  54170. * Parse the serialized pipeline
  54171. * @param source Source pipeline.
  54172. * @param scene The scene to load the pipeline to.
  54173. * @param rootUrl The URL of the serialized pipeline.
  54174. * @returns An instantiated pipeline from the serialized object.
  54175. */
  54176. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54177. }
  54178. }
  54179. declare module BABYLON {
  54180. /** @hidden */
  54181. export var ssaoPixelShader: {
  54182. name: string;
  54183. shader: string;
  54184. };
  54185. }
  54186. declare module BABYLON {
  54187. /**
  54188. * Render pipeline to produce ssao effect
  54189. */
  54190. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54191. /**
  54192. * @ignore
  54193. * The PassPostProcess id in the pipeline that contains the original scene color
  54194. */
  54195. SSAOOriginalSceneColorEffect: string;
  54196. /**
  54197. * @ignore
  54198. * The SSAO PostProcess id in the pipeline
  54199. */
  54200. SSAORenderEffect: string;
  54201. /**
  54202. * @ignore
  54203. * The horizontal blur PostProcess id in the pipeline
  54204. */
  54205. SSAOBlurHRenderEffect: string;
  54206. /**
  54207. * @ignore
  54208. * The vertical blur PostProcess id in the pipeline
  54209. */
  54210. SSAOBlurVRenderEffect: string;
  54211. /**
  54212. * @ignore
  54213. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54214. */
  54215. SSAOCombineRenderEffect: string;
  54216. /**
  54217. * The output strength of the SSAO post-process. Default value is 1.0.
  54218. */
  54219. totalStrength: number;
  54220. /**
  54221. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54222. */
  54223. radius: number;
  54224. /**
  54225. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54226. * Must not be equal to fallOff and superior to fallOff.
  54227. * Default value is 0.0075
  54228. */
  54229. area: number;
  54230. /**
  54231. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54232. * Must not be equal to area and inferior to area.
  54233. * Default value is 0.000001
  54234. */
  54235. fallOff: number;
  54236. /**
  54237. * The base color of the SSAO post-process
  54238. * The final result is "base + ssao" between [0, 1]
  54239. */
  54240. base: number;
  54241. private _scene;
  54242. private _depthTexture;
  54243. private _randomTexture;
  54244. private _originalColorPostProcess;
  54245. private _ssaoPostProcess;
  54246. private _blurHPostProcess;
  54247. private _blurVPostProcess;
  54248. private _ssaoCombinePostProcess;
  54249. private _firstUpdate;
  54250. /**
  54251. * Gets active scene
  54252. */
  54253. readonly scene: Scene;
  54254. /**
  54255. * @constructor
  54256. * @param name - The rendering pipeline name
  54257. * @param scene - The scene linked to this pipeline
  54258. * @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 }
  54259. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54260. */
  54261. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54262. /**
  54263. * Get the class name
  54264. * @returns "SSAORenderingPipeline"
  54265. */
  54266. getClassName(): string;
  54267. /**
  54268. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54269. */
  54270. dispose(disableDepthRender?: boolean): void;
  54271. private _createBlurPostProcess;
  54272. /** @hidden */
  54273. _rebuild(): void;
  54274. private _createSSAOPostProcess;
  54275. private _createSSAOCombinePostProcess;
  54276. private _createRandomTexture;
  54277. }
  54278. }
  54279. declare module BABYLON {
  54280. /** @hidden */
  54281. export var standardPixelShader: {
  54282. name: string;
  54283. shader: string;
  54284. };
  54285. }
  54286. declare module BABYLON {
  54287. /**
  54288. * Standard rendering pipeline
  54289. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54290. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54291. */
  54292. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54293. /**
  54294. * Public members
  54295. */
  54296. /**
  54297. * Post-process which contains the original scene color before the pipeline applies all the effects
  54298. */
  54299. originalPostProcess: Nullable<PostProcess>;
  54300. /**
  54301. * Post-process used to down scale an image x4
  54302. */
  54303. downSampleX4PostProcess: Nullable<PostProcess>;
  54304. /**
  54305. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54306. */
  54307. brightPassPostProcess: Nullable<PostProcess>;
  54308. /**
  54309. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54310. */
  54311. blurHPostProcesses: PostProcess[];
  54312. /**
  54313. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54314. */
  54315. blurVPostProcesses: PostProcess[];
  54316. /**
  54317. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54318. */
  54319. textureAdderPostProcess: Nullable<PostProcess>;
  54320. /**
  54321. * Post-process used to create volumetric lighting effect
  54322. */
  54323. volumetricLightPostProcess: Nullable<PostProcess>;
  54324. /**
  54325. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54326. */
  54327. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54328. /**
  54329. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54330. */
  54331. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54332. /**
  54333. * Post-process used to merge the volumetric light effect and the real scene color
  54334. */
  54335. volumetricLightMergePostProces: Nullable<PostProcess>;
  54336. /**
  54337. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54338. */
  54339. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54340. /**
  54341. * Base post-process used to calculate the average luminance of the final image for HDR
  54342. */
  54343. luminancePostProcess: Nullable<PostProcess>;
  54344. /**
  54345. * Post-processes used to create down sample post-processes in order to get
  54346. * the average luminance of the final image for HDR
  54347. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54348. */
  54349. luminanceDownSamplePostProcesses: PostProcess[];
  54350. /**
  54351. * Post-process used to create a HDR effect (light adaptation)
  54352. */
  54353. hdrPostProcess: Nullable<PostProcess>;
  54354. /**
  54355. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54356. */
  54357. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54358. /**
  54359. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54360. */
  54361. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54362. /**
  54363. * Post-process used to merge the final HDR post-process and the real scene color
  54364. */
  54365. hdrFinalPostProcess: Nullable<PostProcess>;
  54366. /**
  54367. * Post-process used to create a lens flare effect
  54368. */
  54369. lensFlarePostProcess: Nullable<PostProcess>;
  54370. /**
  54371. * Post-process that merges the result of the lens flare post-process and the real scene color
  54372. */
  54373. lensFlareComposePostProcess: Nullable<PostProcess>;
  54374. /**
  54375. * Post-process used to create a motion blur effect
  54376. */
  54377. motionBlurPostProcess: Nullable<PostProcess>;
  54378. /**
  54379. * Post-process used to create a depth of field effect
  54380. */
  54381. depthOfFieldPostProcess: Nullable<PostProcess>;
  54382. /**
  54383. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54384. */
  54385. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54386. /**
  54387. * Represents the brightness threshold in order to configure the illuminated surfaces
  54388. */
  54389. brightThreshold: number;
  54390. /**
  54391. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54392. */
  54393. blurWidth: number;
  54394. /**
  54395. * Sets if the blur for highlighted surfaces must be only horizontal
  54396. */
  54397. horizontalBlur: boolean;
  54398. /**
  54399. * Gets the overall exposure used by the pipeline
  54400. */
  54401. /**
  54402. * Sets the overall exposure used by the pipeline
  54403. */
  54404. exposure: number;
  54405. /**
  54406. * Texture used typically to simulate "dirty" on camera lens
  54407. */
  54408. lensTexture: Nullable<Texture>;
  54409. /**
  54410. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54411. */
  54412. volumetricLightCoefficient: number;
  54413. /**
  54414. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54415. */
  54416. volumetricLightPower: number;
  54417. /**
  54418. * Used the set the blur intensity to smooth the volumetric lights
  54419. */
  54420. volumetricLightBlurScale: number;
  54421. /**
  54422. * Light (spot or directional) used to generate the volumetric lights rays
  54423. * The source light must have a shadow generate so the pipeline can get its
  54424. * depth map
  54425. */
  54426. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54427. /**
  54428. * For eye adaptation, represents the minimum luminance the eye can see
  54429. */
  54430. hdrMinimumLuminance: number;
  54431. /**
  54432. * For eye adaptation, represents the decrease luminance speed
  54433. */
  54434. hdrDecreaseRate: number;
  54435. /**
  54436. * For eye adaptation, represents the increase luminance speed
  54437. */
  54438. hdrIncreaseRate: number;
  54439. /**
  54440. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  54441. */
  54442. /**
  54443. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  54444. */
  54445. hdrAutoExposure: boolean;
  54446. /**
  54447. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54448. */
  54449. lensColorTexture: Nullable<Texture>;
  54450. /**
  54451. * The overall strengh for the lens flare effect
  54452. */
  54453. lensFlareStrength: number;
  54454. /**
  54455. * Dispersion coefficient for lens flare ghosts
  54456. */
  54457. lensFlareGhostDispersal: number;
  54458. /**
  54459. * Main lens flare halo width
  54460. */
  54461. lensFlareHaloWidth: number;
  54462. /**
  54463. * Based on the lens distortion effect, defines how much the lens flare result
  54464. * is distorted
  54465. */
  54466. lensFlareDistortionStrength: number;
  54467. /**
  54468. * Lens star texture must be used to simulate rays on the flares and is available
  54469. * in the documentation
  54470. */
  54471. lensStarTexture: Nullable<Texture>;
  54472. /**
  54473. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54474. * flare effect by taking account of the dirt texture
  54475. */
  54476. lensFlareDirtTexture: Nullable<Texture>;
  54477. /**
  54478. * Represents the focal length for the depth of field effect
  54479. */
  54480. depthOfFieldDistance: number;
  54481. /**
  54482. * Represents the blur intensity for the blurred part of the depth of field effect
  54483. */
  54484. depthOfFieldBlurWidth: number;
  54485. /**
  54486. * For motion blur, defines how much the image is blurred by the movement
  54487. */
  54488. motionStrength: number;
  54489. /**
  54490. * List of animations for the pipeline (IAnimatable implementation)
  54491. */
  54492. animations: Animation[];
  54493. /**
  54494. * Private members
  54495. */
  54496. private _scene;
  54497. private _currentDepthOfFieldSource;
  54498. private _basePostProcess;
  54499. private _fixedExposure;
  54500. private _currentExposure;
  54501. private _hdrAutoExposure;
  54502. private _hdrCurrentLuminance;
  54503. private _floatTextureType;
  54504. private _ratio;
  54505. private _bloomEnabled;
  54506. private _depthOfFieldEnabled;
  54507. private _vlsEnabled;
  54508. private _lensFlareEnabled;
  54509. private _hdrEnabled;
  54510. private _motionBlurEnabled;
  54511. private _fxaaEnabled;
  54512. private _motionBlurSamples;
  54513. private _volumetricLightStepsCount;
  54514. private _samples;
  54515. /**
  54516. * @ignore
  54517. * Specifies if the bloom pipeline is enabled
  54518. */
  54519. BloomEnabled: boolean;
  54520. /**
  54521. * @ignore
  54522. * Specifies if the depth of field pipeline is enabed
  54523. */
  54524. DepthOfFieldEnabled: boolean;
  54525. /**
  54526. * @ignore
  54527. * Specifies if the lens flare pipeline is enabed
  54528. */
  54529. LensFlareEnabled: boolean;
  54530. /**
  54531. * @ignore
  54532. * Specifies if the HDR pipeline is enabled
  54533. */
  54534. HDREnabled: boolean;
  54535. /**
  54536. * @ignore
  54537. * Specifies if the volumetric lights scattering effect is enabled
  54538. */
  54539. VLSEnabled: boolean;
  54540. /**
  54541. * @ignore
  54542. * Specifies if the motion blur effect is enabled
  54543. */
  54544. MotionBlurEnabled: boolean;
  54545. /**
  54546. * Specifies if anti-aliasing is enabled
  54547. */
  54548. fxaaEnabled: boolean;
  54549. /**
  54550. * Specifies the number of steps used to calculate the volumetric lights
  54551. * Typically in interval [50, 200]
  54552. */
  54553. volumetricLightStepsCount: number;
  54554. /**
  54555. * Specifies the number of samples used for the motion blur effect
  54556. * Typically in interval [16, 64]
  54557. */
  54558. motionBlurSamples: number;
  54559. /**
  54560. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54561. */
  54562. samples: number;
  54563. /**
  54564. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54565. * @constructor
  54566. * @param name The rendering pipeline name
  54567. * @param scene The scene linked to this pipeline
  54568. * @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)
  54569. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54570. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54571. */
  54572. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54573. private _buildPipeline;
  54574. private _createDownSampleX4PostProcess;
  54575. private _createBrightPassPostProcess;
  54576. private _createBlurPostProcesses;
  54577. private _createTextureAdderPostProcess;
  54578. private _createVolumetricLightPostProcess;
  54579. private _createLuminancePostProcesses;
  54580. private _createHdrPostProcess;
  54581. private _createLensFlarePostProcess;
  54582. private _createDepthOfFieldPostProcess;
  54583. private _createMotionBlurPostProcess;
  54584. private _getDepthTexture;
  54585. private _disposePostProcesses;
  54586. /**
  54587. * Dispose of the pipeline and stop all post processes
  54588. */
  54589. dispose(): void;
  54590. /**
  54591. * Serialize the rendering pipeline (Used when exporting)
  54592. * @returns the serialized object
  54593. */
  54594. serialize(): any;
  54595. /**
  54596. * Parse the serialized pipeline
  54597. * @param source Source pipeline.
  54598. * @param scene The scene to load the pipeline to.
  54599. * @param rootUrl The URL of the serialized pipeline.
  54600. * @returns An instantiated pipeline from the serialized object.
  54601. */
  54602. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54603. /**
  54604. * Luminance steps
  54605. */
  54606. static LuminanceSteps: number;
  54607. }
  54608. }
  54609. declare module BABYLON {
  54610. /** @hidden */
  54611. export var tonemapPixelShader: {
  54612. name: string;
  54613. shader: string;
  54614. };
  54615. }
  54616. declare module BABYLON {
  54617. /** Defines operator used for tonemapping */
  54618. export enum TonemappingOperator {
  54619. /** Hable */
  54620. Hable = 0,
  54621. /** Reinhard */
  54622. Reinhard = 1,
  54623. /** HejiDawson */
  54624. HejiDawson = 2,
  54625. /** Photographic */
  54626. Photographic = 3
  54627. }
  54628. /**
  54629. * Defines a post process to apply tone mapping
  54630. */
  54631. export class TonemapPostProcess extends PostProcess {
  54632. private _operator;
  54633. /** Defines the required exposure adjustement */
  54634. exposureAdjustment: number;
  54635. /**
  54636. * Creates a new TonemapPostProcess
  54637. * @param name defines the name of the postprocess
  54638. * @param _operator defines the operator to use
  54639. * @param exposureAdjustment defines the required exposure adjustement
  54640. * @param camera defines the camera to use (can be null)
  54641. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54642. * @param engine defines the hosting engine (can be ignore if camera is set)
  54643. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54644. */
  54645. constructor(name: string, _operator: TonemappingOperator,
  54646. /** Defines the required exposure adjustement */
  54647. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54648. }
  54649. }
  54650. declare module BABYLON {
  54651. /** @hidden */
  54652. export var depthVertexShader: {
  54653. name: string;
  54654. shader: string;
  54655. };
  54656. }
  54657. declare module BABYLON {
  54658. /** @hidden */
  54659. export var volumetricLightScatteringPixelShader: {
  54660. name: string;
  54661. shader: string;
  54662. };
  54663. }
  54664. declare module BABYLON {
  54665. /** @hidden */
  54666. export var volumetricLightScatteringPassPixelShader: {
  54667. name: string;
  54668. shader: string;
  54669. };
  54670. }
  54671. declare module BABYLON {
  54672. /**
  54673. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54674. */
  54675. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54676. private _volumetricLightScatteringPass;
  54677. private _volumetricLightScatteringRTT;
  54678. private _viewPort;
  54679. private _screenCoordinates;
  54680. private _cachedDefines;
  54681. /**
  54682. * If not undefined, the mesh position is computed from the attached node position
  54683. */
  54684. attachedNode: {
  54685. position: Vector3;
  54686. };
  54687. /**
  54688. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54689. */
  54690. customMeshPosition: Vector3;
  54691. /**
  54692. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54693. */
  54694. useCustomMeshPosition: boolean;
  54695. /**
  54696. * If the post-process should inverse the light scattering direction
  54697. */
  54698. invert: boolean;
  54699. /**
  54700. * The internal mesh used by the post-process
  54701. */
  54702. mesh: Mesh;
  54703. /**
  54704. * @hidden
  54705. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54706. */
  54707. useDiffuseColor: boolean;
  54708. /**
  54709. * Array containing the excluded meshes not rendered in the internal pass
  54710. */
  54711. excludedMeshes: AbstractMesh[];
  54712. /**
  54713. * Controls the overall intensity of the post-process
  54714. */
  54715. exposure: number;
  54716. /**
  54717. * Dissipates each sample's contribution in range [0, 1]
  54718. */
  54719. decay: number;
  54720. /**
  54721. * Controls the overall intensity of each sample
  54722. */
  54723. weight: number;
  54724. /**
  54725. * Controls the density of each sample
  54726. */
  54727. density: number;
  54728. /**
  54729. * @constructor
  54730. * @param name The post-process name
  54731. * @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)
  54732. * @param camera The camera that the post-process will be attached to
  54733. * @param mesh The mesh used to create the light scattering
  54734. * @param samples The post-process quality, default 100
  54735. * @param samplingModeThe post-process filtering mode
  54736. * @param engine The babylon engine
  54737. * @param reusable If the post-process is reusable
  54738. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54739. */
  54740. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54741. /**
  54742. * Returns the string "VolumetricLightScatteringPostProcess"
  54743. * @returns "VolumetricLightScatteringPostProcess"
  54744. */
  54745. getClassName(): string;
  54746. private _isReady;
  54747. /**
  54748. * Sets the new light position for light scattering effect
  54749. * @param position The new custom light position
  54750. */
  54751. setCustomMeshPosition(position: Vector3): void;
  54752. /**
  54753. * Returns the light position for light scattering effect
  54754. * @return Vector3 The custom light position
  54755. */
  54756. getCustomMeshPosition(): Vector3;
  54757. /**
  54758. * Disposes the internal assets and detaches the post-process from the camera
  54759. */
  54760. dispose(camera: Camera): void;
  54761. /**
  54762. * Returns the render target texture used by the post-process
  54763. * @return the render target texture used by the post-process
  54764. */
  54765. getPass(): RenderTargetTexture;
  54766. private _meshExcluded;
  54767. private _createPass;
  54768. private _updateMeshScreenCoordinates;
  54769. /**
  54770. * Creates a default mesh for the Volumeric Light Scattering post-process
  54771. * @param name The mesh name
  54772. * @param scene The scene where to create the mesh
  54773. * @return the default mesh
  54774. */
  54775. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54776. }
  54777. }
  54778. declare module BABYLON {
  54779. interface Scene {
  54780. /** @hidden (Backing field) */
  54781. _boundingBoxRenderer: BoundingBoxRenderer;
  54782. /** @hidden (Backing field) */
  54783. _forceShowBoundingBoxes: boolean;
  54784. /**
  54785. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54786. */
  54787. forceShowBoundingBoxes: boolean;
  54788. /**
  54789. * Gets the bounding box renderer associated with the scene
  54790. * @returns a BoundingBoxRenderer
  54791. */
  54792. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54793. }
  54794. interface AbstractMesh {
  54795. /** @hidden (Backing field) */
  54796. _showBoundingBox: boolean;
  54797. /**
  54798. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54799. */
  54800. showBoundingBox: boolean;
  54801. }
  54802. /**
  54803. * Component responsible of rendering the bounding box of the meshes in a scene.
  54804. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54805. */
  54806. export class BoundingBoxRenderer implements ISceneComponent {
  54807. /**
  54808. * The component name helpfull to identify the component in the list of scene components.
  54809. */
  54810. readonly name: string;
  54811. /**
  54812. * The scene the component belongs to.
  54813. */
  54814. scene: Scene;
  54815. /**
  54816. * Color of the bounding box lines placed in front of an object
  54817. */
  54818. frontColor: Color3;
  54819. /**
  54820. * Color of the bounding box lines placed behind an object
  54821. */
  54822. backColor: Color3;
  54823. /**
  54824. * Defines if the renderer should show the back lines or not
  54825. */
  54826. showBackLines: boolean;
  54827. /**
  54828. * @hidden
  54829. */
  54830. renderList: SmartArray<BoundingBox>;
  54831. private _colorShader;
  54832. private _vertexBuffers;
  54833. private _indexBuffer;
  54834. /**
  54835. * Instantiates a new bounding box renderer in a scene.
  54836. * @param scene the scene the renderer renders in
  54837. */
  54838. constructor(scene: Scene);
  54839. /**
  54840. * Registers the component in a given scene
  54841. */
  54842. register(): void;
  54843. private _evaluateSubMesh;
  54844. private _activeMesh;
  54845. private _prepareRessources;
  54846. private _createIndexBuffer;
  54847. /**
  54848. * Rebuilds the elements related to this component in case of
  54849. * context lost for instance.
  54850. */
  54851. rebuild(): void;
  54852. /**
  54853. * @hidden
  54854. */
  54855. reset(): void;
  54856. /**
  54857. * Render the bounding boxes of a specific rendering group
  54858. * @param renderingGroupId defines the rendering group to render
  54859. */
  54860. render(renderingGroupId: number): void;
  54861. /**
  54862. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54863. * @param mesh Define the mesh to render the occlusion bounding box for
  54864. */
  54865. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54866. /**
  54867. * Dispose and release the resources attached to this renderer.
  54868. */
  54869. dispose(): void;
  54870. }
  54871. }
  54872. declare module BABYLON {
  54873. /** @hidden */
  54874. export var depthPixelShader: {
  54875. name: string;
  54876. shader: string;
  54877. };
  54878. }
  54879. declare module BABYLON {
  54880. /**
  54881. * This represents a depth renderer in Babylon.
  54882. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54883. */
  54884. export class DepthRenderer {
  54885. private _scene;
  54886. private _depthMap;
  54887. private _effect;
  54888. private _cachedDefines;
  54889. private _camera;
  54890. /**
  54891. * Specifiess that the depth renderer will only be used within
  54892. * the camera it is created for.
  54893. * This can help forcing its rendering during the camera processing.
  54894. */
  54895. useOnlyInActiveCamera: boolean;
  54896. /** @hidden */
  54897. static _SceneComponentInitialization: (scene: Scene) => void;
  54898. /**
  54899. * Instantiates a depth renderer
  54900. * @param scene The scene the renderer belongs to
  54901. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54902. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54903. */
  54904. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54905. /**
  54906. * Creates the depth rendering effect and checks if the effect is ready.
  54907. * @param subMesh The submesh to be used to render the depth map of
  54908. * @param useInstances If multiple world instances should be used
  54909. * @returns if the depth renderer is ready to render the depth map
  54910. */
  54911. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54912. /**
  54913. * Gets the texture which the depth map will be written to.
  54914. * @returns The depth map texture
  54915. */
  54916. getDepthMap(): RenderTargetTexture;
  54917. /**
  54918. * Disposes of the depth renderer.
  54919. */
  54920. dispose(): void;
  54921. }
  54922. }
  54923. declare module BABYLON {
  54924. interface Scene {
  54925. /** @hidden (Backing field) */
  54926. _depthRenderer: {
  54927. [id: string]: DepthRenderer;
  54928. };
  54929. /**
  54930. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54931. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54932. * @returns the created depth renderer
  54933. */
  54934. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54935. /**
  54936. * Disables a depth renderer for a given camera
  54937. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54938. */
  54939. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54940. }
  54941. /**
  54942. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54943. * in several rendering techniques.
  54944. */
  54945. export class DepthRendererSceneComponent implements ISceneComponent {
  54946. /**
  54947. * The component name helpfull to identify the component in the list of scene components.
  54948. */
  54949. readonly name: string;
  54950. /**
  54951. * The scene the component belongs to.
  54952. */
  54953. scene: Scene;
  54954. /**
  54955. * Creates a new instance of the component for the given scene
  54956. * @param scene Defines the scene to register the component in
  54957. */
  54958. constructor(scene: Scene);
  54959. /**
  54960. * Registers the component in a given scene
  54961. */
  54962. register(): void;
  54963. /**
  54964. * Rebuilds the elements related to this component in case of
  54965. * context lost for instance.
  54966. */
  54967. rebuild(): void;
  54968. /**
  54969. * Disposes the component and the associated ressources
  54970. */
  54971. dispose(): void;
  54972. private _gatherRenderTargets;
  54973. private _gatherActiveCameraRenderTargets;
  54974. }
  54975. }
  54976. declare module BABYLON {
  54977. /** @hidden */
  54978. export var outlinePixelShader: {
  54979. name: string;
  54980. shader: string;
  54981. };
  54982. }
  54983. declare module BABYLON {
  54984. /** @hidden */
  54985. export var outlineVertexShader: {
  54986. name: string;
  54987. shader: string;
  54988. };
  54989. }
  54990. declare module BABYLON {
  54991. interface Scene {
  54992. /** @hidden */
  54993. _outlineRenderer: OutlineRenderer;
  54994. /**
  54995. * Gets the outline renderer associated with the scene
  54996. * @returns a OutlineRenderer
  54997. */
  54998. getOutlineRenderer(): OutlineRenderer;
  54999. }
  55000. interface AbstractMesh {
  55001. /** @hidden (Backing field) */
  55002. _renderOutline: boolean;
  55003. /**
  55004. * Gets or sets a boolean indicating if the outline must be rendered as well
  55005. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55006. */
  55007. renderOutline: boolean;
  55008. /** @hidden (Backing field) */
  55009. _renderOverlay: boolean;
  55010. /**
  55011. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55012. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55013. */
  55014. renderOverlay: boolean;
  55015. }
  55016. /**
  55017. * This class is responsible to draw bothe outline/overlay of meshes.
  55018. * It should not be used directly but through the available method on mesh.
  55019. */
  55020. export class OutlineRenderer implements ISceneComponent {
  55021. /**
  55022. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  55023. */
  55024. private static _StencilReference;
  55025. /**
  55026. * The name of the component. Each component must have a unique name.
  55027. */
  55028. name: string;
  55029. /**
  55030. * The scene the component belongs to.
  55031. */
  55032. scene: Scene;
  55033. /**
  55034. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55035. */
  55036. zOffset: number;
  55037. private _engine;
  55038. private _effect;
  55039. private _cachedDefines;
  55040. private _savedDepthWrite;
  55041. /**
  55042. * Instantiates a new outline renderer. (There could be only one per scene).
  55043. * @param scene Defines the scene it belongs to
  55044. */
  55045. constructor(scene: Scene);
  55046. /**
  55047. * Register the component to one instance of a scene.
  55048. */
  55049. register(): void;
  55050. /**
  55051. * Rebuilds the elements related to this component in case of
  55052. * context lost for instance.
  55053. */
  55054. rebuild(): void;
  55055. /**
  55056. * Disposes the component and the associated ressources.
  55057. */
  55058. dispose(): void;
  55059. /**
  55060. * Renders the outline in the canvas.
  55061. * @param subMesh Defines the sumesh to render
  55062. * @param batch Defines the batch of meshes in case of instances
  55063. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55064. */
  55065. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55066. /**
  55067. * Returns whether or not the outline renderer is ready for a given submesh.
  55068. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55069. * @param subMesh Defines the submesh to check readyness for
  55070. * @param useInstances Defines wheter wee are trying to render instances or not
  55071. * @returns true if ready otherwise false
  55072. */
  55073. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55074. private _beforeRenderingMesh;
  55075. private _afterRenderingMesh;
  55076. }
  55077. }
  55078. declare module BABYLON {
  55079. /**
  55080. * Defines the list of states available for a task inside a AssetsManager
  55081. */
  55082. export enum AssetTaskState {
  55083. /**
  55084. * Initialization
  55085. */
  55086. INIT = 0,
  55087. /**
  55088. * Running
  55089. */
  55090. RUNNING = 1,
  55091. /**
  55092. * Done
  55093. */
  55094. DONE = 2,
  55095. /**
  55096. * Error
  55097. */
  55098. ERROR = 3
  55099. }
  55100. /**
  55101. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55102. */
  55103. export abstract class AbstractAssetTask {
  55104. /**
  55105. * Task name
  55106. */ name: string;
  55107. /**
  55108. * Callback called when the task is successful
  55109. */
  55110. onSuccess: (task: any) => void;
  55111. /**
  55112. * Callback called when the task is not successful
  55113. */
  55114. onError: (task: any, message?: string, exception?: any) => void;
  55115. /**
  55116. * Creates a new AssetsManager
  55117. * @param name defines the name of the task
  55118. */
  55119. constructor(
  55120. /**
  55121. * Task name
  55122. */ name: string);
  55123. private _isCompleted;
  55124. private _taskState;
  55125. private _errorObject;
  55126. /**
  55127. * Get if the task is completed
  55128. */
  55129. readonly isCompleted: boolean;
  55130. /**
  55131. * Gets the current state of the task
  55132. */
  55133. readonly taskState: AssetTaskState;
  55134. /**
  55135. * Gets the current error object (if task is in error)
  55136. */
  55137. readonly errorObject: {
  55138. message?: string;
  55139. exception?: any;
  55140. };
  55141. /**
  55142. * Internal only
  55143. * @hidden
  55144. */
  55145. _setErrorObject(message?: string, exception?: any): void;
  55146. /**
  55147. * Execute the current task
  55148. * @param scene defines the scene where you want your assets to be loaded
  55149. * @param onSuccess is a callback called when the task is successfully executed
  55150. * @param onError is a callback called if an error occurs
  55151. */
  55152. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55153. /**
  55154. * Execute the current task
  55155. * @param scene defines the scene where you want your assets to be loaded
  55156. * @param onSuccess is a callback called when the task is successfully executed
  55157. * @param onError is a callback called if an error occurs
  55158. */
  55159. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55160. /**
  55161. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55162. * This can be used with failed tasks that have the reason for failure fixed.
  55163. */
  55164. reset(): void;
  55165. private onErrorCallback;
  55166. private onDoneCallback;
  55167. }
  55168. /**
  55169. * Define the interface used by progress events raised during assets loading
  55170. */
  55171. export interface IAssetsProgressEvent {
  55172. /**
  55173. * Defines the number of remaining tasks to process
  55174. */
  55175. remainingCount: number;
  55176. /**
  55177. * Defines the total number of tasks
  55178. */
  55179. totalCount: number;
  55180. /**
  55181. * Defines the task that was just processed
  55182. */
  55183. task: AbstractAssetTask;
  55184. }
  55185. /**
  55186. * Class used to share progress information about assets loading
  55187. */
  55188. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55189. /**
  55190. * Defines the number of remaining tasks to process
  55191. */
  55192. remainingCount: number;
  55193. /**
  55194. * Defines the total number of tasks
  55195. */
  55196. totalCount: number;
  55197. /**
  55198. * Defines the task that was just processed
  55199. */
  55200. task: AbstractAssetTask;
  55201. /**
  55202. * Creates a AssetsProgressEvent
  55203. * @param remainingCount defines the number of remaining tasks to process
  55204. * @param totalCount defines the total number of tasks
  55205. * @param task defines the task that was just processed
  55206. */
  55207. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55208. }
  55209. /**
  55210. * Define a task used by AssetsManager to load meshes
  55211. */
  55212. export class MeshAssetTask extends AbstractAssetTask {
  55213. /**
  55214. * Defines the name of the task
  55215. */
  55216. name: string;
  55217. /**
  55218. * Defines the list of mesh's names you want to load
  55219. */
  55220. meshesNames: any;
  55221. /**
  55222. * Defines the root url to use as a base to load your meshes and associated resources
  55223. */
  55224. rootUrl: string;
  55225. /**
  55226. * Defines the filename of the scene to load from
  55227. */
  55228. sceneFilename: string;
  55229. /**
  55230. * Gets the list of loaded meshes
  55231. */
  55232. loadedMeshes: Array<AbstractMesh>;
  55233. /**
  55234. * Gets the list of loaded particle systems
  55235. */
  55236. loadedParticleSystems: Array<IParticleSystem>;
  55237. /**
  55238. * Gets the list of loaded skeletons
  55239. */
  55240. loadedSkeletons: Array<Skeleton>;
  55241. /**
  55242. * Gets the list of loaded animation groups
  55243. */
  55244. loadedAnimationGroups: Array<AnimationGroup>;
  55245. /**
  55246. * Callback called when the task is successful
  55247. */
  55248. onSuccess: (task: MeshAssetTask) => void;
  55249. /**
  55250. * Callback called when the task is successful
  55251. */
  55252. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55253. /**
  55254. * Creates a new MeshAssetTask
  55255. * @param name defines the name of the task
  55256. * @param meshesNames defines the list of mesh's names you want to load
  55257. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55258. * @param sceneFilename defines the filename of the scene to load from
  55259. */
  55260. constructor(
  55261. /**
  55262. * Defines the name of the task
  55263. */
  55264. name: string,
  55265. /**
  55266. * Defines the list of mesh's names you want to load
  55267. */
  55268. meshesNames: any,
  55269. /**
  55270. * Defines the root url to use as a base to load your meshes and associated resources
  55271. */
  55272. rootUrl: string,
  55273. /**
  55274. * Defines the filename of the scene to load from
  55275. */
  55276. sceneFilename: string);
  55277. /**
  55278. * Execute the current task
  55279. * @param scene defines the scene where you want your assets to be loaded
  55280. * @param onSuccess is a callback called when the task is successfully executed
  55281. * @param onError is a callback called if an error occurs
  55282. */
  55283. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55284. }
  55285. /**
  55286. * Define a task used by AssetsManager to load text content
  55287. */
  55288. export class TextFileAssetTask extends AbstractAssetTask {
  55289. /**
  55290. * Defines the name of the task
  55291. */
  55292. name: string;
  55293. /**
  55294. * Defines the location of the file to load
  55295. */
  55296. url: string;
  55297. /**
  55298. * Gets the loaded text string
  55299. */
  55300. text: string;
  55301. /**
  55302. * Callback called when the task is successful
  55303. */
  55304. onSuccess: (task: TextFileAssetTask) => void;
  55305. /**
  55306. * Callback called when the task is successful
  55307. */
  55308. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55309. /**
  55310. * Creates a new TextFileAssetTask object
  55311. * @param name defines the name of the task
  55312. * @param url defines the location of the file to load
  55313. */
  55314. constructor(
  55315. /**
  55316. * Defines the name of the task
  55317. */
  55318. name: string,
  55319. /**
  55320. * Defines the location of the file to load
  55321. */
  55322. url: string);
  55323. /**
  55324. * Execute the current task
  55325. * @param scene defines the scene where you want your assets to be loaded
  55326. * @param onSuccess is a callback called when the task is successfully executed
  55327. * @param onError is a callback called if an error occurs
  55328. */
  55329. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55330. }
  55331. /**
  55332. * Define a task used by AssetsManager to load binary data
  55333. */
  55334. export class BinaryFileAssetTask extends AbstractAssetTask {
  55335. /**
  55336. * Defines the name of the task
  55337. */
  55338. name: string;
  55339. /**
  55340. * Defines the location of the file to load
  55341. */
  55342. url: string;
  55343. /**
  55344. * Gets the lodaded data (as an array buffer)
  55345. */
  55346. data: ArrayBuffer;
  55347. /**
  55348. * Callback called when the task is successful
  55349. */
  55350. onSuccess: (task: BinaryFileAssetTask) => void;
  55351. /**
  55352. * Callback called when the task is successful
  55353. */
  55354. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55355. /**
  55356. * Creates a new BinaryFileAssetTask object
  55357. * @param name defines the name of the new task
  55358. * @param url defines the location of the file to load
  55359. */
  55360. constructor(
  55361. /**
  55362. * Defines the name of the task
  55363. */
  55364. name: string,
  55365. /**
  55366. * Defines the location of the file to load
  55367. */
  55368. url: string);
  55369. /**
  55370. * Execute the current task
  55371. * @param scene defines the scene where you want your assets to be loaded
  55372. * @param onSuccess is a callback called when the task is successfully executed
  55373. * @param onError is a callback called if an error occurs
  55374. */
  55375. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55376. }
  55377. /**
  55378. * Define a task used by AssetsManager to load images
  55379. */
  55380. export class ImageAssetTask extends AbstractAssetTask {
  55381. /**
  55382. * Defines the name of the task
  55383. */
  55384. name: string;
  55385. /**
  55386. * Defines the location of the image to load
  55387. */
  55388. url: string;
  55389. /**
  55390. * Gets the loaded images
  55391. */
  55392. image: HTMLImageElement;
  55393. /**
  55394. * Callback called when the task is successful
  55395. */
  55396. onSuccess: (task: ImageAssetTask) => void;
  55397. /**
  55398. * Callback called when the task is successful
  55399. */
  55400. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55401. /**
  55402. * Creates a new ImageAssetTask
  55403. * @param name defines the name of the task
  55404. * @param url defines the location of the image to load
  55405. */
  55406. constructor(
  55407. /**
  55408. * Defines the name of the task
  55409. */
  55410. name: string,
  55411. /**
  55412. * Defines the location of the image to load
  55413. */
  55414. url: string);
  55415. /**
  55416. * Execute the current task
  55417. * @param scene defines the scene where you want your assets to be loaded
  55418. * @param onSuccess is a callback called when the task is successfully executed
  55419. * @param onError is a callback called if an error occurs
  55420. */
  55421. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55422. }
  55423. /**
  55424. * Defines the interface used by texture loading tasks
  55425. */
  55426. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55427. /**
  55428. * Gets the loaded texture
  55429. */
  55430. texture: TEX;
  55431. }
  55432. /**
  55433. * Define a task used by AssetsManager to load 2D textures
  55434. */
  55435. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55436. /**
  55437. * Defines the name of the task
  55438. */
  55439. name: string;
  55440. /**
  55441. * Defines the location of the file to load
  55442. */
  55443. url: string;
  55444. /**
  55445. * Defines if mipmap should not be generated (default is false)
  55446. */
  55447. noMipmap?: boolean | undefined;
  55448. /**
  55449. * Defines if texture must be inverted on Y axis (default is false)
  55450. */
  55451. invertY?: boolean | undefined;
  55452. /**
  55453. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55454. */
  55455. samplingMode: number;
  55456. /**
  55457. * Gets the loaded texture
  55458. */
  55459. texture: Texture;
  55460. /**
  55461. * Callback called when the task is successful
  55462. */
  55463. onSuccess: (task: TextureAssetTask) => void;
  55464. /**
  55465. * Callback called when the task is successful
  55466. */
  55467. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55468. /**
  55469. * Creates a new TextureAssetTask object
  55470. * @param name defines the name of the task
  55471. * @param url defines the location of the file to load
  55472. * @param noMipmap defines if mipmap should not be generated (default is false)
  55473. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55474. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55475. */
  55476. constructor(
  55477. /**
  55478. * Defines the name of the task
  55479. */
  55480. name: string,
  55481. /**
  55482. * Defines the location of the file to load
  55483. */
  55484. url: string,
  55485. /**
  55486. * Defines if mipmap should not be generated (default is false)
  55487. */
  55488. noMipmap?: boolean | undefined,
  55489. /**
  55490. * Defines if texture must be inverted on Y axis (default is false)
  55491. */
  55492. invertY?: boolean | undefined,
  55493. /**
  55494. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55495. */
  55496. samplingMode?: number);
  55497. /**
  55498. * Execute the current task
  55499. * @param scene defines the scene where you want your assets to be loaded
  55500. * @param onSuccess is a callback called when the task is successfully executed
  55501. * @param onError is a callback called if an error occurs
  55502. */
  55503. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55504. }
  55505. /**
  55506. * Define a task used by AssetsManager to load cube textures
  55507. */
  55508. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55509. /**
  55510. * Defines the name of the task
  55511. */
  55512. name: string;
  55513. /**
  55514. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55515. */
  55516. url: string;
  55517. /**
  55518. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55519. */
  55520. extensions?: string[] | undefined;
  55521. /**
  55522. * Defines if mipmaps should not be generated (default is false)
  55523. */
  55524. noMipmap?: boolean | undefined;
  55525. /**
  55526. * Defines the explicit list of files (undefined by default)
  55527. */
  55528. files?: string[] | undefined;
  55529. /**
  55530. * Gets the loaded texture
  55531. */
  55532. texture: CubeTexture;
  55533. /**
  55534. * Callback called when the task is successful
  55535. */
  55536. onSuccess: (task: CubeTextureAssetTask) => void;
  55537. /**
  55538. * Callback called when the task is successful
  55539. */
  55540. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55541. /**
  55542. * Creates a new CubeTextureAssetTask
  55543. * @param name defines the name of the task
  55544. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55545. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55546. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55547. * @param files defines the explicit list of files (undefined by default)
  55548. */
  55549. constructor(
  55550. /**
  55551. * Defines the name of the task
  55552. */
  55553. name: string,
  55554. /**
  55555. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55556. */
  55557. url: string,
  55558. /**
  55559. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55560. */
  55561. extensions?: string[] | undefined,
  55562. /**
  55563. * Defines if mipmaps should not be generated (default is false)
  55564. */
  55565. noMipmap?: boolean | undefined,
  55566. /**
  55567. * Defines the explicit list of files (undefined by default)
  55568. */
  55569. files?: string[] | undefined);
  55570. /**
  55571. * Execute the current task
  55572. * @param scene defines the scene where you want your assets to be loaded
  55573. * @param onSuccess is a callback called when the task is successfully executed
  55574. * @param onError is a callback called if an error occurs
  55575. */
  55576. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55577. }
  55578. /**
  55579. * Define a task used by AssetsManager to load HDR cube textures
  55580. */
  55581. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55582. /**
  55583. * Defines the name of the task
  55584. */
  55585. name: string;
  55586. /**
  55587. * Defines the location of the file to load
  55588. */
  55589. url: string;
  55590. /**
  55591. * Defines the desired size (the more it increases the longer the generation will be)
  55592. */
  55593. size: number;
  55594. /**
  55595. * Defines if mipmaps should not be generated (default is false)
  55596. */
  55597. noMipmap: boolean;
  55598. /**
  55599. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55600. */
  55601. generateHarmonics: boolean;
  55602. /**
  55603. * 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)
  55604. */
  55605. gammaSpace: boolean;
  55606. /**
  55607. * Internal Use Only
  55608. */
  55609. reserved: boolean;
  55610. /**
  55611. * Gets the loaded texture
  55612. */
  55613. texture: HDRCubeTexture;
  55614. /**
  55615. * Callback called when the task is successful
  55616. */
  55617. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55618. /**
  55619. * Callback called when the task is successful
  55620. */
  55621. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55622. /**
  55623. * Creates a new HDRCubeTextureAssetTask object
  55624. * @param name defines the name of the task
  55625. * @param url defines the location of the file to load
  55626. * @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.
  55627. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55628. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55629. * @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)
  55630. * @param reserved Internal use only
  55631. */
  55632. constructor(
  55633. /**
  55634. * Defines the name of the task
  55635. */
  55636. name: string,
  55637. /**
  55638. * Defines the location of the file to load
  55639. */
  55640. url: string,
  55641. /**
  55642. * Defines the desired size (the more it increases the longer the generation will be)
  55643. */
  55644. size: number,
  55645. /**
  55646. * Defines if mipmaps should not be generated (default is false)
  55647. */
  55648. noMipmap?: boolean,
  55649. /**
  55650. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55651. */
  55652. generateHarmonics?: boolean,
  55653. /**
  55654. * 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)
  55655. */
  55656. gammaSpace?: boolean,
  55657. /**
  55658. * Internal Use Only
  55659. */
  55660. reserved?: boolean);
  55661. /**
  55662. * Execute the current task
  55663. * @param scene defines the scene where you want your assets to be loaded
  55664. * @param onSuccess is a callback called when the task is successfully executed
  55665. * @param onError is a callback called if an error occurs
  55666. */
  55667. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55668. }
  55669. /**
  55670. * Define a task used by AssetsManager to load Equirectangular cube textures
  55671. */
  55672. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  55673. /**
  55674. * Defines the name of the task
  55675. */
  55676. name: string;
  55677. /**
  55678. * Defines the location of the file to load
  55679. */
  55680. url: string;
  55681. /**
  55682. * Defines the desired size (the more it increases the longer the generation will be)
  55683. */
  55684. size: number;
  55685. /**
  55686. * Defines if mipmaps should not be generated (default is false)
  55687. */
  55688. noMipmap: boolean;
  55689. /**
  55690. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55691. * but the standard material would require them in Gamma space) (default is true)
  55692. */
  55693. gammaSpace: boolean;
  55694. /**
  55695. * Gets the loaded texture
  55696. */
  55697. texture: EquiRectangularCubeTexture;
  55698. /**
  55699. * Callback called when the task is successful
  55700. */
  55701. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  55702. /**
  55703. * Callback called when the task is successful
  55704. */
  55705. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  55706. /**
  55707. * Creates a new EquiRectangularCubeTextureAssetTask object
  55708. * @param name defines the name of the task
  55709. * @param url defines the location of the file to load
  55710. * @param size defines the desired size (the more it increases the longer the generation will be)
  55711. * If the size is omitted this implies you are using a preprocessed cubemap.
  55712. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55713. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  55714. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  55715. * (default is true)
  55716. */
  55717. constructor(
  55718. /**
  55719. * Defines the name of the task
  55720. */
  55721. name: string,
  55722. /**
  55723. * Defines the location of the file to load
  55724. */
  55725. url: string,
  55726. /**
  55727. * Defines the desired size (the more it increases the longer the generation will be)
  55728. */
  55729. size: number,
  55730. /**
  55731. * Defines if mipmaps should not be generated (default is false)
  55732. */
  55733. noMipmap?: boolean,
  55734. /**
  55735. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55736. * but the standard material would require them in Gamma space) (default is true)
  55737. */
  55738. gammaSpace?: boolean);
  55739. /**
  55740. * Execute the current task
  55741. * @param scene defines the scene where you want your assets to be loaded
  55742. * @param onSuccess is a callback called when the task is successfully executed
  55743. * @param onError is a callback called if an error occurs
  55744. */
  55745. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55746. }
  55747. /**
  55748. * This class can be used to easily import assets into a scene
  55749. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55750. */
  55751. export class AssetsManager {
  55752. private _scene;
  55753. private _isLoading;
  55754. protected _tasks: AbstractAssetTask[];
  55755. protected _waitingTasksCount: number;
  55756. protected _totalTasksCount: number;
  55757. /**
  55758. * Callback called when all tasks are processed
  55759. */
  55760. onFinish: (tasks: AbstractAssetTask[]) => void;
  55761. /**
  55762. * Callback called when a task is successful
  55763. */
  55764. onTaskSuccess: (task: AbstractAssetTask) => void;
  55765. /**
  55766. * Callback called when a task had an error
  55767. */
  55768. onTaskError: (task: AbstractAssetTask) => void;
  55769. /**
  55770. * Callback called when a task is done (whatever the result is)
  55771. */
  55772. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55773. /**
  55774. * Observable called when all tasks are processed
  55775. */
  55776. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55777. /**
  55778. * Observable called when a task had an error
  55779. */
  55780. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55781. /**
  55782. * Observable called when all tasks were executed
  55783. */
  55784. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55785. /**
  55786. * Observable called when a task is done (whatever the result is)
  55787. */
  55788. onProgressObservable: Observable<IAssetsProgressEvent>;
  55789. /**
  55790. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55791. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55792. */
  55793. useDefaultLoadingScreen: boolean;
  55794. /**
  55795. * Creates a new AssetsManager
  55796. * @param scene defines the scene to work on
  55797. */
  55798. constructor(scene: Scene);
  55799. /**
  55800. * Add a MeshAssetTask to the list of active tasks
  55801. * @param taskName defines the name of the new task
  55802. * @param meshesNames defines the name of meshes to load
  55803. * @param rootUrl defines the root url to use to locate files
  55804. * @param sceneFilename defines the filename of the scene file
  55805. * @returns a new MeshAssetTask object
  55806. */
  55807. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55808. /**
  55809. * Add a TextFileAssetTask to the list of active tasks
  55810. * @param taskName defines the name of the new task
  55811. * @param url defines the url of the file to load
  55812. * @returns a new TextFileAssetTask object
  55813. */
  55814. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55815. /**
  55816. * Add a BinaryFileAssetTask to the list of active tasks
  55817. * @param taskName defines the name of the new task
  55818. * @param url defines the url of the file to load
  55819. * @returns a new BinaryFileAssetTask object
  55820. */
  55821. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55822. /**
  55823. * Add a ImageAssetTask to the list of active tasks
  55824. * @param taskName defines the name of the new task
  55825. * @param url defines the url of the file to load
  55826. * @returns a new ImageAssetTask object
  55827. */
  55828. addImageTask(taskName: string, url: string): ImageAssetTask;
  55829. /**
  55830. * Add a TextureAssetTask to the list of active tasks
  55831. * @param taskName defines the name of the new task
  55832. * @param url defines the url of the file to load
  55833. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55834. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55835. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55836. * @returns a new TextureAssetTask object
  55837. */
  55838. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55839. /**
  55840. * Add a CubeTextureAssetTask to the list of active tasks
  55841. * @param taskName defines the name of the new task
  55842. * @param url defines the url of the file to load
  55843. * @param extensions defines the extension to use to load the cube map (can be null)
  55844. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55845. * @param files defines the list of files to load (can be null)
  55846. * @returns a new CubeTextureAssetTask object
  55847. */
  55848. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55849. /**
  55850. *
  55851. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55852. * @param taskName defines the name of the new task
  55853. * @param url defines the url of the file to load
  55854. * @param size defines the size you want for the cubemap (can be null)
  55855. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55856. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55857. * @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)
  55858. * @param reserved Internal use only
  55859. * @returns a new HDRCubeTextureAssetTask object
  55860. */
  55861. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55862. /**
  55863. *
  55864. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  55865. * @param taskName defines the name of the new task
  55866. * @param url defines the url of the file to load
  55867. * @param size defines the size you want for the cubemap (can be null)
  55868. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55869. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55870. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55871. * @returns a new EquiRectangularCubeTextureAssetTask object
  55872. */
  55873. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  55874. /**
  55875. * Remove a task from the assets manager.
  55876. * @param task the task to remove
  55877. */
  55878. removeTask(task: AbstractAssetTask): void;
  55879. private _decreaseWaitingTasksCount;
  55880. private _runTask;
  55881. /**
  55882. * Reset the AssetsManager and remove all tasks
  55883. * @return the current instance of the AssetsManager
  55884. */
  55885. reset(): AssetsManager;
  55886. /**
  55887. * Start the loading process
  55888. * @return the current instance of the AssetsManager
  55889. */
  55890. load(): AssetsManager;
  55891. /**
  55892. * Start the loading process as an async operation
  55893. * @return a promise returning the list of failed tasks
  55894. */
  55895. loadAsync(): Promise<void>;
  55896. }
  55897. }
  55898. declare module BABYLON {
  55899. /**
  55900. * Wrapper class for promise with external resolve and reject.
  55901. */
  55902. export class Deferred<T> {
  55903. /**
  55904. * The promise associated with this deferred object.
  55905. */
  55906. readonly promise: Promise<T>;
  55907. private _resolve;
  55908. private _reject;
  55909. /**
  55910. * The resolve method of the promise associated with this deferred object.
  55911. */
  55912. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55913. /**
  55914. * The reject method of the promise associated with this deferred object.
  55915. */
  55916. readonly reject: (reason?: any) => void;
  55917. /**
  55918. * Constructor for this deferred object.
  55919. */
  55920. constructor();
  55921. }
  55922. }
  55923. declare module BABYLON {
  55924. /**
  55925. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  55926. */
  55927. export class MeshExploder {
  55928. private _centerMesh;
  55929. private _meshes;
  55930. private _meshesOrigins;
  55931. private _toCenterVectors;
  55932. private _scaledDirection;
  55933. private _newPosition;
  55934. private _centerPosition;
  55935. /**
  55936. * Explodes meshes from a center mesh.
  55937. * @param meshes The meshes to explode.
  55938. * @param centerMesh The mesh to be center of explosion.
  55939. */
  55940. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  55941. private _setCenterMesh;
  55942. /**
  55943. * Get class name
  55944. * @returns "MeshExploder"
  55945. */
  55946. getClassName(): string;
  55947. /**
  55948. * "Exploded meshes"
  55949. * @returns Array of meshes with the centerMesh at index 0.
  55950. */
  55951. getMeshes(): Array<Mesh>;
  55952. /**
  55953. * Explodes meshes giving a specific direction
  55954. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  55955. */
  55956. explode(direction?: number): void;
  55957. }
  55958. }
  55959. declare module BABYLON {
  55960. /**
  55961. * Class used to help managing file picking and drag'n'drop
  55962. */
  55963. export class FilesInput {
  55964. /**
  55965. * List of files ready to be loaded
  55966. */
  55967. static readonly FilesToLoad: {
  55968. [key: string]: File;
  55969. };
  55970. /**
  55971. * Callback called when a file is processed
  55972. */
  55973. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55974. private _engine;
  55975. private _currentScene;
  55976. private _sceneLoadedCallback;
  55977. private _progressCallback;
  55978. private _additionalRenderLoopLogicCallback;
  55979. private _textureLoadingCallback;
  55980. private _startingProcessingFilesCallback;
  55981. private _onReloadCallback;
  55982. private _errorCallback;
  55983. private _elementToMonitor;
  55984. private _sceneFileToLoad;
  55985. private _filesToLoad;
  55986. /**
  55987. * Creates a new FilesInput
  55988. * @param engine defines the rendering engine
  55989. * @param scene defines the hosting scene
  55990. * @param sceneLoadedCallback callback called when scene is loaded
  55991. * @param progressCallback callback called to track progress
  55992. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55993. * @param textureLoadingCallback callback called when a texture is loading
  55994. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55995. * @param onReloadCallback callback called when a reload is requested
  55996. * @param errorCallback callback call if an error occurs
  55997. */
  55998. 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);
  55999. private _dragEnterHandler;
  56000. private _dragOverHandler;
  56001. private _dropHandler;
  56002. /**
  56003. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56004. * @param elementToMonitor defines the DOM element to track
  56005. */
  56006. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56007. /**
  56008. * Release all associated resources
  56009. */
  56010. dispose(): void;
  56011. private renderFunction;
  56012. private drag;
  56013. private drop;
  56014. private _traverseFolder;
  56015. private _processFiles;
  56016. /**
  56017. * Load files from a drop event
  56018. * @param event defines the drop event to use as source
  56019. */
  56020. loadFiles(event: any): void;
  56021. private _processReload;
  56022. /**
  56023. * Reload the current scene from the loaded files
  56024. */
  56025. reload(): void;
  56026. }
  56027. }
  56028. declare module BABYLON {
  56029. /**
  56030. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56031. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56032. */
  56033. export class SceneOptimization {
  56034. /**
  56035. * Defines the priority of this optimization (0 by default which means first in the list)
  56036. */
  56037. priority: number;
  56038. /**
  56039. * Gets a string describing the action executed by the current optimization
  56040. * @returns description string
  56041. */
  56042. getDescription(): string;
  56043. /**
  56044. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56045. * @param scene defines the current scene where to apply this optimization
  56046. * @param optimizer defines the current optimizer
  56047. * @returns true if everything that can be done was applied
  56048. */
  56049. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56050. /**
  56051. * Creates the SceneOptimization object
  56052. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56053. * @param desc defines the description associated with the optimization
  56054. */
  56055. constructor(
  56056. /**
  56057. * Defines the priority of this optimization (0 by default which means first in the list)
  56058. */
  56059. priority?: number);
  56060. }
  56061. /**
  56062. * Defines an optimization used to reduce the size of render target textures
  56063. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56064. */
  56065. export class TextureOptimization extends SceneOptimization {
  56066. /**
  56067. * Defines the priority of this optimization (0 by default which means first in the list)
  56068. */
  56069. priority: number;
  56070. /**
  56071. * 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
  56072. */
  56073. maximumSize: number;
  56074. /**
  56075. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56076. */
  56077. step: number;
  56078. /**
  56079. * Gets a string describing the action executed by the current optimization
  56080. * @returns description string
  56081. */
  56082. getDescription(): string;
  56083. /**
  56084. * Creates the TextureOptimization object
  56085. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56086. * @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
  56087. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56088. */
  56089. constructor(
  56090. /**
  56091. * Defines the priority of this optimization (0 by default which means first in the list)
  56092. */
  56093. priority?: number,
  56094. /**
  56095. * 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
  56096. */
  56097. maximumSize?: number,
  56098. /**
  56099. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56100. */
  56101. step?: number);
  56102. /**
  56103. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56104. * @param scene defines the current scene where to apply this optimization
  56105. * @param optimizer defines the current optimizer
  56106. * @returns true if everything that can be done was applied
  56107. */
  56108. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56109. }
  56110. /**
  56111. * Defines an optimization used to increase or decrease the rendering resolution
  56112. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56113. */
  56114. export class HardwareScalingOptimization extends SceneOptimization {
  56115. /**
  56116. * Defines the priority of this optimization (0 by default which means first in the list)
  56117. */
  56118. priority: number;
  56119. /**
  56120. * Defines the maximum scale to use (2 by default)
  56121. */
  56122. maximumScale: number;
  56123. /**
  56124. * Defines the step to use between two passes (0.5 by default)
  56125. */
  56126. step: number;
  56127. private _currentScale;
  56128. private _directionOffset;
  56129. /**
  56130. * Gets a string describing the action executed by the current optimization
  56131. * @return description string
  56132. */
  56133. getDescription(): string;
  56134. /**
  56135. * Creates the HardwareScalingOptimization object
  56136. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56137. * @param maximumScale defines the maximum scale to use (2 by default)
  56138. * @param step defines the step to use between two passes (0.5 by default)
  56139. */
  56140. constructor(
  56141. /**
  56142. * Defines the priority of this optimization (0 by default which means first in the list)
  56143. */
  56144. priority?: number,
  56145. /**
  56146. * Defines the maximum scale to use (2 by default)
  56147. */
  56148. maximumScale?: number,
  56149. /**
  56150. * Defines the step to use between two passes (0.5 by default)
  56151. */
  56152. step?: number);
  56153. /**
  56154. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56155. * @param scene defines the current scene where to apply this optimization
  56156. * @param optimizer defines the current optimizer
  56157. * @returns true if everything that can be done was applied
  56158. */
  56159. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56160. }
  56161. /**
  56162. * Defines an optimization used to remove shadows
  56163. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56164. */
  56165. export class ShadowsOptimization extends SceneOptimization {
  56166. /**
  56167. * Gets a string describing the action executed by the current optimization
  56168. * @return description string
  56169. */
  56170. getDescription(): string;
  56171. /**
  56172. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56173. * @param scene defines the current scene where to apply this optimization
  56174. * @param optimizer defines the current optimizer
  56175. * @returns true if everything that can be done was applied
  56176. */
  56177. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56178. }
  56179. /**
  56180. * Defines an optimization used to turn post-processes off
  56181. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56182. */
  56183. export class PostProcessesOptimization extends SceneOptimization {
  56184. /**
  56185. * Gets a string describing the action executed by the current optimization
  56186. * @return description string
  56187. */
  56188. getDescription(): string;
  56189. /**
  56190. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56191. * @param scene defines the current scene where to apply this optimization
  56192. * @param optimizer defines the current optimizer
  56193. * @returns true if everything that can be done was applied
  56194. */
  56195. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56196. }
  56197. /**
  56198. * Defines an optimization used to turn lens flares off
  56199. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56200. */
  56201. export class LensFlaresOptimization extends SceneOptimization {
  56202. /**
  56203. * Gets a string describing the action executed by the current optimization
  56204. * @return description string
  56205. */
  56206. getDescription(): string;
  56207. /**
  56208. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56209. * @param scene defines the current scene where to apply this optimization
  56210. * @param optimizer defines the current optimizer
  56211. * @returns true if everything that can be done was applied
  56212. */
  56213. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56214. }
  56215. /**
  56216. * Defines an optimization based on user defined callback.
  56217. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56218. */
  56219. export class CustomOptimization extends SceneOptimization {
  56220. /**
  56221. * Callback called to apply the custom optimization.
  56222. */
  56223. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56224. /**
  56225. * Callback called to get custom description
  56226. */
  56227. onGetDescription: () => string;
  56228. /**
  56229. * Gets a string describing the action executed by the current optimization
  56230. * @returns description string
  56231. */
  56232. getDescription(): string;
  56233. /**
  56234. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56235. * @param scene defines the current scene where to apply this optimization
  56236. * @param optimizer defines the current optimizer
  56237. * @returns true if everything that can be done was applied
  56238. */
  56239. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56240. }
  56241. /**
  56242. * Defines an optimization used to turn particles off
  56243. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56244. */
  56245. export class ParticlesOptimization extends SceneOptimization {
  56246. /**
  56247. * Gets a string describing the action executed by the current optimization
  56248. * @return description string
  56249. */
  56250. getDescription(): string;
  56251. /**
  56252. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56253. * @param scene defines the current scene where to apply this optimization
  56254. * @param optimizer defines the current optimizer
  56255. * @returns true if everything that can be done was applied
  56256. */
  56257. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56258. }
  56259. /**
  56260. * Defines an optimization used to turn render targets off
  56261. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56262. */
  56263. export class RenderTargetsOptimization extends SceneOptimization {
  56264. /**
  56265. * Gets a string describing the action executed by the current optimization
  56266. * @return description string
  56267. */
  56268. getDescription(): string;
  56269. /**
  56270. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56271. * @param scene defines the current scene where to apply this optimization
  56272. * @param optimizer defines the current optimizer
  56273. * @returns true if everything that can be done was applied
  56274. */
  56275. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56276. }
  56277. /**
  56278. * Defines an optimization used to merge meshes with compatible materials
  56279. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56280. */
  56281. export class MergeMeshesOptimization extends SceneOptimization {
  56282. private static _UpdateSelectionTree;
  56283. /**
  56284. * Gets or sets a boolean which defines if optimization octree has to be updated
  56285. */
  56286. /**
  56287. * Gets or sets a boolean which defines if optimization octree has to be updated
  56288. */
  56289. static UpdateSelectionTree: boolean;
  56290. /**
  56291. * Gets a string describing the action executed by the current optimization
  56292. * @return description string
  56293. */
  56294. getDescription(): string;
  56295. private _canBeMerged;
  56296. /**
  56297. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56298. * @param scene defines the current scene where to apply this optimization
  56299. * @param optimizer defines the current optimizer
  56300. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56301. * @returns true if everything that can be done was applied
  56302. */
  56303. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56304. }
  56305. /**
  56306. * Defines a list of options used by SceneOptimizer
  56307. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56308. */
  56309. export class SceneOptimizerOptions {
  56310. /**
  56311. * Defines the target frame rate to reach (60 by default)
  56312. */
  56313. targetFrameRate: number;
  56314. /**
  56315. * Defines the interval between two checkes (2000ms by default)
  56316. */
  56317. trackerDuration: number;
  56318. /**
  56319. * Gets the list of optimizations to apply
  56320. */
  56321. optimizations: SceneOptimization[];
  56322. /**
  56323. * Creates a new list of options used by SceneOptimizer
  56324. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56325. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56326. */
  56327. constructor(
  56328. /**
  56329. * Defines the target frame rate to reach (60 by default)
  56330. */
  56331. targetFrameRate?: number,
  56332. /**
  56333. * Defines the interval between two checkes (2000ms by default)
  56334. */
  56335. trackerDuration?: number);
  56336. /**
  56337. * Add a new optimization
  56338. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56339. * @returns the current SceneOptimizerOptions
  56340. */
  56341. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56342. /**
  56343. * Add a new custom optimization
  56344. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56345. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56346. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56347. * @returns the current SceneOptimizerOptions
  56348. */
  56349. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56350. /**
  56351. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56352. * @param targetFrameRate defines the target frame rate (60 by default)
  56353. * @returns a SceneOptimizerOptions object
  56354. */
  56355. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56356. /**
  56357. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56358. * @param targetFrameRate defines the target frame rate (60 by default)
  56359. * @returns a SceneOptimizerOptions object
  56360. */
  56361. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56362. /**
  56363. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56364. * @param targetFrameRate defines the target frame rate (60 by default)
  56365. * @returns a SceneOptimizerOptions object
  56366. */
  56367. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56368. }
  56369. /**
  56370. * Class used to run optimizations in order to reach a target frame rate
  56371. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56372. */
  56373. export class SceneOptimizer implements IDisposable {
  56374. private _isRunning;
  56375. private _options;
  56376. private _scene;
  56377. private _currentPriorityLevel;
  56378. private _targetFrameRate;
  56379. private _trackerDuration;
  56380. private _currentFrameRate;
  56381. private _sceneDisposeObserver;
  56382. private _improvementMode;
  56383. /**
  56384. * Defines an observable called when the optimizer reaches the target frame rate
  56385. */
  56386. onSuccessObservable: Observable<SceneOptimizer>;
  56387. /**
  56388. * Defines an observable called when the optimizer enables an optimization
  56389. */
  56390. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56391. /**
  56392. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56393. */
  56394. onFailureObservable: Observable<SceneOptimizer>;
  56395. /**
  56396. * Gets a boolean indicating if the optimizer is in improvement mode
  56397. */
  56398. readonly isInImprovementMode: boolean;
  56399. /**
  56400. * Gets the current priority level (0 at start)
  56401. */
  56402. readonly currentPriorityLevel: number;
  56403. /**
  56404. * Gets the current frame rate checked by the SceneOptimizer
  56405. */
  56406. readonly currentFrameRate: number;
  56407. /**
  56408. * Gets or sets the current target frame rate (60 by default)
  56409. */
  56410. /**
  56411. * Gets or sets the current target frame rate (60 by default)
  56412. */
  56413. targetFrameRate: number;
  56414. /**
  56415. * Gets or sets the current interval between two checks (every 2000ms by default)
  56416. */
  56417. /**
  56418. * Gets or sets the current interval between two checks (every 2000ms by default)
  56419. */
  56420. trackerDuration: number;
  56421. /**
  56422. * Gets the list of active optimizations
  56423. */
  56424. readonly optimizations: SceneOptimization[];
  56425. /**
  56426. * Creates a new SceneOptimizer
  56427. * @param scene defines the scene to work on
  56428. * @param options defines the options to use with the SceneOptimizer
  56429. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56430. * @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)
  56431. */
  56432. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56433. /**
  56434. * Stops the current optimizer
  56435. */
  56436. stop(): void;
  56437. /**
  56438. * Reset the optimizer to initial step (current priority level = 0)
  56439. */
  56440. reset(): void;
  56441. /**
  56442. * Start the optimizer. By default it will try to reach a specific framerate
  56443. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56444. */
  56445. start(): void;
  56446. private _checkCurrentState;
  56447. /**
  56448. * Release all resources
  56449. */
  56450. dispose(): void;
  56451. /**
  56452. * Helper function to create a SceneOptimizer with one single line of code
  56453. * @param scene defines the scene to work on
  56454. * @param options defines the options to use with the SceneOptimizer
  56455. * @param onSuccess defines a callback to call on success
  56456. * @param onFailure defines a callback to call on failure
  56457. * @returns the new SceneOptimizer object
  56458. */
  56459. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56460. }
  56461. }
  56462. declare module BABYLON {
  56463. /**
  56464. * Class used to serialize a scene into a string
  56465. */
  56466. export class SceneSerializer {
  56467. /**
  56468. * Clear cache used by a previous serialization
  56469. */
  56470. static ClearCache(): void;
  56471. /**
  56472. * Serialize a scene into a JSON compatible object
  56473. * @param scene defines the scene to serialize
  56474. * @returns a JSON compatible object
  56475. */
  56476. static Serialize(scene: Scene): any;
  56477. /**
  56478. * Serialize a mesh into a JSON compatible object
  56479. * @param toSerialize defines the mesh to serialize
  56480. * @param withParents defines if parents must be serialized as well
  56481. * @param withChildren defines if children must be serialized as well
  56482. * @returns a JSON compatible object
  56483. */
  56484. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56485. }
  56486. }
  56487. declare module BABYLON {
  56488. /**
  56489. * Class used to host texture specific utilities
  56490. */
  56491. export class TextureTools {
  56492. /**
  56493. * Uses the GPU to create a copy texture rescaled at a given size
  56494. * @param texture Texture to copy from
  56495. * @param width defines the desired width
  56496. * @param height defines the desired height
  56497. * @param useBilinearMode defines if bilinear mode has to be used
  56498. * @return the generated texture
  56499. */
  56500. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  56501. }
  56502. }
  56503. declare module BABYLON {
  56504. /**
  56505. * This represents the different options avilable for the video capture.
  56506. */
  56507. export interface VideoRecorderOptions {
  56508. /** Defines the mime type of the video */
  56509. mimeType: string;
  56510. /** Defines the video the video should be recorded at */
  56511. fps: number;
  56512. /** Defines the chunk size for the recording data */
  56513. recordChunckSize: number;
  56514. /** The audio tracks to attach to the record */
  56515. audioTracks?: MediaStreamTrack[];
  56516. }
  56517. /**
  56518. * This can helps recording videos from BabylonJS.
  56519. * This is based on the available WebRTC functionalities of the browser.
  56520. *
  56521. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56522. */
  56523. export class VideoRecorder {
  56524. private static readonly _defaultOptions;
  56525. /**
  56526. * Returns wehther or not the VideoRecorder is available in your browser.
  56527. * @param engine Defines the Babylon Engine to check the support for
  56528. * @returns true if supported otherwise false
  56529. */
  56530. static IsSupported(engine: Engine): boolean;
  56531. private readonly _options;
  56532. private _canvas;
  56533. private _mediaRecorder;
  56534. private _recordedChunks;
  56535. private _fileName;
  56536. private _resolve;
  56537. private _reject;
  56538. /**
  56539. * True wether a recording is already in progress.
  56540. */
  56541. readonly isRecording: boolean;
  56542. /**
  56543. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56544. * a video file.
  56545. * @param engine Defines the BabylonJS Engine you wish to record
  56546. * @param options Defines options that can be used to customized the capture
  56547. */
  56548. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56549. /**
  56550. * Stops the current recording before the default capture timeout passed in the startRecording
  56551. * functions.
  56552. */
  56553. stopRecording(): void;
  56554. /**
  56555. * Starts recording the canvas for a max duration specified in parameters.
  56556. * @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.
  56557. * @param maxDuration Defines the maximum recording time in seconds.
  56558. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56559. * @return a promise callback at the end of the recording with the video data in Blob.
  56560. */
  56561. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56562. /**
  56563. * Releases internal resources used during the recording.
  56564. */
  56565. dispose(): void;
  56566. private _handleDataAvailable;
  56567. private _handleError;
  56568. private _handleStop;
  56569. }
  56570. }
  56571. declare module BABYLON {
  56572. /**
  56573. * Class containing a set of static utilities functions for screenshots
  56574. */
  56575. export class ScreenshotTools {
  56576. /**
  56577. * Captures a screenshot of the current rendering
  56578. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56579. * @param engine defines the rendering engine
  56580. * @param camera defines the source camera
  56581. * @param size This parameter can be set to a single number or to an object with the
  56582. * following (optional) properties: precision, width, height. If a single number is passed,
  56583. * it will be used for both width and height. If an object is passed, the screenshot size
  56584. * will be derived from the parameters. The precision property is a multiplier allowing
  56585. * rendering at a higher or lower resolution
  56586. * @param successCallback defines the callback receives a single parameter which contains the
  56587. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56588. * src parameter of an <img> to display it
  56589. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56590. * Check your browser for supported MIME types
  56591. */
  56592. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56593. /**
  56594. * Generates an image screenshot from the specified camera.
  56595. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56596. * @param engine The engine to use for rendering
  56597. * @param camera The camera to use for rendering
  56598. * @param size This parameter can be set to a single number or to an object with the
  56599. * following (optional) properties: precision, width, height. If a single number is passed,
  56600. * it will be used for both width and height. If an object is passed, the screenshot size
  56601. * will be derived from the parameters. The precision property is a multiplier allowing
  56602. * rendering at a higher or lower resolution
  56603. * @param successCallback The callback receives a single parameter which contains the
  56604. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56605. * src parameter of an <img> to display it
  56606. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56607. * Check your browser for supported MIME types
  56608. * @param samples Texture samples (default: 1)
  56609. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56610. * @param fileName A name for for the downloaded file.
  56611. */
  56612. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56613. }
  56614. }
  56615. declare module BABYLON {
  56616. /**
  56617. * A cursor which tracks a point on a path
  56618. */
  56619. export class PathCursor {
  56620. private path;
  56621. /**
  56622. * Stores path cursor callbacks for when an onchange event is triggered
  56623. */
  56624. private _onchange;
  56625. /**
  56626. * The value of the path cursor
  56627. */
  56628. value: number;
  56629. /**
  56630. * The animation array of the path cursor
  56631. */
  56632. animations: Animation[];
  56633. /**
  56634. * Initializes the path cursor
  56635. * @param path The path to track
  56636. */
  56637. constructor(path: Path2);
  56638. /**
  56639. * Gets the cursor point on the path
  56640. * @returns A point on the path cursor at the cursor location
  56641. */
  56642. getPoint(): Vector3;
  56643. /**
  56644. * Moves the cursor ahead by the step amount
  56645. * @param step The amount to move the cursor forward
  56646. * @returns This path cursor
  56647. */
  56648. moveAhead(step?: number): PathCursor;
  56649. /**
  56650. * Moves the cursor behind by the step amount
  56651. * @param step The amount to move the cursor back
  56652. * @returns This path cursor
  56653. */
  56654. moveBack(step?: number): PathCursor;
  56655. /**
  56656. * Moves the cursor by the step amount
  56657. * If the step amount is greater than one, an exception is thrown
  56658. * @param step The amount to move the cursor
  56659. * @returns This path cursor
  56660. */
  56661. move(step: number): PathCursor;
  56662. /**
  56663. * Ensures that the value is limited between zero and one
  56664. * @returns This path cursor
  56665. */
  56666. private ensureLimits;
  56667. /**
  56668. * Runs onchange callbacks on change (used by the animation engine)
  56669. * @returns This path cursor
  56670. */
  56671. private raiseOnChange;
  56672. /**
  56673. * Executes a function on change
  56674. * @param f A path cursor onchange callback
  56675. * @returns This path cursor
  56676. */
  56677. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56678. }
  56679. }
  56680. declare module BABYLON {
  56681. /** @hidden */
  56682. export var blurPixelShader: {
  56683. name: string;
  56684. shader: string;
  56685. };
  56686. }
  56687. declare module BABYLON {
  56688. /** @hidden */
  56689. export var bones300Declaration: {
  56690. name: string;
  56691. shader: string;
  56692. };
  56693. }
  56694. declare module BABYLON {
  56695. /** @hidden */
  56696. export var instances300Declaration: {
  56697. name: string;
  56698. shader: string;
  56699. };
  56700. }
  56701. declare module BABYLON {
  56702. /** @hidden */
  56703. export var pointCloudVertexDeclaration: {
  56704. name: string;
  56705. shader: string;
  56706. };
  56707. }
  56708. // Mixins
  56709. interface Window {
  56710. mozIndexedDB: IDBFactory;
  56711. webkitIndexedDB: IDBFactory;
  56712. msIndexedDB: IDBFactory;
  56713. webkitURL: typeof URL;
  56714. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56715. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56716. WebGLRenderingContext: WebGLRenderingContext;
  56717. MSGesture: MSGesture;
  56718. CANNON: any;
  56719. AudioContext: AudioContext;
  56720. webkitAudioContext: AudioContext;
  56721. PointerEvent: any;
  56722. Math: Math;
  56723. Uint8Array: Uint8ArrayConstructor;
  56724. Float32Array: Float32ArrayConstructor;
  56725. mozURL: typeof URL;
  56726. msURL: typeof URL;
  56727. VRFrameData: any; // WebVR, from specs 1.1
  56728. DracoDecoderModule: any;
  56729. setImmediate(handler: (...args: any[]) => void): number;
  56730. }
  56731. interface HTMLCanvasElement {
  56732. requestPointerLock(): void;
  56733. msRequestPointerLock?(): void;
  56734. mozRequestPointerLock?(): void;
  56735. webkitRequestPointerLock?(): void;
  56736. /** Track wether a record is in progress */
  56737. isRecording: boolean;
  56738. /** Capture Stream method defined by some browsers */
  56739. captureStream(fps?: number): MediaStream;
  56740. }
  56741. interface CanvasRenderingContext2D {
  56742. msImageSmoothingEnabled: boolean;
  56743. }
  56744. interface MouseEvent {
  56745. mozMovementX: number;
  56746. mozMovementY: number;
  56747. webkitMovementX: number;
  56748. webkitMovementY: number;
  56749. msMovementX: number;
  56750. msMovementY: number;
  56751. }
  56752. interface Navigator {
  56753. mozGetVRDevices: (any: any) => any;
  56754. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56755. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56756. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56757. webkitGetGamepads(): Gamepad[];
  56758. msGetGamepads(): Gamepad[];
  56759. webkitGamepads(): Gamepad[];
  56760. }
  56761. interface HTMLVideoElement {
  56762. mozSrcObject: any;
  56763. }
  56764. interface Math {
  56765. fround(x: number): number;
  56766. imul(a: number, b: number): number;
  56767. }
  56768. interface WebGLRenderingContext {
  56769. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56770. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56771. vertexAttribDivisor(index: number, divisor: number): void;
  56772. createVertexArray(): any;
  56773. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56774. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56775. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56776. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56777. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56778. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56779. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56780. // Queries
  56781. createQuery(): WebGLQuery;
  56782. deleteQuery(query: WebGLQuery): void;
  56783. beginQuery(target: number, query: WebGLQuery): void;
  56784. endQuery(target: number): void;
  56785. getQueryParameter(query: WebGLQuery, pname: number): any;
  56786. getQuery(target: number, pname: number): any;
  56787. MAX_SAMPLES: number;
  56788. RGBA8: number;
  56789. READ_FRAMEBUFFER: number;
  56790. DRAW_FRAMEBUFFER: number;
  56791. UNIFORM_BUFFER: number;
  56792. HALF_FLOAT_OES: number;
  56793. RGBA16F: number;
  56794. RGBA32F: number;
  56795. R32F: number;
  56796. RG32F: number;
  56797. RGB32F: number;
  56798. R16F: number;
  56799. RG16F: number;
  56800. RGB16F: number;
  56801. RED: number;
  56802. RG: number;
  56803. R8: number;
  56804. RG8: number;
  56805. UNSIGNED_INT_24_8: number;
  56806. DEPTH24_STENCIL8: number;
  56807. /* Multiple Render Targets */
  56808. drawBuffers(buffers: number[]): void;
  56809. readBuffer(src: number): void;
  56810. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56811. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56812. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56813. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56814. // Occlusion Query
  56815. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56816. ANY_SAMPLES_PASSED: number;
  56817. QUERY_RESULT_AVAILABLE: number;
  56818. QUERY_RESULT: number;
  56819. }
  56820. interface WebGLProgram {
  56821. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56822. }
  56823. interface EXT_disjoint_timer_query {
  56824. QUERY_COUNTER_BITS_EXT: number;
  56825. TIME_ELAPSED_EXT: number;
  56826. TIMESTAMP_EXT: number;
  56827. GPU_DISJOINT_EXT: number;
  56828. QUERY_RESULT_EXT: number;
  56829. QUERY_RESULT_AVAILABLE_EXT: number;
  56830. queryCounterEXT(query: WebGLQuery, target: number): void;
  56831. createQueryEXT(): WebGLQuery;
  56832. beginQueryEXT(target: number, query: WebGLQuery): void;
  56833. endQueryEXT(target: number): void;
  56834. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56835. deleteQueryEXT(query: WebGLQuery): void;
  56836. }
  56837. interface WebGLUniformLocation {
  56838. _currentState: any;
  56839. }
  56840. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56841. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56842. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56843. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56844. interface WebGLRenderingContext {
  56845. readonly RASTERIZER_DISCARD: number;
  56846. readonly DEPTH_COMPONENT24: number;
  56847. readonly TEXTURE_3D: number;
  56848. readonly TEXTURE_2D_ARRAY: number;
  56849. readonly TEXTURE_COMPARE_FUNC: number;
  56850. readonly TEXTURE_COMPARE_MODE: number;
  56851. readonly COMPARE_REF_TO_TEXTURE: number;
  56852. readonly TEXTURE_WRAP_R: number;
  56853. readonly HALF_FLOAT: number;
  56854. readonly RGB8: number;
  56855. readonly RED_INTEGER: number;
  56856. readonly RG_INTEGER: number;
  56857. readonly RGB_INTEGER: number;
  56858. readonly RGBA_INTEGER: number;
  56859. readonly R8_SNORM: number;
  56860. readonly RG8_SNORM: number;
  56861. readonly RGB8_SNORM: number;
  56862. readonly RGBA8_SNORM: number;
  56863. readonly R8I: number;
  56864. readonly RG8I: number;
  56865. readonly RGB8I: number;
  56866. readonly RGBA8I: number;
  56867. readonly R8UI: number;
  56868. readonly RG8UI: number;
  56869. readonly RGB8UI: number;
  56870. readonly RGBA8UI: number;
  56871. readonly R16I: number;
  56872. readonly RG16I: number;
  56873. readonly RGB16I: number;
  56874. readonly RGBA16I: number;
  56875. readonly R16UI: number;
  56876. readonly RG16UI: number;
  56877. readonly RGB16UI: number;
  56878. readonly RGBA16UI: number;
  56879. readonly R32I: number;
  56880. readonly RG32I: number;
  56881. readonly RGB32I: number;
  56882. readonly RGBA32I: number;
  56883. readonly R32UI: number;
  56884. readonly RG32UI: number;
  56885. readonly RGB32UI: number;
  56886. readonly RGBA32UI: number;
  56887. readonly RGB10_A2UI: number;
  56888. readonly R11F_G11F_B10F: number;
  56889. readonly RGB9_E5: number;
  56890. readonly RGB10_A2: number;
  56891. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56892. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56893. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56894. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56895. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56896. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56897. 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;
  56898. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56899. readonly TRANSFORM_FEEDBACK: number;
  56900. readonly INTERLEAVED_ATTRIBS: number;
  56901. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56902. createTransformFeedback(): WebGLTransformFeedback;
  56903. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56904. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56905. beginTransformFeedback(primitiveMode: number): void;
  56906. endTransformFeedback(): void;
  56907. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56908. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56909. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56910. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56911. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56912. }
  56913. interface ImageBitmap {
  56914. readonly width: number;
  56915. readonly height: number;
  56916. close(): void;
  56917. }
  56918. interface WebGLQuery extends WebGLObject {
  56919. }
  56920. declare var WebGLQuery: {
  56921. prototype: WebGLQuery;
  56922. new(): WebGLQuery;
  56923. };
  56924. interface WebGLSampler extends WebGLObject {
  56925. }
  56926. declare var WebGLSampler: {
  56927. prototype: WebGLSampler;
  56928. new(): WebGLSampler;
  56929. };
  56930. interface WebGLSync extends WebGLObject {
  56931. }
  56932. declare var WebGLSync: {
  56933. prototype: WebGLSync;
  56934. new(): WebGLSync;
  56935. };
  56936. interface WebGLTransformFeedback extends WebGLObject {
  56937. }
  56938. declare var WebGLTransformFeedback: {
  56939. prototype: WebGLTransformFeedback;
  56940. new(): WebGLTransformFeedback;
  56941. };
  56942. interface WebGLVertexArrayObject extends WebGLObject {
  56943. }
  56944. declare var WebGLVertexArrayObject: {
  56945. prototype: WebGLVertexArrayObject;
  56946. new(): WebGLVertexArrayObject;
  56947. };
  56948. // Type definitions for WebVR API
  56949. // Project: https://w3c.github.io/webvr/
  56950. // Definitions by: six a <https://github.com/lostfictions>
  56951. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56952. interface VRDisplay extends EventTarget {
  56953. /**
  56954. * Dictionary of capabilities describing the VRDisplay.
  56955. */
  56956. readonly capabilities: VRDisplayCapabilities;
  56957. /**
  56958. * z-depth defining the far plane of the eye view frustum
  56959. * enables mapping of values in the render target depth
  56960. * attachment to scene coordinates. Initially set to 10000.0.
  56961. */
  56962. depthFar: number;
  56963. /**
  56964. * z-depth defining the near plane of the eye view frustum
  56965. * enables mapping of values in the render target depth
  56966. * attachment to scene coordinates. Initially set to 0.01.
  56967. */
  56968. depthNear: number;
  56969. /**
  56970. * An identifier for this distinct VRDisplay. Used as an
  56971. * association point in the Gamepad API.
  56972. */
  56973. readonly displayId: number;
  56974. /**
  56975. * A display name, a user-readable name identifying it.
  56976. */
  56977. readonly displayName: string;
  56978. readonly isConnected: boolean;
  56979. readonly isPresenting: boolean;
  56980. /**
  56981. * If this VRDisplay supports room-scale experiences, the optional
  56982. * stage attribute contains details on the room-scale parameters.
  56983. */
  56984. readonly stageParameters: VRStageParameters | null;
  56985. /**
  56986. * Passing the value returned by `requestAnimationFrame` to
  56987. * `cancelAnimationFrame` will unregister the callback.
  56988. * @param handle Define the hanle of the request to cancel
  56989. */
  56990. cancelAnimationFrame(handle: number): void;
  56991. /**
  56992. * Stops presenting to the VRDisplay.
  56993. * @returns a promise to know when it stopped
  56994. */
  56995. exitPresent(): Promise<void>;
  56996. /**
  56997. * Return the current VREyeParameters for the given eye.
  56998. * @param whichEye Define the eye we want the parameter for
  56999. * @returns the eye parameters
  57000. */
  57001. getEyeParameters(whichEye: string): VREyeParameters;
  57002. /**
  57003. * Populates the passed VRFrameData with the information required to render
  57004. * the current frame.
  57005. * @param frameData Define the data structure to populate
  57006. * @returns true if ok otherwise false
  57007. */
  57008. getFrameData(frameData: VRFrameData): boolean;
  57009. /**
  57010. * Get the layers currently being presented.
  57011. * @returns the list of VR layers
  57012. */
  57013. getLayers(): VRLayer[];
  57014. /**
  57015. * Return a VRPose containing the future predicted pose of the VRDisplay
  57016. * when the current frame will be presented. The value returned will not
  57017. * change until JavaScript has returned control to the browser.
  57018. *
  57019. * The VRPose will contain the position, orientation, velocity,
  57020. * and acceleration of each of these properties.
  57021. * @returns the pose object
  57022. */
  57023. getPose(): VRPose;
  57024. /**
  57025. * Return the current instantaneous pose of the VRDisplay, with no
  57026. * prediction applied.
  57027. * @returns the current instantaneous pose
  57028. */
  57029. getImmediatePose(): VRPose;
  57030. /**
  57031. * The callback passed to `requestAnimationFrame` will be called
  57032. * any time a new frame should be rendered. When the VRDisplay is
  57033. * presenting the callback will be called at the native refresh
  57034. * rate of the HMD. When not presenting this function acts
  57035. * identically to how window.requestAnimationFrame acts. Content should
  57036. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57037. * asynchronously from other displays and at differing refresh rates.
  57038. * @param callback Define the eaction to run next frame
  57039. * @returns the request handle it
  57040. */
  57041. requestAnimationFrame(callback: FrameRequestCallback): number;
  57042. /**
  57043. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57044. * Repeat calls while already presenting will update the VRLayers being displayed.
  57045. * @param layers Define the list of layer to present
  57046. * @returns a promise to know when the request has been fulfilled
  57047. */
  57048. requestPresent(layers: VRLayer[]): Promise<void>;
  57049. /**
  57050. * Reset the pose for this display, treating its current position and
  57051. * orientation as the "origin/zero" values. VRPose.position,
  57052. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57053. * updated when calling resetPose(). This should be called in only
  57054. * sitting-space experiences.
  57055. */
  57056. resetPose(): void;
  57057. /**
  57058. * The VRLayer provided to the VRDisplay will be captured and presented
  57059. * in the HMD. Calling this function has the same effect on the source
  57060. * canvas as any other operation that uses its source image, and canvases
  57061. * created without preserveDrawingBuffer set to true will be cleared.
  57062. * @param pose Define the pose to submit
  57063. */
  57064. submitFrame(pose?: VRPose): void;
  57065. }
  57066. declare var VRDisplay: {
  57067. prototype: VRDisplay;
  57068. new(): VRDisplay;
  57069. };
  57070. interface VRLayer {
  57071. leftBounds?: number[] | Float32Array | null;
  57072. rightBounds?: number[] | Float32Array | null;
  57073. source?: HTMLCanvasElement | null;
  57074. }
  57075. interface VRDisplayCapabilities {
  57076. readonly canPresent: boolean;
  57077. readonly hasExternalDisplay: boolean;
  57078. readonly hasOrientation: boolean;
  57079. readonly hasPosition: boolean;
  57080. readonly maxLayers: number;
  57081. }
  57082. interface VREyeParameters {
  57083. /** @deprecated */
  57084. readonly fieldOfView: VRFieldOfView;
  57085. readonly offset: Float32Array;
  57086. readonly renderHeight: number;
  57087. readonly renderWidth: number;
  57088. }
  57089. interface VRFieldOfView {
  57090. readonly downDegrees: number;
  57091. readonly leftDegrees: number;
  57092. readonly rightDegrees: number;
  57093. readonly upDegrees: number;
  57094. }
  57095. interface VRFrameData {
  57096. readonly leftProjectionMatrix: Float32Array;
  57097. readonly leftViewMatrix: Float32Array;
  57098. readonly pose: VRPose;
  57099. readonly rightProjectionMatrix: Float32Array;
  57100. readonly rightViewMatrix: Float32Array;
  57101. readonly timestamp: number;
  57102. }
  57103. interface VRPose {
  57104. readonly angularAcceleration: Float32Array | null;
  57105. readonly angularVelocity: Float32Array | null;
  57106. readonly linearAcceleration: Float32Array | null;
  57107. readonly linearVelocity: Float32Array | null;
  57108. readonly orientation: Float32Array | null;
  57109. readonly position: Float32Array | null;
  57110. readonly timestamp: number;
  57111. }
  57112. interface VRStageParameters {
  57113. sittingToStandingTransform?: Float32Array;
  57114. sizeX?: number;
  57115. sizeY?: number;
  57116. }
  57117. interface Navigator {
  57118. getVRDisplays(): Promise<VRDisplay[]>;
  57119. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57120. }
  57121. interface Window {
  57122. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57123. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57124. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57125. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57126. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57127. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57128. }
  57129. interface Gamepad {
  57130. readonly displayId: number;
  57131. }
  57132. interface XRDevice {
  57133. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57134. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57135. }
  57136. interface XRSession {
  57137. getInputSources(): Array<any>;
  57138. baseLayer: XRWebGLLayer;
  57139. requestFrameOfReference(type: string): Promise<void>;
  57140. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57141. end(): Promise<void>;
  57142. requestAnimationFrame: Function;
  57143. addEventListener: Function;
  57144. }
  57145. interface XRSessionCreationOptions {
  57146. outputContext?: WebGLRenderingContext | null;
  57147. immersive?: boolean;
  57148. environmentIntegration?: boolean;
  57149. }
  57150. interface XRLayer {
  57151. getViewport: Function;
  57152. framebufferWidth: number;
  57153. framebufferHeight: number;
  57154. }
  57155. interface XRView {
  57156. projectionMatrix: Float32Array;
  57157. }
  57158. interface XRFrame {
  57159. getDevicePose: Function;
  57160. getInputPose: Function;
  57161. views: Array<XRView>;
  57162. baseLayer: XRLayer;
  57163. }
  57164. interface XRFrameOfReference {
  57165. }
  57166. interface XRWebGLLayer extends XRLayer {
  57167. framebuffer: WebGLFramebuffer;
  57168. }
  57169. declare var XRWebGLLayer: {
  57170. prototype: XRWebGLLayer;
  57171. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57172. };