babylon.d.ts 2.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113
  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): 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. /**
  24226. * Class used to store all common mesh properties
  24227. */
  24228. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24229. /** No occlusion */
  24230. static OCCLUSION_TYPE_NONE: number;
  24231. /** Occlusion set to optimisitic */
  24232. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24233. /** Occlusion set to strict */
  24234. static OCCLUSION_TYPE_STRICT: number;
  24235. /** Use an accurante occlusion algorithm */
  24236. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24237. /** Use a conservative occlusion algorithm */
  24238. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24239. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24240. * Test order :
  24241. * Is the bounding sphere outside the frustum ?
  24242. * If not, are the bounding box vertices outside the frustum ?
  24243. * It not, then the cullable object is in the frustum.
  24244. */
  24245. static readonly CULLINGSTRATEGY_STANDARD: number;
  24246. /** Culling strategy : Bounding Sphere Only.
  24247. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24248. * It's also less accurate than the standard because some not visible objects can still be selected.
  24249. * Test : is the bounding sphere outside the frustum ?
  24250. * If not, then the cullable object is in the frustum.
  24251. */
  24252. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24253. /** Culling strategy : Optimistic Inclusion.
  24254. * This in an inclusion test first, then the standard exclusion test.
  24255. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24256. * 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.
  24257. * Anyway, it's as accurate as the standard strategy.
  24258. * Test :
  24259. * Is the cullable object bounding sphere center in the frustum ?
  24260. * If not, apply the default culling strategy.
  24261. */
  24262. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24263. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24264. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24265. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24266. * 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.
  24267. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24268. * Test :
  24269. * Is the cullable object bounding sphere center in the frustum ?
  24270. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24271. */
  24272. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24273. /**
  24274. * No billboard
  24275. */
  24276. static readonly BILLBOARDMODE_NONE: number;
  24277. /** Billboard on X axis */
  24278. static readonly BILLBOARDMODE_X: number;
  24279. /** Billboard on Y axis */
  24280. static readonly BILLBOARDMODE_Y: number;
  24281. /** Billboard on Z axis */
  24282. static readonly BILLBOARDMODE_Z: number;
  24283. /** Billboard on all axes */
  24284. static readonly BILLBOARDMODE_ALL: number;
  24285. private _internalAbstractMeshDataInfo;
  24286. /**
  24287. * The culling strategy to use to check whether the mesh must be rendered or not.
  24288. * This value can be changed at any time and will be used on the next render mesh selection.
  24289. * The possible values are :
  24290. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24291. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24292. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24293. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24294. * Please read each static variable documentation to get details about the culling process.
  24295. * */
  24296. cullingStrategy: number;
  24297. /**
  24298. * Gets the number of facets in the mesh
  24299. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24300. */
  24301. readonly facetNb: number;
  24302. /**
  24303. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24305. */
  24306. partitioningSubdivisions: number;
  24307. /**
  24308. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24309. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24310. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24311. */
  24312. partitioningBBoxRatio: number;
  24313. /**
  24314. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24315. * Works only for updatable meshes.
  24316. * Doesn't work with multi-materials
  24317. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24318. */
  24319. mustDepthSortFacets: boolean;
  24320. /**
  24321. * The location (Vector3) where the facet depth sort must be computed from.
  24322. * By default, the active camera position.
  24323. * Used only when facet depth sort is enabled
  24324. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24325. */
  24326. facetDepthSortFrom: Vector3;
  24327. /**
  24328. * gets a boolean indicating if facetData is enabled
  24329. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24330. */
  24331. readonly isFacetDataEnabled: boolean;
  24332. /** @hidden */
  24333. _updateNonUniformScalingState(value: boolean): boolean;
  24334. /**
  24335. * An event triggered when this mesh collides with another one
  24336. */
  24337. onCollideObservable: Observable<AbstractMesh>;
  24338. /** Set a function to call when this mesh collides with another one */
  24339. onCollide: () => void;
  24340. /**
  24341. * An event triggered when the collision's position changes
  24342. */
  24343. onCollisionPositionChangeObservable: Observable<Vector3>;
  24344. /** Set a function to call when the collision's position changes */
  24345. onCollisionPositionChange: () => void;
  24346. /**
  24347. * An event triggered when material is changed
  24348. */
  24349. onMaterialChangedObservable: Observable<AbstractMesh>;
  24350. /**
  24351. * Gets or sets the orientation for POV movement & rotation
  24352. */
  24353. definedFacingForward: boolean;
  24354. /** @hidden */
  24355. _occlusionQuery: Nullable<WebGLQuery>;
  24356. /** @hidden */
  24357. _isActive: boolean;
  24358. /** @hidden */
  24359. _onlyForInstances: boolean;
  24360. /** @hidden */
  24361. _renderingGroup: Nullable<RenderingGroup>;
  24362. /**
  24363. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24364. */
  24365. /**
  24366. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24367. */
  24368. visibility: number;
  24369. /** Gets or sets the alpha index used to sort transparent meshes
  24370. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24371. */
  24372. alphaIndex: number;
  24373. /**
  24374. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24375. */
  24376. isVisible: boolean;
  24377. /**
  24378. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24379. */
  24380. isPickable: boolean;
  24381. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24382. showSubMeshesBoundingBox: boolean;
  24383. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24384. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24385. */
  24386. isBlocker: boolean;
  24387. /**
  24388. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24389. */
  24390. enablePointerMoveEvents: boolean;
  24391. /**
  24392. * Specifies the rendering group id for this mesh (0 by default)
  24393. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24394. */
  24395. renderingGroupId: number;
  24396. private _material;
  24397. /** Gets or sets current material */
  24398. material: Nullable<Material>;
  24399. /**
  24400. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24401. * @see http://doc.babylonjs.com/babylon101/shadows
  24402. */
  24403. receiveShadows: boolean;
  24404. /** Defines color to use when rendering outline */
  24405. outlineColor: Color3;
  24406. /** Define width to use when rendering outline */
  24407. outlineWidth: number;
  24408. /** Defines color to use when rendering overlay */
  24409. overlayColor: Color3;
  24410. /** Defines alpha to use when rendering overlay */
  24411. overlayAlpha: number;
  24412. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24413. hasVertexAlpha: boolean;
  24414. /** 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) */
  24415. useVertexColors: boolean;
  24416. /**
  24417. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24418. */
  24419. computeBonesUsingShaders: boolean;
  24420. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24421. numBoneInfluencers: number;
  24422. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24423. applyFog: boolean;
  24424. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24425. useOctreeForRenderingSelection: boolean;
  24426. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24427. useOctreeForPicking: boolean;
  24428. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24429. useOctreeForCollisions: boolean;
  24430. /**
  24431. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24432. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24433. */
  24434. layerMask: number;
  24435. /**
  24436. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24437. */
  24438. alwaysSelectAsActiveMesh: boolean;
  24439. /**
  24440. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24441. */
  24442. doNotSyncBoundingInfo: boolean;
  24443. /**
  24444. * Gets or sets the current action manager
  24445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24446. */
  24447. actionManager: Nullable<AbstractActionManager>;
  24448. private _meshCollisionData;
  24449. /**
  24450. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24451. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24452. */
  24453. ellipsoid: Vector3;
  24454. /**
  24455. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24456. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24457. */
  24458. ellipsoidOffset: Vector3;
  24459. /**
  24460. * Gets or sets a collision mask used to mask collisions (default is -1).
  24461. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24462. */
  24463. collisionMask: number;
  24464. /**
  24465. * Gets or sets the current collision group mask (-1 by default).
  24466. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24467. */
  24468. collisionGroup: number;
  24469. /**
  24470. * Defines edge width used when edgesRenderer is enabled
  24471. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24472. */
  24473. edgesWidth: number;
  24474. /**
  24475. * Defines edge color used when edgesRenderer is enabled
  24476. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24477. */
  24478. edgesColor: Color4;
  24479. /** @hidden */
  24480. _edgesRenderer: Nullable<IEdgesRenderer>;
  24481. /** @hidden */
  24482. _masterMesh: Nullable<AbstractMesh>;
  24483. /** @hidden */
  24484. _boundingInfo: Nullable<BoundingInfo>;
  24485. /** @hidden */
  24486. _renderId: number;
  24487. /**
  24488. * Gets or sets the list of subMeshes
  24489. * @see http://doc.babylonjs.com/how_to/multi_materials
  24490. */
  24491. subMeshes: SubMesh[];
  24492. /** @hidden */
  24493. _intersectionsInProgress: AbstractMesh[];
  24494. /** @hidden */
  24495. _unIndexed: boolean;
  24496. /** @hidden */
  24497. _lightSources: Light[];
  24498. /** Gets the list of lights affecting that mesh */
  24499. readonly lightSources: Light[];
  24500. /** @hidden */
  24501. readonly _positions: Nullable<Vector3[]>;
  24502. /** @hidden */
  24503. _waitingData: {
  24504. lods: Nullable<any>;
  24505. actions: Nullable<any>;
  24506. freezeWorldMatrix: Nullable<boolean>;
  24507. };
  24508. /** @hidden */
  24509. _bonesTransformMatrices: Nullable<Float32Array>;
  24510. /**
  24511. * Gets or sets a skeleton to apply skining transformations
  24512. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24513. */
  24514. skeleton: Nullable<Skeleton>;
  24515. /**
  24516. * An event triggered when the mesh is rebuilt.
  24517. */
  24518. onRebuildObservable: Observable<AbstractMesh>;
  24519. /**
  24520. * Creates a new AbstractMesh
  24521. * @param name defines the name of the mesh
  24522. * @param scene defines the hosting scene
  24523. */
  24524. constructor(name: string, scene?: Nullable<Scene>);
  24525. /**
  24526. * Returns the string "AbstractMesh"
  24527. * @returns "AbstractMesh"
  24528. */
  24529. getClassName(): string;
  24530. /**
  24531. * Gets a string representation of the current mesh
  24532. * @param fullDetails defines a boolean indicating if full details must be included
  24533. * @returns a string representation of the current mesh
  24534. */
  24535. toString(fullDetails?: boolean): string;
  24536. /**
  24537. * @hidden
  24538. */
  24539. protected _getEffectiveParent(): Nullable<Node>;
  24540. /** @hidden */
  24541. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24542. /** @hidden */
  24543. _rebuild(): void;
  24544. /** @hidden */
  24545. _resyncLightSources(): void;
  24546. /** @hidden */
  24547. _resyncLighSource(light: Light): void;
  24548. /** @hidden */
  24549. _unBindEffect(): void;
  24550. /** @hidden */
  24551. _removeLightSource(light: Light): void;
  24552. private _markSubMeshesAsDirty;
  24553. /** @hidden */
  24554. _markSubMeshesAsLightDirty(): void;
  24555. /** @hidden */
  24556. _markSubMeshesAsAttributesDirty(): void;
  24557. /** @hidden */
  24558. _markSubMeshesAsMiscDirty(): void;
  24559. /**
  24560. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24561. */
  24562. scaling: Vector3;
  24563. /**
  24564. * Returns true if the mesh is blocked. Implemented by child classes
  24565. */
  24566. readonly isBlocked: boolean;
  24567. /**
  24568. * Returns the mesh itself by default. Implemented by child classes
  24569. * @param camera defines the camera to use to pick the right LOD level
  24570. * @returns the currentAbstractMesh
  24571. */
  24572. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24573. /**
  24574. * Returns 0 by default. Implemented by child classes
  24575. * @returns an integer
  24576. */
  24577. getTotalVertices(): number;
  24578. /**
  24579. * Returns a positive integer : the total number of indices in this mesh geometry.
  24580. * @returns the numner of indices or zero if the mesh has no geometry.
  24581. */
  24582. getTotalIndices(): number;
  24583. /**
  24584. * Returns null by default. Implemented by child classes
  24585. * @returns null
  24586. */
  24587. getIndices(): Nullable<IndicesArray>;
  24588. /**
  24589. * Returns the array of the requested vertex data kind. Implemented by child classes
  24590. * @param kind defines the vertex data kind to use
  24591. * @returns null
  24592. */
  24593. getVerticesData(kind: string): Nullable<FloatArray>;
  24594. /**
  24595. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24596. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24597. * Note that a new underlying VertexBuffer object is created each call.
  24598. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24599. * @param kind defines vertex data kind:
  24600. * * VertexBuffer.PositionKind
  24601. * * VertexBuffer.UVKind
  24602. * * VertexBuffer.UV2Kind
  24603. * * VertexBuffer.UV3Kind
  24604. * * VertexBuffer.UV4Kind
  24605. * * VertexBuffer.UV5Kind
  24606. * * VertexBuffer.UV6Kind
  24607. * * VertexBuffer.ColorKind
  24608. * * VertexBuffer.MatricesIndicesKind
  24609. * * VertexBuffer.MatricesIndicesExtraKind
  24610. * * VertexBuffer.MatricesWeightsKind
  24611. * * VertexBuffer.MatricesWeightsExtraKind
  24612. * @param data defines the data source
  24613. * @param updatable defines if the data must be flagged as updatable (or static)
  24614. * @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
  24615. * @returns the current mesh
  24616. */
  24617. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24618. /**
  24619. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24620. * If the mesh has no geometry, it is simply returned as it is.
  24621. * @param kind defines vertex data kind:
  24622. * * VertexBuffer.PositionKind
  24623. * * VertexBuffer.UVKind
  24624. * * VertexBuffer.UV2Kind
  24625. * * VertexBuffer.UV3Kind
  24626. * * VertexBuffer.UV4Kind
  24627. * * VertexBuffer.UV5Kind
  24628. * * VertexBuffer.UV6Kind
  24629. * * VertexBuffer.ColorKind
  24630. * * VertexBuffer.MatricesIndicesKind
  24631. * * VertexBuffer.MatricesIndicesExtraKind
  24632. * * VertexBuffer.MatricesWeightsKind
  24633. * * VertexBuffer.MatricesWeightsExtraKind
  24634. * @param data defines the data source
  24635. * @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
  24636. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24637. * @returns the current mesh
  24638. */
  24639. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24640. /**
  24641. * Sets the mesh indices,
  24642. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24643. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24644. * @param totalVertices Defines the total number of vertices
  24645. * @returns the current mesh
  24646. */
  24647. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24648. /**
  24649. * Gets a boolean indicating if specific vertex data is present
  24650. * @param kind defines the vertex data kind to use
  24651. * @returns true is data kind is present
  24652. */
  24653. isVerticesDataPresent(kind: string): boolean;
  24654. /**
  24655. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24656. * @returns a BoundingInfo
  24657. */
  24658. getBoundingInfo(): BoundingInfo;
  24659. /**
  24660. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24661. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24662. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24663. * @returns the current mesh
  24664. */
  24665. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24666. /**
  24667. * Overwrite the current bounding info
  24668. * @param boundingInfo defines the new bounding info
  24669. * @returns the current mesh
  24670. */
  24671. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24672. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24673. readonly useBones: boolean;
  24674. /** @hidden */
  24675. _preActivate(): void;
  24676. /** @hidden */
  24677. _preActivateForIntermediateRendering(renderId: number): void;
  24678. /** @hidden */
  24679. _activate(renderId: number): boolean;
  24680. /** @hidden */
  24681. _postActivate(): void;
  24682. /** @hidden */
  24683. _freeze(): void;
  24684. /** @hidden */
  24685. _unFreeze(): void;
  24686. /**
  24687. * Gets the current world matrix
  24688. * @returns a Matrix
  24689. */
  24690. getWorldMatrix(): Matrix;
  24691. /** @hidden */
  24692. _getWorldMatrixDeterminant(): number;
  24693. /**
  24694. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24695. */
  24696. readonly isAnInstance: boolean;
  24697. /**
  24698. * Perform relative position change from the point of view of behind the front of the mesh.
  24699. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24700. * Supports definition of mesh facing forward or backward
  24701. * @param amountRight defines the distance on the right axis
  24702. * @param amountUp defines the distance on the up axis
  24703. * @param amountForward defines the distance on the forward axis
  24704. * @returns the current mesh
  24705. */
  24706. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24707. /**
  24708. * Calculate relative position change from the point of view of behind the front of the mesh.
  24709. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24710. * Supports definition of mesh facing forward or backward
  24711. * @param amountRight defines the distance on the right axis
  24712. * @param amountUp defines the distance on the up axis
  24713. * @param amountForward defines the distance on the forward axis
  24714. * @returns the new displacement vector
  24715. */
  24716. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24717. /**
  24718. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24719. * Supports definition of mesh facing forward or backward
  24720. * @param flipBack defines the flip
  24721. * @param twirlClockwise defines the twirl
  24722. * @param tiltRight defines the tilt
  24723. * @returns the current mesh
  24724. */
  24725. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24726. /**
  24727. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24728. * Supports definition of mesh facing forward or backward.
  24729. * @param flipBack defines the flip
  24730. * @param twirlClockwise defines the twirl
  24731. * @param tiltRight defines the tilt
  24732. * @returns the new rotation vector
  24733. */
  24734. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24735. /**
  24736. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24737. * This means the mesh underlying bounding box and sphere are recomputed.
  24738. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24739. * @returns the current mesh
  24740. */
  24741. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24742. /** @hidden */
  24743. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24744. /** @hidden */
  24745. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24746. /** @hidden */
  24747. _updateBoundingInfo(): AbstractMesh;
  24748. /** @hidden */
  24749. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24750. /** @hidden */
  24751. protected _afterComputeWorldMatrix(): void;
  24752. /** @hidden */
  24753. readonly _effectiveMesh: AbstractMesh;
  24754. /**
  24755. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24756. * A mesh is in the frustum if its bounding box intersects the frustum
  24757. * @param frustumPlanes defines the frustum to test
  24758. * @returns true if the mesh is in the frustum planes
  24759. */
  24760. isInFrustum(frustumPlanes: Plane[]): boolean;
  24761. /**
  24762. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24763. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24764. * @param frustumPlanes defines the frustum to test
  24765. * @returns true if the mesh is completely in the frustum planes
  24766. */
  24767. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24768. /**
  24769. * True if the mesh intersects another mesh or a SolidParticle object
  24770. * @param mesh defines a target mesh or SolidParticle to test
  24771. * @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)
  24772. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24773. * @returns true if there is an intersection
  24774. */
  24775. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24776. /**
  24777. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24778. * @param point defines the point to test
  24779. * @returns true if there is an intersection
  24780. */
  24781. intersectsPoint(point: Vector3): boolean;
  24782. /**
  24783. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24784. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24785. */
  24786. checkCollisions: boolean;
  24787. /**
  24788. * Gets Collider object used to compute collisions (not physics)
  24789. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24790. */
  24791. readonly collider: Nullable<Collider>;
  24792. /**
  24793. * Move the mesh using collision engine
  24794. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24795. * @param displacement defines the requested displacement vector
  24796. * @returns the current mesh
  24797. */
  24798. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24799. private _onCollisionPositionChange;
  24800. /** @hidden */
  24801. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24802. /** @hidden */
  24803. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24804. /** @hidden */
  24805. _checkCollision(collider: Collider): AbstractMesh;
  24806. /** @hidden */
  24807. _generatePointsArray(): boolean;
  24808. /**
  24809. * Checks if the passed Ray intersects with the mesh
  24810. * @param ray defines the ray to use
  24811. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24812. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24813. * @returns the picking info
  24814. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24815. */
  24816. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24817. /**
  24818. * Clones the current mesh
  24819. * @param name defines the mesh name
  24820. * @param newParent defines the new mesh parent
  24821. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24822. * @returns the new mesh
  24823. */
  24824. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24825. /**
  24826. * Disposes all the submeshes of the current meshnp
  24827. * @returns the current mesh
  24828. */
  24829. releaseSubMeshes(): AbstractMesh;
  24830. /**
  24831. * Releases resources associated with this abstract mesh.
  24832. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24833. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24834. */
  24835. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24836. /**
  24837. * Adds the passed mesh as a child to the current mesh
  24838. * @param mesh defines the child mesh
  24839. * @returns the current mesh
  24840. */
  24841. addChild(mesh: AbstractMesh): AbstractMesh;
  24842. /**
  24843. * Removes the passed mesh from the current mesh children list
  24844. * @param mesh defines the child mesh
  24845. * @returns the current mesh
  24846. */
  24847. removeChild(mesh: AbstractMesh): AbstractMesh;
  24848. /** @hidden */
  24849. private _initFacetData;
  24850. /**
  24851. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24852. * This method can be called within the render loop.
  24853. * 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
  24854. * @returns the current mesh
  24855. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24856. */
  24857. updateFacetData(): AbstractMesh;
  24858. /**
  24859. * Returns the facetLocalNormals array.
  24860. * The normals are expressed in the mesh local spac
  24861. * @returns an array of Vector3
  24862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24863. */
  24864. getFacetLocalNormals(): Vector3[];
  24865. /**
  24866. * Returns the facetLocalPositions array.
  24867. * The facet positions are expressed in the mesh local space
  24868. * @returns an array of Vector3
  24869. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24870. */
  24871. getFacetLocalPositions(): Vector3[];
  24872. /**
  24873. * Returns the facetLocalPartioning array
  24874. * @returns an array of array of numbers
  24875. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24876. */
  24877. getFacetLocalPartitioning(): number[][];
  24878. /**
  24879. * Returns the i-th facet position in the world system.
  24880. * This method allocates a new Vector3 per call
  24881. * @param i defines the facet index
  24882. * @returns a new Vector3
  24883. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24884. */
  24885. getFacetPosition(i: number): Vector3;
  24886. /**
  24887. * Sets the reference Vector3 with the i-th facet position in the world system
  24888. * @param i defines the facet index
  24889. * @param ref defines the target vector
  24890. * @returns the current mesh
  24891. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24892. */
  24893. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24894. /**
  24895. * Returns the i-th facet normal in the world system.
  24896. * This method allocates a new Vector3 per call
  24897. * @param i defines the facet index
  24898. * @returns a new Vector3
  24899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24900. */
  24901. getFacetNormal(i: number): Vector3;
  24902. /**
  24903. * Sets the reference Vector3 with the i-th facet normal in the world system
  24904. * @param i defines the facet index
  24905. * @param ref defines the target vector
  24906. * @returns the current mesh
  24907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24908. */
  24909. getFacetNormalToRef(i: number, ref: Vector3): this;
  24910. /**
  24911. * 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)
  24912. * @param x defines x coordinate
  24913. * @param y defines y coordinate
  24914. * @param z defines z coordinate
  24915. * @returns the array of facet indexes
  24916. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24917. */
  24918. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24919. /**
  24920. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24921. * @param projected sets as the (x,y,z) world projection on the facet
  24922. * @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
  24923. * @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
  24924. * @param x defines x coordinate
  24925. * @param y defines y coordinate
  24926. * @param z defines z coordinate
  24927. * @returns the face index if found (or null instead)
  24928. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24929. */
  24930. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24931. /**
  24932. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24933. * @param projected sets as the (x,y,z) local projection on the facet
  24934. * @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
  24935. * @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
  24936. * @param x defines x coordinate
  24937. * @param y defines y coordinate
  24938. * @param z defines z coordinate
  24939. * @returns the face index if found (or null instead)
  24940. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24941. */
  24942. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24943. /**
  24944. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24945. * @returns the parameters
  24946. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24947. */
  24948. getFacetDataParameters(): any;
  24949. /**
  24950. * Disables the feature FacetData and frees the related memory
  24951. * @returns the current mesh
  24952. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24953. */
  24954. disableFacetData(): AbstractMesh;
  24955. /**
  24956. * Updates the AbstractMesh indices array
  24957. * @param indices defines the data source
  24958. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24959. * @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)
  24960. * @returns the current mesh
  24961. */
  24962. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24963. /**
  24964. * Creates new normals data for the mesh
  24965. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24966. * @returns the current mesh
  24967. */
  24968. createNormals(updatable: boolean): AbstractMesh;
  24969. /**
  24970. * Align the mesh with a normal
  24971. * @param normal defines the normal to use
  24972. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24973. * @returns the current mesh
  24974. */
  24975. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24976. /** @hidden */
  24977. _checkOcclusionQuery(): boolean;
  24978. /**
  24979. * Disables the mesh edge rendering mode
  24980. * @returns the currentAbstractMesh
  24981. */
  24982. disableEdgesRendering(): AbstractMesh;
  24983. /**
  24984. * Enables the edge rendering mode on the mesh.
  24985. * This mode makes the mesh edges visible
  24986. * @param epsilon defines the maximal distance between two angles to detect a face
  24987. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  24988. * @returns the currentAbstractMesh
  24989. * @see https://www.babylonjs-playground.com/#19O9TU#0
  24990. */
  24991. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  24992. }
  24993. }
  24994. declare module BABYLON {
  24995. /**
  24996. * Interface used to define ActionEvent
  24997. */
  24998. export interface IActionEvent {
  24999. /** The mesh or sprite that triggered the action */
  25000. source: any;
  25001. /** The X mouse cursor position at the time of the event */
  25002. pointerX: number;
  25003. /** The Y mouse cursor position at the time of the event */
  25004. pointerY: number;
  25005. /** The mesh that is currently pointed at (can be null) */
  25006. meshUnderPointer: Nullable<AbstractMesh>;
  25007. /** the original (browser) event that triggered the ActionEvent */
  25008. sourceEvent?: any;
  25009. /** additional data for the event */
  25010. additionalData?: any;
  25011. }
  25012. /**
  25013. * ActionEvent is the event being sent when an action is triggered.
  25014. */
  25015. export class ActionEvent implements IActionEvent {
  25016. /** The mesh or sprite that triggered the action */
  25017. source: any;
  25018. /** The X mouse cursor position at the time of the event */
  25019. pointerX: number;
  25020. /** The Y mouse cursor position at the time of the event */
  25021. pointerY: number;
  25022. /** The mesh that is currently pointed at (can be null) */
  25023. meshUnderPointer: Nullable<AbstractMesh>;
  25024. /** the original (browser) event that triggered the ActionEvent */
  25025. sourceEvent?: any;
  25026. /** additional data for the event */
  25027. additionalData?: any;
  25028. /**
  25029. * Creates a new ActionEvent
  25030. * @param source The mesh or sprite that triggered the action
  25031. * @param pointerX The X mouse cursor position at the time of the event
  25032. * @param pointerY The Y mouse cursor position at the time of the event
  25033. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25034. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25035. * @param additionalData additional data for the event
  25036. */
  25037. constructor(
  25038. /** The mesh or sprite that triggered the action */
  25039. source: any,
  25040. /** The X mouse cursor position at the time of the event */
  25041. pointerX: number,
  25042. /** The Y mouse cursor position at the time of the event */
  25043. pointerY: number,
  25044. /** The mesh that is currently pointed at (can be null) */
  25045. meshUnderPointer: Nullable<AbstractMesh>,
  25046. /** the original (browser) event that triggered the ActionEvent */
  25047. sourceEvent?: any,
  25048. /** additional data for the event */
  25049. additionalData?: any);
  25050. /**
  25051. * Helper function to auto-create an ActionEvent from a source mesh.
  25052. * @param source The source mesh that triggered the event
  25053. * @param evt The original (browser) event
  25054. * @param additionalData additional data for the event
  25055. * @returns the new ActionEvent
  25056. */
  25057. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25058. /**
  25059. * Helper function to auto-create an ActionEvent from a source sprite
  25060. * @param source The source sprite that triggered the event
  25061. * @param scene Scene associated with the sprite
  25062. * @param evt The original (browser) event
  25063. * @param additionalData additional data for the event
  25064. * @returns the new ActionEvent
  25065. */
  25066. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25067. /**
  25068. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25069. * @param scene the scene where the event occurred
  25070. * @param evt The original (browser) event
  25071. * @returns the new ActionEvent
  25072. */
  25073. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25074. /**
  25075. * Helper function to auto-create an ActionEvent from a primitive
  25076. * @param prim defines the target primitive
  25077. * @param pointerPos defines the pointer position
  25078. * @param evt The original (browser) event
  25079. * @param additionalData additional data for the event
  25080. * @returns the new ActionEvent
  25081. */
  25082. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25083. }
  25084. }
  25085. declare module BABYLON {
  25086. /**
  25087. * Abstract class used to decouple action Manager from scene and meshes.
  25088. * Do not instantiate.
  25089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25090. */
  25091. export abstract class AbstractActionManager implements IDisposable {
  25092. /** Gets the list of active triggers */
  25093. static Triggers: {
  25094. [key: string]: number;
  25095. };
  25096. /** Gets the cursor to use when hovering items */
  25097. hoverCursor: string;
  25098. /** Gets the list of actions */
  25099. actions: IAction[];
  25100. /**
  25101. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25102. */
  25103. isRecursive: boolean;
  25104. /**
  25105. * Releases all associated resources
  25106. */
  25107. abstract dispose(): void;
  25108. /**
  25109. * Does this action manager has pointer triggers
  25110. */
  25111. abstract readonly hasPointerTriggers: boolean;
  25112. /**
  25113. * Does this action manager has pick triggers
  25114. */
  25115. abstract readonly hasPickTriggers: boolean;
  25116. /**
  25117. * Process a specific trigger
  25118. * @param trigger defines the trigger to process
  25119. * @param evt defines the event details to be processed
  25120. */
  25121. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25122. /**
  25123. * Does this action manager handles actions of any of the given triggers
  25124. * @param triggers defines the triggers to be tested
  25125. * @return a boolean indicating whether one (or more) of the triggers is handled
  25126. */
  25127. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25128. /**
  25129. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25130. * speed.
  25131. * @param triggerA defines the trigger to be tested
  25132. * @param triggerB defines the trigger to be tested
  25133. * @return a boolean indicating whether one (or more) of the triggers is handled
  25134. */
  25135. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25136. /**
  25137. * Does this action manager handles actions of a given trigger
  25138. * @param trigger defines the trigger to be tested
  25139. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25140. * @return whether the trigger is handled
  25141. */
  25142. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25143. /**
  25144. * Serialize this manager to a JSON object
  25145. * @param name defines the property name to store this manager
  25146. * @returns a JSON representation of this manager
  25147. */
  25148. abstract serialize(name: string): any;
  25149. /**
  25150. * Registers an action to this action manager
  25151. * @param action defines the action to be registered
  25152. * @return the action amended (prepared) after registration
  25153. */
  25154. abstract registerAction(action: IAction): Nullable<IAction>;
  25155. /**
  25156. * Unregisters an action to this action manager
  25157. * @param action defines the action to be unregistered
  25158. * @return a boolean indicating whether the action has been unregistered
  25159. */
  25160. abstract unregisterAction(action: IAction): Boolean;
  25161. /**
  25162. * Does exist one action manager with at least one trigger
  25163. **/
  25164. static readonly HasTriggers: boolean;
  25165. /**
  25166. * Does exist one action manager with at least one pick trigger
  25167. **/
  25168. static readonly HasPickTriggers: boolean;
  25169. /**
  25170. * Does exist one action manager that handles actions of a given trigger
  25171. * @param trigger defines the trigger to be tested
  25172. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25173. **/
  25174. static HasSpecificTrigger(trigger: number): boolean;
  25175. }
  25176. }
  25177. declare module BABYLON {
  25178. /**
  25179. * Defines how a node can be built from a string name.
  25180. */
  25181. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25182. /**
  25183. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25184. */
  25185. export class Node implements IBehaviorAware<Node> {
  25186. /** @hidden */
  25187. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25188. private static _NodeConstructors;
  25189. /**
  25190. * Add a new node constructor
  25191. * @param type defines the type name of the node to construct
  25192. * @param constructorFunc defines the constructor function
  25193. */
  25194. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25195. /**
  25196. * Returns a node constructor based on type name
  25197. * @param type defines the type name
  25198. * @param name defines the new node name
  25199. * @param scene defines the hosting scene
  25200. * @param options defines optional options to transmit to constructors
  25201. * @returns the new constructor or null
  25202. */
  25203. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25204. /**
  25205. * Gets or sets the name of the node
  25206. */
  25207. name: string;
  25208. /**
  25209. * Gets or sets the id of the node
  25210. */
  25211. id: string;
  25212. /**
  25213. * Gets or sets the unique id of the node
  25214. */
  25215. uniqueId: number;
  25216. /**
  25217. * Gets or sets a string used to store user defined state for the node
  25218. */
  25219. state: string;
  25220. /**
  25221. * Gets or sets an object used to store user defined information for the node
  25222. */
  25223. metadata: any;
  25224. /**
  25225. * For internal use only. Please do not use.
  25226. */
  25227. reservedDataStore: any;
  25228. /**
  25229. * List of inspectable custom properties (used by the Inspector)
  25230. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25231. */
  25232. inspectableCustomProperties: IInspectable[];
  25233. /**
  25234. * Gets or sets a boolean used to define if the node must be serialized
  25235. */
  25236. doNotSerialize: boolean;
  25237. /** @hidden */
  25238. _isDisposed: boolean;
  25239. /**
  25240. * Gets a list of Animations associated with the node
  25241. */
  25242. animations: Animation[];
  25243. protected _ranges: {
  25244. [name: string]: Nullable<AnimationRange>;
  25245. };
  25246. /**
  25247. * Callback raised when the node is ready to be used
  25248. */
  25249. onReady: Nullable<(node: Node) => void>;
  25250. private _isEnabled;
  25251. private _isParentEnabled;
  25252. private _isReady;
  25253. /** @hidden */
  25254. _currentRenderId: number;
  25255. private _parentUpdateId;
  25256. /** @hidden */
  25257. _childUpdateId: number;
  25258. /** @hidden */
  25259. _waitingParentId: Nullable<string>;
  25260. /** @hidden */
  25261. _scene: Scene;
  25262. /** @hidden */
  25263. _cache: any;
  25264. private _parentNode;
  25265. private _children;
  25266. /** @hidden */
  25267. _worldMatrix: Matrix;
  25268. /** @hidden */
  25269. _worldMatrixDeterminant: number;
  25270. /** @hidden */
  25271. _worldMatrixDeterminantIsDirty: boolean;
  25272. /** @hidden */
  25273. private _sceneRootNodesIndex;
  25274. /**
  25275. * Gets a boolean indicating if the node has been disposed
  25276. * @returns true if the node was disposed
  25277. */
  25278. isDisposed(): boolean;
  25279. /**
  25280. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25281. * @see https://doc.babylonjs.com/how_to/parenting
  25282. */
  25283. parent: Nullable<Node>;
  25284. private addToSceneRootNodes;
  25285. private removeFromSceneRootNodes;
  25286. private _animationPropertiesOverride;
  25287. /**
  25288. * Gets or sets the animation properties override
  25289. */
  25290. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25291. /**
  25292. * Gets a string idenfifying the name of the class
  25293. * @returns "Node" string
  25294. */
  25295. getClassName(): string;
  25296. /** @hidden */
  25297. readonly _isNode: boolean;
  25298. /**
  25299. * An event triggered when the mesh is disposed
  25300. */
  25301. onDisposeObservable: Observable<Node>;
  25302. private _onDisposeObserver;
  25303. /**
  25304. * Sets a callback that will be raised when the node will be disposed
  25305. */
  25306. onDispose: () => void;
  25307. /**
  25308. * Creates a new Node
  25309. * @param name the name and id to be given to this node
  25310. * @param scene the scene this node will be added to
  25311. * @param addToRootNodes the node will be added to scene.rootNodes
  25312. */
  25313. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25314. /**
  25315. * Gets the scene of the node
  25316. * @returns a scene
  25317. */
  25318. getScene(): Scene;
  25319. /**
  25320. * Gets the engine of the node
  25321. * @returns a Engine
  25322. */
  25323. getEngine(): Engine;
  25324. private _behaviors;
  25325. /**
  25326. * Attach a behavior to the node
  25327. * @see http://doc.babylonjs.com/features/behaviour
  25328. * @param behavior defines the behavior to attach
  25329. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25330. * @returns the current Node
  25331. */
  25332. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25333. /**
  25334. * Remove an attached behavior
  25335. * @see http://doc.babylonjs.com/features/behaviour
  25336. * @param behavior defines the behavior to attach
  25337. * @returns the current Node
  25338. */
  25339. removeBehavior(behavior: Behavior<Node>): Node;
  25340. /**
  25341. * Gets the list of attached behaviors
  25342. * @see http://doc.babylonjs.com/features/behaviour
  25343. */
  25344. readonly behaviors: Behavior<Node>[];
  25345. /**
  25346. * Gets an attached behavior by name
  25347. * @param name defines the name of the behavior to look for
  25348. * @see http://doc.babylonjs.com/features/behaviour
  25349. * @returns null if behavior was not found else the requested behavior
  25350. */
  25351. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25352. /**
  25353. * Returns the latest update of the World matrix
  25354. * @returns a Matrix
  25355. */
  25356. getWorldMatrix(): Matrix;
  25357. /** @hidden */
  25358. _getWorldMatrixDeterminant(): number;
  25359. /**
  25360. * Returns directly the latest state of the mesh World matrix.
  25361. * A Matrix is returned.
  25362. */
  25363. readonly worldMatrixFromCache: Matrix;
  25364. /** @hidden */
  25365. _initCache(): void;
  25366. /** @hidden */
  25367. updateCache(force?: boolean): void;
  25368. /** @hidden */
  25369. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25370. /** @hidden */
  25371. _updateCache(ignoreParentClass?: boolean): void;
  25372. /** @hidden */
  25373. _isSynchronized(): boolean;
  25374. /** @hidden */
  25375. _markSyncedWithParent(): void;
  25376. /** @hidden */
  25377. isSynchronizedWithParent(): boolean;
  25378. /** @hidden */
  25379. isSynchronized(): boolean;
  25380. /**
  25381. * Is this node ready to be used/rendered
  25382. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25383. * @return true if the node is ready
  25384. */
  25385. isReady(completeCheck?: boolean): boolean;
  25386. /**
  25387. * Is this node enabled?
  25388. * 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
  25389. * @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
  25390. * @return whether this node (and its parent) is enabled
  25391. */
  25392. isEnabled(checkAncestors?: boolean): boolean;
  25393. /** @hidden */
  25394. protected _syncParentEnabledState(): void;
  25395. /**
  25396. * Set the enabled state of this node
  25397. * @param value defines the new enabled state
  25398. */
  25399. setEnabled(value: boolean): void;
  25400. /**
  25401. * Is this node a descendant of the given node?
  25402. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25403. * @param ancestor defines the parent node to inspect
  25404. * @returns a boolean indicating if this node is a descendant of the given node
  25405. */
  25406. isDescendantOf(ancestor: Node): boolean;
  25407. /** @hidden */
  25408. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25409. /**
  25410. * Will return all nodes that have this node as ascendant
  25411. * @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
  25412. * @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
  25413. * @return all children nodes of all types
  25414. */
  25415. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25416. /**
  25417. * Get all child-meshes of this node
  25418. * @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)
  25419. * @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
  25420. * @returns an array of AbstractMesh
  25421. */
  25422. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25423. /**
  25424. * Get all direct children of this node
  25425. * @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
  25426. * @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)
  25427. * @returns an array of Node
  25428. */
  25429. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25430. /** @hidden */
  25431. _setReady(state: boolean): void;
  25432. /**
  25433. * Get an animation by name
  25434. * @param name defines the name of the animation to look for
  25435. * @returns null if not found else the requested animation
  25436. */
  25437. getAnimationByName(name: string): Nullable<Animation>;
  25438. /**
  25439. * Creates an animation range for this node
  25440. * @param name defines the name of the range
  25441. * @param from defines the starting key
  25442. * @param to defines the end key
  25443. */
  25444. createAnimationRange(name: string, from: number, to: number): void;
  25445. /**
  25446. * Delete a specific animation range
  25447. * @param name defines the name of the range to delete
  25448. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25449. */
  25450. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25451. /**
  25452. * Get an animation range by name
  25453. * @param name defines the name of the animation range to look for
  25454. * @returns null if not found else the requested animation range
  25455. */
  25456. getAnimationRange(name: string): Nullable<AnimationRange>;
  25457. /**
  25458. * Gets the list of all animation ranges defined on this node
  25459. * @returns an array
  25460. */
  25461. getAnimationRanges(): Nullable<AnimationRange>[];
  25462. /**
  25463. * Will start the animation sequence
  25464. * @param name defines the range frames for animation sequence
  25465. * @param loop defines if the animation should loop (false by default)
  25466. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25467. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25468. * @returns the object created for this animation. If range does not exist, it will return null
  25469. */
  25470. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25471. /**
  25472. * Serialize animation ranges into a JSON compatible object
  25473. * @returns serialization object
  25474. */
  25475. serializeAnimationRanges(): any;
  25476. /**
  25477. * Computes the world matrix of the node
  25478. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25479. * @returns the world matrix
  25480. */
  25481. computeWorldMatrix(force?: boolean): Matrix;
  25482. /**
  25483. * Releases resources associated with this node.
  25484. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25485. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25486. */
  25487. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25488. /**
  25489. * Parse animation range data from a serialization object and store them into a given node
  25490. * @param node defines where to store the animation ranges
  25491. * @param parsedNode defines the serialization object to read data from
  25492. * @param scene defines the hosting scene
  25493. */
  25494. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25495. /**
  25496. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25497. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25498. * @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
  25499. * @returns the new bounding vectors
  25500. */
  25501. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25502. min: Vector3;
  25503. max: Vector3;
  25504. };
  25505. }
  25506. }
  25507. declare module BABYLON {
  25508. /**
  25509. * @hidden
  25510. */
  25511. export class _IAnimationState {
  25512. key: number;
  25513. repeatCount: number;
  25514. workValue?: any;
  25515. loopMode?: number;
  25516. offsetValue?: any;
  25517. highLimitValue?: any;
  25518. }
  25519. /**
  25520. * Class used to store any kind of animation
  25521. */
  25522. export class Animation {
  25523. /**Name of the animation */
  25524. name: string;
  25525. /**Property to animate */
  25526. targetProperty: string;
  25527. /**The frames per second of the animation */
  25528. framePerSecond: number;
  25529. /**The data type of the animation */
  25530. dataType: number;
  25531. /**The loop mode of the animation */
  25532. loopMode?: number | undefined;
  25533. /**Specifies if blending should be enabled */
  25534. enableBlending?: boolean | undefined;
  25535. /**
  25536. * Use matrix interpolation instead of using direct key value when animating matrices
  25537. */
  25538. static AllowMatricesInterpolation: boolean;
  25539. /**
  25540. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25541. */
  25542. static AllowMatrixDecomposeForInterpolation: boolean;
  25543. /**
  25544. * Stores the key frames of the animation
  25545. */
  25546. private _keys;
  25547. /**
  25548. * Stores the easing function of the animation
  25549. */
  25550. private _easingFunction;
  25551. /**
  25552. * @hidden Internal use only
  25553. */
  25554. _runtimeAnimations: RuntimeAnimation[];
  25555. /**
  25556. * The set of event that will be linked to this animation
  25557. */
  25558. private _events;
  25559. /**
  25560. * Stores an array of target property paths
  25561. */
  25562. targetPropertyPath: string[];
  25563. /**
  25564. * Stores the blending speed of the animation
  25565. */
  25566. blendingSpeed: number;
  25567. /**
  25568. * Stores the animation ranges for the animation
  25569. */
  25570. private _ranges;
  25571. /**
  25572. * @hidden Internal use
  25573. */
  25574. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25575. /**
  25576. * Sets up an animation
  25577. * @param property The property to animate
  25578. * @param animationType The animation type to apply
  25579. * @param framePerSecond The frames per second of the animation
  25580. * @param easingFunction The easing function used in the animation
  25581. * @returns The created animation
  25582. */
  25583. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25584. /**
  25585. * Create and start an animation on a node
  25586. * @param name defines the name of the global animation that will be run on all nodes
  25587. * @param node defines the root node where the animation will take place
  25588. * @param targetProperty defines property to animate
  25589. * @param framePerSecond defines the number of frame per second yo use
  25590. * @param totalFrame defines the number of frames in total
  25591. * @param from defines the initial value
  25592. * @param to defines the final value
  25593. * @param loopMode defines which loop mode you want to use (off by default)
  25594. * @param easingFunction defines the easing function to use (linear by default)
  25595. * @param onAnimationEnd defines the callback to call when animation end
  25596. * @returns the animatable created for this animation
  25597. */
  25598. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25599. /**
  25600. * Create and start an animation on a node and its descendants
  25601. * @param name defines the name of the global animation that will be run on all nodes
  25602. * @param node defines the root node where the animation will take place
  25603. * @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
  25604. * @param targetProperty defines property to animate
  25605. * @param framePerSecond defines the number of frame per second to use
  25606. * @param totalFrame defines the number of frames in total
  25607. * @param from defines the initial value
  25608. * @param to defines the final value
  25609. * @param loopMode defines which loop mode you want to use (off by default)
  25610. * @param easingFunction defines the easing function to use (linear by default)
  25611. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25612. * @returns the list of animatables created for all nodes
  25613. * @example https://www.babylonjs-playground.com/#MH0VLI
  25614. */
  25615. 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[]>;
  25616. /**
  25617. * Creates a new animation, merges it with the existing animations and starts it
  25618. * @param name Name of the animation
  25619. * @param node Node which contains the scene that begins the animations
  25620. * @param targetProperty Specifies which property to animate
  25621. * @param framePerSecond The frames per second of the animation
  25622. * @param totalFrame The total number of frames
  25623. * @param from The frame at the beginning of the animation
  25624. * @param to The frame at the end of the animation
  25625. * @param loopMode Specifies the loop mode of the animation
  25626. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25627. * @param onAnimationEnd Callback to run once the animation is complete
  25628. * @returns Nullable animation
  25629. */
  25630. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25631. /**
  25632. * Transition property of an host to the target Value
  25633. * @param property The property to transition
  25634. * @param targetValue The target Value of the property
  25635. * @param host The object where the property to animate belongs
  25636. * @param scene Scene used to run the animation
  25637. * @param frameRate Framerate (in frame/s) to use
  25638. * @param transition The transition type we want to use
  25639. * @param duration The duration of the animation, in milliseconds
  25640. * @param onAnimationEnd Callback trigger at the end of the animation
  25641. * @returns Nullable animation
  25642. */
  25643. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25644. /**
  25645. * Return the array of runtime animations currently using this animation
  25646. */
  25647. readonly runtimeAnimations: RuntimeAnimation[];
  25648. /**
  25649. * Specifies if any of the runtime animations are currently running
  25650. */
  25651. readonly hasRunningRuntimeAnimations: boolean;
  25652. /**
  25653. * Initializes the animation
  25654. * @param name Name of the animation
  25655. * @param targetProperty Property to animate
  25656. * @param framePerSecond The frames per second of the animation
  25657. * @param dataType The data type of the animation
  25658. * @param loopMode The loop mode of the animation
  25659. * @param enableBlending Specifies if blending should be enabled
  25660. */
  25661. constructor(
  25662. /**Name of the animation */
  25663. name: string,
  25664. /**Property to animate */
  25665. targetProperty: string,
  25666. /**The frames per second of the animation */
  25667. framePerSecond: number,
  25668. /**The data type of the animation */
  25669. dataType: number,
  25670. /**The loop mode of the animation */
  25671. loopMode?: number | undefined,
  25672. /**Specifies if blending should be enabled */
  25673. enableBlending?: boolean | undefined);
  25674. /**
  25675. * Converts the animation to a string
  25676. * @param fullDetails support for multiple levels of logging within scene loading
  25677. * @returns String form of the animation
  25678. */
  25679. toString(fullDetails?: boolean): string;
  25680. /**
  25681. * Add an event to this animation
  25682. * @param event Event to add
  25683. */
  25684. addEvent(event: AnimationEvent): void;
  25685. /**
  25686. * Remove all events found at the given frame
  25687. * @param frame The frame to remove events from
  25688. */
  25689. removeEvents(frame: number): void;
  25690. /**
  25691. * Retrieves all the events from the animation
  25692. * @returns Events from the animation
  25693. */
  25694. getEvents(): AnimationEvent[];
  25695. /**
  25696. * Creates an animation range
  25697. * @param name Name of the animation range
  25698. * @param from Starting frame of the animation range
  25699. * @param to Ending frame of the animation
  25700. */
  25701. createRange(name: string, from: number, to: number): void;
  25702. /**
  25703. * Deletes an animation range by name
  25704. * @param name Name of the animation range to delete
  25705. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25706. */
  25707. deleteRange(name: string, deleteFrames?: boolean): void;
  25708. /**
  25709. * Gets the animation range by name, or null if not defined
  25710. * @param name Name of the animation range
  25711. * @returns Nullable animation range
  25712. */
  25713. getRange(name: string): Nullable<AnimationRange>;
  25714. /**
  25715. * Gets the key frames from the animation
  25716. * @returns The key frames of the animation
  25717. */
  25718. getKeys(): Array<IAnimationKey>;
  25719. /**
  25720. * Gets the highest frame rate of the animation
  25721. * @returns Highest frame rate of the animation
  25722. */
  25723. getHighestFrame(): number;
  25724. /**
  25725. * Gets the easing function of the animation
  25726. * @returns Easing function of the animation
  25727. */
  25728. getEasingFunction(): IEasingFunction;
  25729. /**
  25730. * Sets the easing function of the animation
  25731. * @param easingFunction A custom mathematical formula for animation
  25732. */
  25733. setEasingFunction(easingFunction: EasingFunction): void;
  25734. /**
  25735. * Interpolates a scalar linearly
  25736. * @param startValue Start value of the animation curve
  25737. * @param endValue End value of the animation curve
  25738. * @param gradient Scalar amount to interpolate
  25739. * @returns Interpolated scalar value
  25740. */
  25741. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25742. /**
  25743. * Interpolates a scalar cubically
  25744. * @param startValue Start value of the animation curve
  25745. * @param outTangent End tangent of the animation
  25746. * @param endValue End value of the animation curve
  25747. * @param inTangent Start tangent of the animation curve
  25748. * @param gradient Scalar amount to interpolate
  25749. * @returns Interpolated scalar value
  25750. */
  25751. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25752. /**
  25753. * Interpolates a quaternion using a spherical linear interpolation
  25754. * @param startValue Start value of the animation curve
  25755. * @param endValue End value of the animation curve
  25756. * @param gradient Scalar amount to interpolate
  25757. * @returns Interpolated quaternion value
  25758. */
  25759. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25760. /**
  25761. * Interpolates a quaternion cubically
  25762. * @param startValue Start value of the animation curve
  25763. * @param outTangent End tangent of the animation curve
  25764. * @param endValue End value of the animation curve
  25765. * @param inTangent Start tangent of the animation curve
  25766. * @param gradient Scalar amount to interpolate
  25767. * @returns Interpolated quaternion value
  25768. */
  25769. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25770. /**
  25771. * Interpolates a Vector3 linearl
  25772. * @param startValue Start value of the animation curve
  25773. * @param endValue End value of the animation curve
  25774. * @param gradient Scalar amount to interpolate
  25775. * @returns Interpolated scalar value
  25776. */
  25777. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25778. /**
  25779. * Interpolates a Vector3 cubically
  25780. * @param startValue Start value of the animation curve
  25781. * @param outTangent End tangent of the animation
  25782. * @param endValue End value of the animation curve
  25783. * @param inTangent Start tangent of the animation curve
  25784. * @param gradient Scalar amount to interpolate
  25785. * @returns InterpolatedVector3 value
  25786. */
  25787. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25788. /**
  25789. * Interpolates a Vector2 linearly
  25790. * @param startValue Start value of the animation curve
  25791. * @param endValue End value of the animation curve
  25792. * @param gradient Scalar amount to interpolate
  25793. * @returns Interpolated Vector2 value
  25794. */
  25795. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25796. /**
  25797. * Interpolates a Vector2 cubically
  25798. * @param startValue Start value of the animation curve
  25799. * @param outTangent End tangent of the animation
  25800. * @param endValue End value of the animation curve
  25801. * @param inTangent Start tangent of the animation curve
  25802. * @param gradient Scalar amount to interpolate
  25803. * @returns Interpolated Vector2 value
  25804. */
  25805. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25806. /**
  25807. * Interpolates a size linearly
  25808. * @param startValue Start value of the animation curve
  25809. * @param endValue End value of the animation curve
  25810. * @param gradient Scalar amount to interpolate
  25811. * @returns Interpolated Size value
  25812. */
  25813. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25814. /**
  25815. * Interpolates a Color3 linearly
  25816. * @param startValue Start value of the animation curve
  25817. * @param endValue End value of the animation curve
  25818. * @param gradient Scalar amount to interpolate
  25819. * @returns Interpolated Color3 value
  25820. */
  25821. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25822. /**
  25823. * @hidden Internal use only
  25824. */
  25825. _getKeyValue(value: any): any;
  25826. /**
  25827. * @hidden Internal use only
  25828. */
  25829. _interpolate(currentFrame: number, state: _IAnimationState): any;
  25830. /**
  25831. * Defines the function to use to interpolate matrices
  25832. * @param startValue defines the start matrix
  25833. * @param endValue defines the end matrix
  25834. * @param gradient defines the gradient between both matrices
  25835. * @param result defines an optional target matrix where to store the interpolation
  25836. * @returns the interpolated matrix
  25837. */
  25838. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25839. /**
  25840. * Makes a copy of the animation
  25841. * @returns Cloned animation
  25842. */
  25843. clone(): Animation;
  25844. /**
  25845. * Sets the key frames of the animation
  25846. * @param values The animation key frames to set
  25847. */
  25848. setKeys(values: Array<IAnimationKey>): void;
  25849. /**
  25850. * Serializes the animation to an object
  25851. * @returns Serialized object
  25852. */
  25853. serialize(): any;
  25854. /**
  25855. * Float animation type
  25856. */
  25857. private static _ANIMATIONTYPE_FLOAT;
  25858. /**
  25859. * Vector3 animation type
  25860. */
  25861. private static _ANIMATIONTYPE_VECTOR3;
  25862. /**
  25863. * Quaternion animation type
  25864. */
  25865. private static _ANIMATIONTYPE_QUATERNION;
  25866. /**
  25867. * Matrix animation type
  25868. */
  25869. private static _ANIMATIONTYPE_MATRIX;
  25870. /**
  25871. * Color3 animation type
  25872. */
  25873. private static _ANIMATIONTYPE_COLOR3;
  25874. /**
  25875. * Vector2 animation type
  25876. */
  25877. private static _ANIMATIONTYPE_VECTOR2;
  25878. /**
  25879. * Size animation type
  25880. */
  25881. private static _ANIMATIONTYPE_SIZE;
  25882. /**
  25883. * Relative Loop Mode
  25884. */
  25885. private static _ANIMATIONLOOPMODE_RELATIVE;
  25886. /**
  25887. * Cycle Loop Mode
  25888. */
  25889. private static _ANIMATIONLOOPMODE_CYCLE;
  25890. /**
  25891. * Constant Loop Mode
  25892. */
  25893. private static _ANIMATIONLOOPMODE_CONSTANT;
  25894. /**
  25895. * Get the float animation type
  25896. */
  25897. static readonly ANIMATIONTYPE_FLOAT: number;
  25898. /**
  25899. * Get the Vector3 animation type
  25900. */
  25901. static readonly ANIMATIONTYPE_VECTOR3: number;
  25902. /**
  25903. * Get the Vector2 animation type
  25904. */
  25905. static readonly ANIMATIONTYPE_VECTOR2: number;
  25906. /**
  25907. * Get the Size animation type
  25908. */
  25909. static readonly ANIMATIONTYPE_SIZE: number;
  25910. /**
  25911. * Get the Quaternion animation type
  25912. */
  25913. static readonly ANIMATIONTYPE_QUATERNION: number;
  25914. /**
  25915. * Get the Matrix animation type
  25916. */
  25917. static readonly ANIMATIONTYPE_MATRIX: number;
  25918. /**
  25919. * Get the Color3 animation type
  25920. */
  25921. static readonly ANIMATIONTYPE_COLOR3: number;
  25922. /**
  25923. * Get the Relative Loop Mode
  25924. */
  25925. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25926. /**
  25927. * Get the Cycle Loop Mode
  25928. */
  25929. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25930. /**
  25931. * Get the Constant Loop Mode
  25932. */
  25933. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25934. /** @hidden */
  25935. static _UniversalLerp(left: any, right: any, amount: number): any;
  25936. /**
  25937. * Parses an animation object and creates an animation
  25938. * @param parsedAnimation Parsed animation object
  25939. * @returns Animation object
  25940. */
  25941. static Parse(parsedAnimation: any): Animation;
  25942. /**
  25943. * Appends the serialized animations from the source animations
  25944. * @param source Source containing the animations
  25945. * @param destination Target to store the animations
  25946. */
  25947. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25948. }
  25949. }
  25950. declare module BABYLON {
  25951. /**
  25952. * Base class of all the textures in babylon.
  25953. * It groups all the common properties the materials, post process, lights... might need
  25954. * in order to make a correct use of the texture.
  25955. */
  25956. export class BaseTexture implements IAnimatable {
  25957. /**
  25958. * Default anisotropic filtering level for the application.
  25959. * It is set to 4 as a good tradeoff between perf and quality.
  25960. */
  25961. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25962. /**
  25963. * Gets or sets the unique id of the texture
  25964. */
  25965. uniqueId: number;
  25966. /**
  25967. * Define the name of the texture.
  25968. */
  25969. name: string;
  25970. /**
  25971. * Gets or sets an object used to store user defined information.
  25972. */
  25973. metadata: any;
  25974. /**
  25975. * For internal use only. Please do not use.
  25976. */
  25977. reservedDataStore: any;
  25978. private _hasAlpha;
  25979. /**
  25980. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25981. */
  25982. hasAlpha: boolean;
  25983. /**
  25984. * Defines if the alpha value should be determined via the rgb values.
  25985. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25986. */
  25987. getAlphaFromRGB: boolean;
  25988. /**
  25989. * Intensity or strength of the texture.
  25990. * It is commonly used by materials to fine tune the intensity of the texture
  25991. */
  25992. level: number;
  25993. /**
  25994. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25995. * This is part of the texture as textures usually maps to one uv set.
  25996. */
  25997. coordinatesIndex: number;
  25998. private _coordinatesMode;
  25999. /**
  26000. * How a texture is mapped.
  26001. *
  26002. * | Value | Type | Description |
  26003. * | ----- | ----------------------------------- | ----------- |
  26004. * | 0 | EXPLICIT_MODE | |
  26005. * | 1 | SPHERICAL_MODE | |
  26006. * | 2 | PLANAR_MODE | |
  26007. * | 3 | CUBIC_MODE | |
  26008. * | 4 | PROJECTION_MODE | |
  26009. * | 5 | SKYBOX_MODE | |
  26010. * | 6 | INVCUBIC_MODE | |
  26011. * | 7 | EQUIRECTANGULAR_MODE | |
  26012. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26013. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26014. */
  26015. coordinatesMode: number;
  26016. /**
  26017. * | Value | Type | Description |
  26018. * | ----- | ------------------ | ----------- |
  26019. * | 0 | CLAMP_ADDRESSMODE | |
  26020. * | 1 | WRAP_ADDRESSMODE | |
  26021. * | 2 | MIRROR_ADDRESSMODE | |
  26022. */
  26023. wrapU: number;
  26024. /**
  26025. * | Value | Type | Description |
  26026. * | ----- | ------------------ | ----------- |
  26027. * | 0 | CLAMP_ADDRESSMODE | |
  26028. * | 1 | WRAP_ADDRESSMODE | |
  26029. * | 2 | MIRROR_ADDRESSMODE | |
  26030. */
  26031. wrapV: number;
  26032. /**
  26033. * | Value | Type | Description |
  26034. * | ----- | ------------------ | ----------- |
  26035. * | 0 | CLAMP_ADDRESSMODE | |
  26036. * | 1 | WRAP_ADDRESSMODE | |
  26037. * | 2 | MIRROR_ADDRESSMODE | |
  26038. */
  26039. wrapR: number;
  26040. /**
  26041. * With compliant hardware and browser (supporting anisotropic filtering)
  26042. * this defines the level of anisotropic filtering in the texture.
  26043. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26044. */
  26045. anisotropicFilteringLevel: number;
  26046. /**
  26047. * Define if the texture is a cube texture or if false a 2d texture.
  26048. */
  26049. isCube: boolean;
  26050. /**
  26051. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26052. */
  26053. is3D: boolean;
  26054. /**
  26055. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26056. * HDR texture are usually stored in linear space.
  26057. * This only impacts the PBR and Background materials
  26058. */
  26059. gammaSpace: boolean;
  26060. /**
  26061. * Gets whether or not the texture contains RGBD data.
  26062. */
  26063. readonly isRGBD: boolean;
  26064. /**
  26065. * Is Z inverted in the texture (useful in a cube texture).
  26066. */
  26067. invertZ: boolean;
  26068. /**
  26069. * Are mip maps generated for this texture or not.
  26070. */
  26071. readonly noMipmap: boolean;
  26072. /**
  26073. * @hidden
  26074. */
  26075. lodLevelInAlpha: boolean;
  26076. /**
  26077. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26078. */
  26079. lodGenerationOffset: number;
  26080. /**
  26081. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26082. */
  26083. lodGenerationScale: number;
  26084. /**
  26085. * Define if the texture is a render target.
  26086. */
  26087. isRenderTarget: boolean;
  26088. /**
  26089. * Define the unique id of the texture in the scene.
  26090. */
  26091. readonly uid: string;
  26092. /**
  26093. * Return a string representation of the texture.
  26094. * @returns the texture as a string
  26095. */
  26096. toString(): string;
  26097. /**
  26098. * Get the class name of the texture.
  26099. * @returns "BaseTexture"
  26100. */
  26101. getClassName(): string;
  26102. /**
  26103. * Define the list of animation attached to the texture.
  26104. */
  26105. animations: Animation[];
  26106. /**
  26107. * An event triggered when the texture is disposed.
  26108. */
  26109. onDisposeObservable: Observable<BaseTexture>;
  26110. private _onDisposeObserver;
  26111. /**
  26112. * Callback triggered when the texture has been disposed.
  26113. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26114. */
  26115. onDispose: () => void;
  26116. /**
  26117. * Define the current state of the loading sequence when in delayed load mode.
  26118. */
  26119. delayLoadState: number;
  26120. private _scene;
  26121. /** @hidden */
  26122. _texture: Nullable<InternalTexture>;
  26123. private _uid;
  26124. /**
  26125. * Define if the texture is preventinga material to render or not.
  26126. * If not and the texture is not ready, the engine will use a default black texture instead.
  26127. */
  26128. readonly isBlocking: boolean;
  26129. /**
  26130. * Instantiates a new BaseTexture.
  26131. * Base class of all the textures in babylon.
  26132. * It groups all the common properties the materials, post process, lights... might need
  26133. * in order to make a correct use of the texture.
  26134. * @param scene Define the scene the texture blongs to
  26135. */
  26136. constructor(scene: Nullable<Scene>);
  26137. /**
  26138. * Get the scene the texture belongs to.
  26139. * @returns the scene or null if undefined
  26140. */
  26141. getScene(): Nullable<Scene>;
  26142. /**
  26143. * Get the texture transform matrix used to offset tile the texture for istance.
  26144. * @returns the transformation matrix
  26145. */
  26146. getTextureMatrix(): Matrix;
  26147. /**
  26148. * Get the texture reflection matrix used to rotate/transform the reflection.
  26149. * @returns the reflection matrix
  26150. */
  26151. getReflectionTextureMatrix(): Matrix;
  26152. /**
  26153. * Get the underlying lower level texture from Babylon.
  26154. * @returns the insternal texture
  26155. */
  26156. getInternalTexture(): Nullable<InternalTexture>;
  26157. /**
  26158. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26159. * @returns true if ready or not blocking
  26160. */
  26161. isReadyOrNotBlocking(): boolean;
  26162. /**
  26163. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26164. * @returns true if fully ready
  26165. */
  26166. isReady(): boolean;
  26167. private _cachedSize;
  26168. /**
  26169. * Get the size of the texture.
  26170. * @returns the texture size.
  26171. */
  26172. getSize(): ISize;
  26173. /**
  26174. * Get the base size of the texture.
  26175. * It can be different from the size if the texture has been resized for POT for instance
  26176. * @returns the base size
  26177. */
  26178. getBaseSize(): ISize;
  26179. /**
  26180. * Update the sampling mode of the texture.
  26181. * Default is Trilinear mode.
  26182. *
  26183. * | Value | Type | Description |
  26184. * | ----- | ------------------ | ----------- |
  26185. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26186. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26187. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26188. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26189. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26190. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26191. * | 7 | NEAREST_LINEAR | |
  26192. * | 8 | NEAREST_NEAREST | |
  26193. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26194. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26195. * | 11 | LINEAR_LINEAR | |
  26196. * | 12 | LINEAR_NEAREST | |
  26197. *
  26198. * > _mag_: magnification filter (close to the viewer)
  26199. * > _min_: minification filter (far from the viewer)
  26200. * > _mip_: filter used between mip map levels
  26201. *@param samplingMode Define the new sampling mode of the texture
  26202. */
  26203. updateSamplingMode(samplingMode: number): void;
  26204. /**
  26205. * Scales the texture if is `canRescale()`
  26206. * @param ratio the resize factor we want to use to rescale
  26207. */
  26208. scale(ratio: number): void;
  26209. /**
  26210. * Get if the texture can rescale.
  26211. */
  26212. readonly canRescale: boolean;
  26213. /** @hidden */
  26214. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26215. /** @hidden */
  26216. _rebuild(): void;
  26217. /**
  26218. * Triggers the load sequence in delayed load mode.
  26219. */
  26220. delayLoad(): void;
  26221. /**
  26222. * Clones the texture.
  26223. * @returns the cloned texture
  26224. */
  26225. clone(): Nullable<BaseTexture>;
  26226. /**
  26227. * Get the texture underlying type (INT, FLOAT...)
  26228. */
  26229. readonly textureType: number;
  26230. /**
  26231. * Get the texture underlying format (RGB, RGBA...)
  26232. */
  26233. readonly textureFormat: number;
  26234. /**
  26235. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26236. * This will returns an RGBA array buffer containing either in values (0-255) or
  26237. * float values (0-1) depending of the underlying buffer type.
  26238. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26239. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26240. * @param buffer defines a user defined buffer to fill with data (can be null)
  26241. * @returns The Array buffer containing the pixels data.
  26242. */
  26243. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26244. /**
  26245. * Release and destroy the underlying lower level texture aka internalTexture.
  26246. */
  26247. releaseInternalTexture(): void;
  26248. /**
  26249. * Get the polynomial representation of the texture data.
  26250. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26251. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26252. */
  26253. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26254. /** @hidden */
  26255. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26256. /** @hidden */
  26257. readonly _lodTextureMid: Nullable<BaseTexture>;
  26258. /** @hidden */
  26259. readonly _lodTextureLow: Nullable<BaseTexture>;
  26260. /**
  26261. * Dispose the texture and release its associated resources.
  26262. */
  26263. dispose(): void;
  26264. /**
  26265. * Serialize the texture into a JSON representation that can be parsed later on.
  26266. * @returns the JSON representation of the texture
  26267. */
  26268. serialize(): any;
  26269. /**
  26270. * Helper function to be called back once a list of texture contains only ready textures.
  26271. * @param textures Define the list of textures to wait for
  26272. * @param callback Define the callback triggered once the entire list will be ready
  26273. */
  26274. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26275. }
  26276. }
  26277. declare module BABYLON {
  26278. /**
  26279. * Uniform buffer objects.
  26280. *
  26281. * Handles blocks of uniform on the GPU.
  26282. *
  26283. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26284. *
  26285. * For more information, please refer to :
  26286. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26287. */
  26288. export class UniformBuffer {
  26289. private _engine;
  26290. private _buffer;
  26291. private _data;
  26292. private _bufferData;
  26293. private _dynamic?;
  26294. private _uniformLocations;
  26295. private _uniformSizes;
  26296. private _uniformLocationPointer;
  26297. private _needSync;
  26298. private _noUBO;
  26299. private _currentEffect;
  26300. private static _MAX_UNIFORM_SIZE;
  26301. private static _tempBuffer;
  26302. /**
  26303. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26304. * This is dynamic to allow compat with webgl 1 and 2.
  26305. * You will need to pass the name of the uniform as well as the value.
  26306. */
  26307. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26308. /**
  26309. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26310. * This is dynamic to allow compat with webgl 1 and 2.
  26311. * You will need to pass the name of the uniform as well as the value.
  26312. */
  26313. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26314. /**
  26315. * Lambda to Update a single float in a uniform buffer.
  26316. * This is dynamic to allow compat with webgl 1 and 2.
  26317. * You will need to pass the name of the uniform as well as the value.
  26318. */
  26319. updateFloat: (name: string, x: number) => void;
  26320. /**
  26321. * Lambda to Update a vec2 of float in a uniform buffer.
  26322. * This is dynamic to allow compat with webgl 1 and 2.
  26323. * You will need to pass the name of the uniform as well as the value.
  26324. */
  26325. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26326. /**
  26327. * Lambda to Update a vec3 of float in a uniform buffer.
  26328. * This is dynamic to allow compat with webgl 1 and 2.
  26329. * You will need to pass the name of the uniform as well as the value.
  26330. */
  26331. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26332. /**
  26333. * Lambda to Update a vec4 of float in a uniform buffer.
  26334. * This is dynamic to allow compat with webgl 1 and 2.
  26335. * You will need to pass the name of the uniform as well as the value.
  26336. */
  26337. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26338. /**
  26339. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26340. * This is dynamic to allow compat with webgl 1 and 2.
  26341. * You will need to pass the name of the uniform as well as the value.
  26342. */
  26343. updateMatrix: (name: string, mat: Matrix) => void;
  26344. /**
  26345. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26346. * This is dynamic to allow compat with webgl 1 and 2.
  26347. * You will need to pass the name of the uniform as well as the value.
  26348. */
  26349. updateVector3: (name: string, vector: Vector3) => void;
  26350. /**
  26351. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26352. * This is dynamic to allow compat with webgl 1 and 2.
  26353. * You will need to pass the name of the uniform as well as the value.
  26354. */
  26355. updateVector4: (name: string, vector: Vector4) => void;
  26356. /**
  26357. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26358. * This is dynamic to allow compat with webgl 1 and 2.
  26359. * You will need to pass the name of the uniform as well as the value.
  26360. */
  26361. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26362. /**
  26363. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26364. * This is dynamic to allow compat with webgl 1 and 2.
  26365. * You will need to pass the name of the uniform as well as the value.
  26366. */
  26367. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26368. /**
  26369. * Instantiates a new Uniform buffer objects.
  26370. *
  26371. * Handles blocks of uniform on the GPU.
  26372. *
  26373. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26374. *
  26375. * For more information, please refer to :
  26376. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26377. * @param engine Define the engine the buffer is associated with
  26378. * @param data Define the data contained in the buffer
  26379. * @param dynamic Define if the buffer is updatable
  26380. */
  26381. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26382. /**
  26383. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26384. * or just falling back on setUniformXXX calls.
  26385. */
  26386. readonly useUbo: boolean;
  26387. /**
  26388. * Indicates if the WebGL underlying uniform buffer is in sync
  26389. * with the javascript cache data.
  26390. */
  26391. readonly isSync: boolean;
  26392. /**
  26393. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26394. * Also, a dynamic UniformBuffer will disable cache verification and always
  26395. * update the underlying WebGL uniform buffer to the GPU.
  26396. * @returns if Dynamic, otherwise false
  26397. */
  26398. isDynamic(): boolean;
  26399. /**
  26400. * The data cache on JS side.
  26401. * @returns the underlying data as a float array
  26402. */
  26403. getData(): Float32Array;
  26404. /**
  26405. * The underlying WebGL Uniform buffer.
  26406. * @returns the webgl buffer
  26407. */
  26408. getBuffer(): Nullable<DataBuffer>;
  26409. /**
  26410. * std140 layout specifies how to align data within an UBO structure.
  26411. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26412. * for specs.
  26413. */
  26414. private _fillAlignment;
  26415. /**
  26416. * Adds an uniform in the buffer.
  26417. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26418. * for the layout to be correct !
  26419. * @param name Name of the uniform, as used in the uniform block in the shader.
  26420. * @param size Data size, or data directly.
  26421. */
  26422. addUniform(name: string, size: number | number[]): void;
  26423. /**
  26424. * Adds a Matrix 4x4 to the uniform buffer.
  26425. * @param name Name of the uniform, as used in the uniform block in the shader.
  26426. * @param mat A 4x4 matrix.
  26427. */
  26428. addMatrix(name: string, mat: Matrix): void;
  26429. /**
  26430. * Adds a vec2 to the uniform buffer.
  26431. * @param name Name of the uniform, as used in the uniform block in the shader.
  26432. * @param x Define the x component value of the vec2
  26433. * @param y Define the y component value of the vec2
  26434. */
  26435. addFloat2(name: string, x: number, y: number): void;
  26436. /**
  26437. * Adds a vec3 to the uniform buffer.
  26438. * @param name Name of the uniform, as used in the uniform block in the shader.
  26439. * @param x Define the x component value of the vec3
  26440. * @param y Define the y component value of the vec3
  26441. * @param z Define the z component value of the vec3
  26442. */
  26443. addFloat3(name: string, x: number, y: number, z: number): void;
  26444. /**
  26445. * Adds a vec3 to the uniform buffer.
  26446. * @param name Name of the uniform, as used in the uniform block in the shader.
  26447. * @param color Define the vec3 from a Color
  26448. */
  26449. addColor3(name: string, color: Color3): void;
  26450. /**
  26451. * Adds a vec4 to the uniform buffer.
  26452. * @param name Name of the uniform, as used in the uniform block in the shader.
  26453. * @param color Define the rgb components from a Color
  26454. * @param alpha Define the a component of the vec4
  26455. */
  26456. addColor4(name: string, color: Color3, alpha: number): void;
  26457. /**
  26458. * Adds a vec3 to the uniform buffer.
  26459. * @param name Name of the uniform, as used in the uniform block in the shader.
  26460. * @param vector Define the vec3 components from a Vector
  26461. */
  26462. addVector3(name: string, vector: Vector3): void;
  26463. /**
  26464. * Adds a Matrix 3x3 to the uniform buffer.
  26465. * @param name Name of the uniform, as used in the uniform block in the shader.
  26466. */
  26467. addMatrix3x3(name: string): void;
  26468. /**
  26469. * Adds a Matrix 2x2 to the uniform buffer.
  26470. * @param name Name of the uniform, as used in the uniform block in the shader.
  26471. */
  26472. addMatrix2x2(name: string): void;
  26473. /**
  26474. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26475. */
  26476. create(): void;
  26477. /** @hidden */
  26478. _rebuild(): void;
  26479. /**
  26480. * Updates the WebGL Uniform Buffer on the GPU.
  26481. * If the `dynamic` flag is set to true, no cache comparison is done.
  26482. * Otherwise, the buffer will be updated only if the cache differs.
  26483. */
  26484. update(): void;
  26485. /**
  26486. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26487. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26488. * @param data Define the flattened data
  26489. * @param size Define the size of the data.
  26490. */
  26491. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26492. private _updateMatrix3x3ForUniform;
  26493. private _updateMatrix3x3ForEffect;
  26494. private _updateMatrix2x2ForEffect;
  26495. private _updateMatrix2x2ForUniform;
  26496. private _updateFloatForEffect;
  26497. private _updateFloatForUniform;
  26498. private _updateFloat2ForEffect;
  26499. private _updateFloat2ForUniform;
  26500. private _updateFloat3ForEffect;
  26501. private _updateFloat3ForUniform;
  26502. private _updateFloat4ForEffect;
  26503. private _updateFloat4ForUniform;
  26504. private _updateMatrixForEffect;
  26505. private _updateMatrixForUniform;
  26506. private _updateVector3ForEffect;
  26507. private _updateVector3ForUniform;
  26508. private _updateVector4ForEffect;
  26509. private _updateVector4ForUniform;
  26510. private _updateColor3ForEffect;
  26511. private _updateColor3ForUniform;
  26512. private _updateColor4ForEffect;
  26513. private _updateColor4ForUniform;
  26514. /**
  26515. * Sets a sampler uniform on the effect.
  26516. * @param name Define the name of the sampler.
  26517. * @param texture Define the texture to set in the sampler
  26518. */
  26519. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26520. /**
  26521. * Directly updates the value of the uniform in the cache AND on the GPU.
  26522. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26523. * @param data Define the flattened data
  26524. */
  26525. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26526. /**
  26527. * Binds this uniform buffer to an effect.
  26528. * @param effect Define the effect to bind the buffer to
  26529. * @param name Name of the uniform block in the shader.
  26530. */
  26531. bindToEffect(effect: Effect, name: string): void;
  26532. /**
  26533. * Disposes the uniform buffer.
  26534. */
  26535. dispose(): void;
  26536. }
  26537. }
  26538. declare module BABYLON {
  26539. /**
  26540. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26541. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26542. */
  26543. export class Analyser {
  26544. /**
  26545. * Gets or sets the smoothing
  26546. * @ignorenaming
  26547. */
  26548. SMOOTHING: number;
  26549. /**
  26550. * Gets or sets the FFT table size
  26551. * @ignorenaming
  26552. */
  26553. FFT_SIZE: number;
  26554. /**
  26555. * Gets or sets the bar graph amplitude
  26556. * @ignorenaming
  26557. */
  26558. BARGRAPHAMPLITUDE: number;
  26559. /**
  26560. * Gets or sets the position of the debug canvas
  26561. * @ignorenaming
  26562. */
  26563. DEBUGCANVASPOS: {
  26564. x: number;
  26565. y: number;
  26566. };
  26567. /**
  26568. * Gets or sets the debug canvas size
  26569. * @ignorenaming
  26570. */
  26571. DEBUGCANVASSIZE: {
  26572. width: number;
  26573. height: number;
  26574. };
  26575. private _byteFreqs;
  26576. private _byteTime;
  26577. private _floatFreqs;
  26578. private _webAudioAnalyser;
  26579. private _debugCanvas;
  26580. private _debugCanvasContext;
  26581. private _scene;
  26582. private _registerFunc;
  26583. private _audioEngine;
  26584. /**
  26585. * Creates a new analyser
  26586. * @param scene defines hosting scene
  26587. */
  26588. constructor(scene: Scene);
  26589. /**
  26590. * Get the number of data values you will have to play with for the visualization
  26591. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26592. * @returns a number
  26593. */
  26594. getFrequencyBinCount(): number;
  26595. /**
  26596. * Gets the current frequency data as a byte array
  26597. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26598. * @returns a Uint8Array
  26599. */
  26600. getByteFrequencyData(): Uint8Array;
  26601. /**
  26602. * Gets the current waveform as a byte array
  26603. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26604. * @returns a Uint8Array
  26605. */
  26606. getByteTimeDomainData(): Uint8Array;
  26607. /**
  26608. * Gets the current frequency data as a float array
  26609. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26610. * @returns a Float32Array
  26611. */
  26612. getFloatFrequencyData(): Float32Array;
  26613. /**
  26614. * Renders the debug canvas
  26615. */
  26616. drawDebugCanvas(): void;
  26617. /**
  26618. * Stops rendering the debug canvas and removes it
  26619. */
  26620. stopDebugCanvas(): void;
  26621. /**
  26622. * Connects two audio nodes
  26623. * @param inputAudioNode defines first node to connect
  26624. * @param outputAudioNode defines second node to connect
  26625. */
  26626. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26627. /**
  26628. * Releases all associated resources
  26629. */
  26630. dispose(): void;
  26631. }
  26632. }
  26633. declare module BABYLON {
  26634. /**
  26635. * This represents an audio engine and it is responsible
  26636. * to play, synchronize and analyse sounds throughout the application.
  26637. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26638. */
  26639. export interface IAudioEngine extends IDisposable {
  26640. /**
  26641. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26642. */
  26643. readonly canUseWebAudio: boolean;
  26644. /**
  26645. * Gets the current AudioContext if available.
  26646. */
  26647. readonly audioContext: Nullable<AudioContext>;
  26648. /**
  26649. * The master gain node defines the global audio volume of your audio engine.
  26650. */
  26651. readonly masterGain: GainNode;
  26652. /**
  26653. * Gets whether or not mp3 are supported by your browser.
  26654. */
  26655. readonly isMP3supported: boolean;
  26656. /**
  26657. * Gets whether or not ogg are supported by your browser.
  26658. */
  26659. readonly isOGGsupported: boolean;
  26660. /**
  26661. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26662. * @ignoreNaming
  26663. */
  26664. WarnedWebAudioUnsupported: boolean;
  26665. /**
  26666. * Defines if the audio engine relies on a custom unlocked button.
  26667. * In this case, the embedded button will not be displayed.
  26668. */
  26669. useCustomUnlockedButton: boolean;
  26670. /**
  26671. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26672. */
  26673. readonly unlocked: boolean;
  26674. /**
  26675. * Event raised when audio has been unlocked on the browser.
  26676. */
  26677. onAudioUnlockedObservable: Observable<AudioEngine>;
  26678. /**
  26679. * Event raised when audio has been locked on the browser.
  26680. */
  26681. onAudioLockedObservable: Observable<AudioEngine>;
  26682. /**
  26683. * Flags the audio engine in Locked state.
  26684. * This happens due to new browser policies preventing audio to autoplay.
  26685. */
  26686. lock(): void;
  26687. /**
  26688. * Unlocks the audio engine once a user action has been done on the dom.
  26689. * This is helpful to resume play once browser policies have been satisfied.
  26690. */
  26691. unlock(): void;
  26692. }
  26693. /**
  26694. * This represents the default audio engine used in babylon.
  26695. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26697. */
  26698. export class AudioEngine implements IAudioEngine {
  26699. private _audioContext;
  26700. private _audioContextInitialized;
  26701. private _muteButton;
  26702. private _hostElement;
  26703. /**
  26704. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26705. */
  26706. canUseWebAudio: boolean;
  26707. /**
  26708. * The master gain node defines the global audio volume of your audio engine.
  26709. */
  26710. masterGain: GainNode;
  26711. /**
  26712. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26713. * @ignoreNaming
  26714. */
  26715. WarnedWebAudioUnsupported: boolean;
  26716. /**
  26717. * Gets whether or not mp3 are supported by your browser.
  26718. */
  26719. isMP3supported: boolean;
  26720. /**
  26721. * Gets whether or not ogg are supported by your browser.
  26722. */
  26723. isOGGsupported: boolean;
  26724. /**
  26725. * Gets whether audio has been unlocked on the device.
  26726. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26727. * a user interaction has happened.
  26728. */
  26729. unlocked: boolean;
  26730. /**
  26731. * Defines if the audio engine relies on a custom unlocked button.
  26732. * In this case, the embedded button will not be displayed.
  26733. */
  26734. useCustomUnlockedButton: boolean;
  26735. /**
  26736. * Event raised when audio has been unlocked on the browser.
  26737. */
  26738. onAudioUnlockedObservable: Observable<AudioEngine>;
  26739. /**
  26740. * Event raised when audio has been locked on the browser.
  26741. */
  26742. onAudioLockedObservable: Observable<AudioEngine>;
  26743. /**
  26744. * Gets the current AudioContext if available.
  26745. */
  26746. readonly audioContext: Nullable<AudioContext>;
  26747. private _connectedAnalyser;
  26748. /**
  26749. * Instantiates a new audio engine.
  26750. *
  26751. * There should be only one per page as some browsers restrict the number
  26752. * of audio contexts you can create.
  26753. * @param hostElement defines the host element where to display the mute icon if necessary
  26754. */
  26755. constructor(hostElement?: Nullable<HTMLElement>);
  26756. /**
  26757. * Flags the audio engine in Locked state.
  26758. * This happens due to new browser policies preventing audio to autoplay.
  26759. */
  26760. lock(): void;
  26761. /**
  26762. * Unlocks the audio engine once a user action has been done on the dom.
  26763. * This is helpful to resume play once browser policies have been satisfied.
  26764. */
  26765. unlock(): void;
  26766. private _resumeAudioContext;
  26767. private _initializeAudioContext;
  26768. private _tryToRun;
  26769. private _triggerRunningState;
  26770. private _triggerSuspendedState;
  26771. private _displayMuteButton;
  26772. private _moveButtonToTopLeft;
  26773. private _onResize;
  26774. private _hideMuteButton;
  26775. /**
  26776. * Destroy and release the resources associated with the audio ccontext.
  26777. */
  26778. dispose(): void;
  26779. /**
  26780. * Gets the global volume sets on the master gain.
  26781. * @returns the global volume if set or -1 otherwise
  26782. */
  26783. getGlobalVolume(): number;
  26784. /**
  26785. * Sets the global volume of your experience (sets on the master gain).
  26786. * @param newVolume Defines the new global volume of the application
  26787. */
  26788. setGlobalVolume(newVolume: number): void;
  26789. /**
  26790. * Connect the audio engine to an audio analyser allowing some amazing
  26791. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26793. * @param analyser The analyser to connect to the engine
  26794. */
  26795. connectToAnalyser(analyser: Analyser): void;
  26796. }
  26797. }
  26798. declare module BABYLON {
  26799. /**
  26800. * Interface used to present a loading screen while loading a scene
  26801. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26802. */
  26803. export interface ILoadingScreen {
  26804. /**
  26805. * Function called to display the loading screen
  26806. */
  26807. displayLoadingUI: () => void;
  26808. /**
  26809. * Function called to hide the loading screen
  26810. */
  26811. hideLoadingUI: () => void;
  26812. /**
  26813. * Gets or sets the color to use for the background
  26814. */
  26815. loadingUIBackgroundColor: string;
  26816. /**
  26817. * Gets or sets the text to display while loading
  26818. */
  26819. loadingUIText: string;
  26820. }
  26821. /**
  26822. * Class used for the default loading screen
  26823. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26824. */
  26825. export class DefaultLoadingScreen implements ILoadingScreen {
  26826. private _renderingCanvas;
  26827. private _loadingText;
  26828. private _loadingDivBackgroundColor;
  26829. private _loadingDiv;
  26830. private _loadingTextDiv;
  26831. /**
  26832. * Creates a new default loading screen
  26833. * @param _renderingCanvas defines the canvas used to render the scene
  26834. * @param _loadingText defines the default text to display
  26835. * @param _loadingDivBackgroundColor defines the default background color
  26836. */
  26837. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26838. /**
  26839. * Function called to display the loading screen
  26840. */
  26841. displayLoadingUI(): void;
  26842. /**
  26843. * Function called to hide the loading screen
  26844. */
  26845. hideLoadingUI(): void;
  26846. /**
  26847. * Gets or sets the text to display while loading
  26848. */
  26849. loadingUIText: string;
  26850. /**
  26851. * Gets or sets the color to use for the background
  26852. */
  26853. loadingUIBackgroundColor: string;
  26854. private _resizeLoadingUI;
  26855. }
  26856. }
  26857. declare module BABYLON {
  26858. /** @hidden */
  26859. export class WebGLPipelineContext implements IPipelineContext {
  26860. engine: Engine;
  26861. program: Nullable<WebGLProgram>;
  26862. context?: WebGLRenderingContext;
  26863. vertexShader?: WebGLShader;
  26864. fragmentShader?: WebGLShader;
  26865. isParallelCompiled: boolean;
  26866. onCompiled?: () => void;
  26867. transformFeedback?: WebGLTransformFeedback | null;
  26868. readonly isAsync: boolean;
  26869. readonly isReady: boolean;
  26870. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  26871. }
  26872. }
  26873. declare module BABYLON {
  26874. /** @hidden */
  26875. export class WebGLDataBuffer extends DataBuffer {
  26876. private _buffer;
  26877. constructor(resource: WebGLBuffer);
  26878. readonly underlyingResource: any;
  26879. }
  26880. }
  26881. declare module BABYLON {
  26882. /**
  26883. * Settings for finer control over video usage
  26884. */
  26885. export interface VideoTextureSettings {
  26886. /**
  26887. * Applies `autoplay` to video, if specified
  26888. */
  26889. autoPlay?: boolean;
  26890. /**
  26891. * Applies `loop` to video, if specified
  26892. */
  26893. loop?: boolean;
  26894. /**
  26895. * Automatically updates internal texture from video at every frame in the render loop
  26896. */
  26897. autoUpdateTexture: boolean;
  26898. /**
  26899. * Image src displayed during the video loading or until the user interacts with the video.
  26900. */
  26901. poster?: string;
  26902. }
  26903. /**
  26904. * If you want to display a video in your scene, this is the special texture for that.
  26905. * This special texture works similar to other textures, with the exception of a few parameters.
  26906. * @see https://doc.babylonjs.com/how_to/video_texture
  26907. */
  26908. export class VideoTexture extends Texture {
  26909. /**
  26910. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26911. */
  26912. readonly autoUpdateTexture: boolean;
  26913. /**
  26914. * The video instance used by the texture internally
  26915. */
  26916. readonly video: HTMLVideoElement;
  26917. private _onUserActionRequestedObservable;
  26918. /**
  26919. * Event triggerd when a dom action is required by the user to play the video.
  26920. * This happens due to recent changes in browser policies preventing video to auto start.
  26921. */
  26922. readonly onUserActionRequestedObservable: Observable<Texture>;
  26923. private _generateMipMaps;
  26924. private _engine;
  26925. private _stillImageCaptured;
  26926. private _displayingPosterTexture;
  26927. private _settings;
  26928. private _createInternalTextureOnEvent;
  26929. /**
  26930. * Creates a video texture.
  26931. * If you want to display a video in your scene, this is the special texture for that.
  26932. * This special texture works similar to other textures, with the exception of a few parameters.
  26933. * @see https://doc.babylonjs.com/how_to/video_texture
  26934. * @param name optional name, will detect from video source, if not defined
  26935. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26936. * @param scene is obviously the current scene.
  26937. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26938. * @param invertY is false by default but can be used to invert video on Y axis
  26939. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26940. * @param settings allows finer control over video usage
  26941. */
  26942. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26943. private _getName;
  26944. private _getVideo;
  26945. private _createInternalTexture;
  26946. private reset;
  26947. /**
  26948. * @hidden Internal method to initiate `update`.
  26949. */
  26950. _rebuild(): void;
  26951. /**
  26952. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26953. */
  26954. update(): void;
  26955. /**
  26956. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26957. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26958. */
  26959. updateTexture(isVisible: boolean): void;
  26960. protected _updateInternalTexture: () => void;
  26961. /**
  26962. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26963. * @param url New url.
  26964. */
  26965. updateURL(url: string): void;
  26966. /**
  26967. * Dispose the texture and release its associated resources.
  26968. */
  26969. dispose(): void;
  26970. /**
  26971. * Creates a video texture straight from a stream.
  26972. * @param scene Define the scene the texture should be created in
  26973. * @param stream Define the stream the texture should be created from
  26974. * @returns The created video texture as a promise
  26975. */
  26976. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26977. /**
  26978. * Creates a video texture straight from your WebCam video feed.
  26979. * @param scene Define the scene the texture should be created in
  26980. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26981. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26982. * @returns The created video texture as a promise
  26983. */
  26984. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26985. minWidth: number;
  26986. maxWidth: number;
  26987. minHeight: number;
  26988. maxHeight: number;
  26989. deviceId: string;
  26990. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26991. /**
  26992. * Creates a video texture straight from your WebCam video feed.
  26993. * @param scene Define the scene the texture should be created in
  26994. * @param onReady Define a callback to triggered once the texture will be ready
  26995. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26996. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26997. */
  26998. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26999. minWidth: number;
  27000. maxWidth: number;
  27001. minHeight: number;
  27002. maxHeight: number;
  27003. deviceId: string;
  27004. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27005. }
  27006. }
  27007. declare module BABYLON {
  27008. /**
  27009. * Interface for attribute information associated with buffer instanciation
  27010. */
  27011. export class InstancingAttributeInfo {
  27012. /**
  27013. * Index/offset of the attribute in the vertex shader
  27014. */
  27015. index: number;
  27016. /**
  27017. * size of the attribute, 1, 2, 3 or 4
  27018. */
  27019. attributeSize: number;
  27020. /**
  27021. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27022. * default is FLOAT
  27023. */
  27024. attribyteType: number;
  27025. /**
  27026. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27027. */
  27028. normalized: boolean;
  27029. /**
  27030. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27031. */
  27032. offset: number;
  27033. /**
  27034. * Name of the GLSL attribute, for debugging purpose only
  27035. */
  27036. attributeName: string;
  27037. }
  27038. /**
  27039. * Define options used to create a depth texture
  27040. */
  27041. export class DepthTextureCreationOptions {
  27042. /** Specifies whether or not a stencil should be allocated in the texture */
  27043. generateStencil?: boolean;
  27044. /** Specifies whether or not bilinear filtering is enable on the texture */
  27045. bilinearFiltering?: boolean;
  27046. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27047. comparisonFunction?: number;
  27048. /** Specifies if the created texture is a cube texture */
  27049. isCube?: boolean;
  27050. }
  27051. /**
  27052. * Class used to describe the capabilities of the engine relatively to the current browser
  27053. */
  27054. export class EngineCapabilities {
  27055. /** Maximum textures units per fragment shader */
  27056. maxTexturesImageUnits: number;
  27057. /** Maximum texture units per vertex shader */
  27058. maxVertexTextureImageUnits: number;
  27059. /** Maximum textures units in the entire pipeline */
  27060. maxCombinedTexturesImageUnits: number;
  27061. /** Maximum texture size */
  27062. maxTextureSize: number;
  27063. /** Maximum cube texture size */
  27064. maxCubemapTextureSize: number;
  27065. /** Maximum render texture size */
  27066. maxRenderTextureSize: number;
  27067. /** Maximum number of vertex attributes */
  27068. maxVertexAttribs: number;
  27069. /** Maximum number of varyings */
  27070. maxVaryingVectors: number;
  27071. /** Maximum number of uniforms per vertex shader */
  27072. maxVertexUniformVectors: number;
  27073. /** Maximum number of uniforms per fragment shader */
  27074. maxFragmentUniformVectors: number;
  27075. /** Defines if standard derivates (dx/dy) are supported */
  27076. standardDerivatives: boolean;
  27077. /** Defines if s3tc texture compression is supported */
  27078. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27079. /** Defines if pvrtc texture compression is supported */
  27080. pvrtc: any;
  27081. /** Defines if etc1 texture compression is supported */
  27082. etc1: any;
  27083. /** Defines if etc2 texture compression is supported */
  27084. etc2: any;
  27085. /** Defines if astc texture compression is supported */
  27086. astc: any;
  27087. /** Defines if float textures are supported */
  27088. textureFloat: boolean;
  27089. /** Defines if vertex array objects are supported */
  27090. vertexArrayObject: boolean;
  27091. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27092. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27093. /** Gets the maximum level of anisotropy supported */
  27094. maxAnisotropy: number;
  27095. /** Defines if instancing is supported */
  27096. instancedArrays: boolean;
  27097. /** Defines if 32 bits indices are supported */
  27098. uintIndices: boolean;
  27099. /** Defines if high precision shaders are supported */
  27100. highPrecisionShaderSupported: boolean;
  27101. /** Defines if depth reading in the fragment shader is supported */
  27102. fragmentDepthSupported: boolean;
  27103. /** Defines if float texture linear filtering is supported*/
  27104. textureFloatLinearFiltering: boolean;
  27105. /** Defines if rendering to float textures is supported */
  27106. textureFloatRender: boolean;
  27107. /** Defines if half float textures are supported*/
  27108. textureHalfFloat: boolean;
  27109. /** Defines if half float texture linear filtering is supported*/
  27110. textureHalfFloatLinearFiltering: boolean;
  27111. /** Defines if rendering to half float textures is supported */
  27112. textureHalfFloatRender: boolean;
  27113. /** Defines if textureLOD shader command is supported */
  27114. textureLOD: boolean;
  27115. /** Defines if draw buffers extension is supported */
  27116. drawBuffersExtension: boolean;
  27117. /** Defines if depth textures are supported */
  27118. depthTextureExtension: boolean;
  27119. /** Defines if float color buffer are supported */
  27120. colorBufferFloat: boolean;
  27121. /** Gets disjoint timer query extension (null if not supported) */
  27122. timerQuery: EXT_disjoint_timer_query;
  27123. /** Defines if timestamp can be used with timer query */
  27124. canUseTimestampForTimerQuery: boolean;
  27125. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27126. multiview: any;
  27127. /** Function used to let the system compiles shaders in background */
  27128. parallelShaderCompile: {
  27129. COMPLETION_STATUS_KHR: number;
  27130. };
  27131. }
  27132. /** Interface defining initialization parameters for Engine class */
  27133. export interface EngineOptions extends WebGLContextAttributes {
  27134. /**
  27135. * Defines if the engine should no exceed a specified device ratio
  27136. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27137. */
  27138. limitDeviceRatio?: number;
  27139. /**
  27140. * Defines if webvr should be enabled automatically
  27141. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27142. */
  27143. autoEnableWebVR?: boolean;
  27144. /**
  27145. * Defines if webgl2 should be turned off even if supported
  27146. * @see http://doc.babylonjs.com/features/webgl2
  27147. */
  27148. disableWebGL2Support?: boolean;
  27149. /**
  27150. * Defines if webaudio should be initialized as well
  27151. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27152. */
  27153. audioEngine?: boolean;
  27154. /**
  27155. * Defines if animations should run using a deterministic lock step
  27156. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27157. */
  27158. deterministicLockstep?: boolean;
  27159. /** Defines the maximum steps to use with deterministic lock step mode */
  27160. lockstepMaxSteps?: number;
  27161. /**
  27162. * Defines that engine should ignore context lost events
  27163. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27164. */
  27165. doNotHandleContextLost?: boolean;
  27166. /**
  27167. * Defines that engine should ignore modifying touch action attribute and style
  27168. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27169. */
  27170. doNotHandleTouchAction?: boolean;
  27171. /**
  27172. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27173. */
  27174. useHighPrecisionFloats?: boolean;
  27175. }
  27176. /**
  27177. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27178. */
  27179. export class Engine {
  27180. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27181. static ExceptionList: ({
  27182. key: string;
  27183. capture: string;
  27184. captureConstraint: number;
  27185. targets: string[];
  27186. } | {
  27187. key: string;
  27188. capture: null;
  27189. captureConstraint: null;
  27190. targets: string[];
  27191. })[];
  27192. /** Gets the list of created engines */
  27193. static readonly Instances: Engine[];
  27194. /**
  27195. * Gets the latest created engine
  27196. */
  27197. static readonly LastCreatedEngine: Nullable<Engine>;
  27198. /**
  27199. * Gets the latest created scene
  27200. */
  27201. static readonly LastCreatedScene: Nullable<Scene>;
  27202. /**
  27203. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27204. * @param flag defines which part of the materials must be marked as dirty
  27205. * @param predicate defines a predicate used to filter which materials should be affected
  27206. */
  27207. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27208. /**
  27209. * Hidden
  27210. */
  27211. static _TextureLoaders: IInternalTextureLoader[];
  27212. /** Defines that alpha blending is disabled */
  27213. static readonly ALPHA_DISABLE: number;
  27214. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27215. static readonly ALPHA_ADD: number;
  27216. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27217. static readonly ALPHA_COMBINE: number;
  27218. /** Defines that alpha blending to DEST - SRC * DEST */
  27219. static readonly ALPHA_SUBTRACT: number;
  27220. /** Defines that alpha blending to SRC * DEST */
  27221. static readonly ALPHA_MULTIPLY: number;
  27222. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27223. static readonly ALPHA_MAXIMIZED: number;
  27224. /** Defines that alpha blending to SRC + DEST */
  27225. static readonly ALPHA_ONEONE: number;
  27226. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27227. static readonly ALPHA_PREMULTIPLIED: number;
  27228. /**
  27229. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27230. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27231. */
  27232. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27233. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27234. static readonly ALPHA_INTERPOLATE: number;
  27235. /**
  27236. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27237. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27238. */
  27239. static readonly ALPHA_SCREENMODE: number;
  27240. /** Defines that the ressource is not delayed*/
  27241. static readonly DELAYLOADSTATE_NONE: number;
  27242. /** Defines that the ressource was successfully delay loaded */
  27243. static readonly DELAYLOADSTATE_LOADED: number;
  27244. /** Defines that the ressource is currently delay loading */
  27245. static readonly DELAYLOADSTATE_LOADING: number;
  27246. /** Defines that the ressource is delayed and has not started loading */
  27247. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27248. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27249. static readonly NEVER: number;
  27250. /** 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 */
  27251. static readonly ALWAYS: number;
  27252. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27253. static readonly LESS: number;
  27254. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27255. static readonly EQUAL: number;
  27256. /** 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 */
  27257. static readonly LEQUAL: number;
  27258. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27259. static readonly GREATER: number;
  27260. /** 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 */
  27261. static readonly GEQUAL: number;
  27262. /** 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 */
  27263. static readonly NOTEQUAL: number;
  27264. /** Passed to stencilOperation to specify that stencil value must be kept */
  27265. static readonly KEEP: number;
  27266. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27267. static readonly REPLACE: number;
  27268. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27269. static readonly INCR: number;
  27270. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27271. static readonly DECR: number;
  27272. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27273. static readonly INVERT: number;
  27274. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27275. static readonly INCR_WRAP: number;
  27276. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27277. static readonly DECR_WRAP: number;
  27278. /** Texture is not repeating outside of 0..1 UVs */
  27279. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27280. /** Texture is repeating outside of 0..1 UVs */
  27281. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27282. /** Texture is repeating and mirrored */
  27283. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27284. /** ALPHA */
  27285. static readonly TEXTUREFORMAT_ALPHA: number;
  27286. /** LUMINANCE */
  27287. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27288. /** LUMINANCE_ALPHA */
  27289. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27290. /** RGB */
  27291. static readonly TEXTUREFORMAT_RGB: number;
  27292. /** RGBA */
  27293. static readonly TEXTUREFORMAT_RGBA: number;
  27294. /** RED */
  27295. static readonly TEXTUREFORMAT_RED: number;
  27296. /** RED (2nd reference) */
  27297. static readonly TEXTUREFORMAT_R: number;
  27298. /** RG */
  27299. static readonly TEXTUREFORMAT_RG: number;
  27300. /** RED_INTEGER */
  27301. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27302. /** RED_INTEGER (2nd reference) */
  27303. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27304. /** RG_INTEGER */
  27305. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27306. /** RGB_INTEGER */
  27307. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27308. /** RGBA_INTEGER */
  27309. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27310. /** UNSIGNED_BYTE */
  27311. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27312. /** UNSIGNED_BYTE (2nd reference) */
  27313. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27314. /** FLOAT */
  27315. static readonly TEXTURETYPE_FLOAT: number;
  27316. /** HALF_FLOAT */
  27317. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27318. /** BYTE */
  27319. static readonly TEXTURETYPE_BYTE: number;
  27320. /** SHORT */
  27321. static readonly TEXTURETYPE_SHORT: number;
  27322. /** UNSIGNED_SHORT */
  27323. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27324. /** INT */
  27325. static readonly TEXTURETYPE_INT: number;
  27326. /** UNSIGNED_INT */
  27327. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27328. /** UNSIGNED_SHORT_4_4_4_4 */
  27329. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27330. /** UNSIGNED_SHORT_5_5_5_1 */
  27331. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27332. /** UNSIGNED_SHORT_5_6_5 */
  27333. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27334. /** UNSIGNED_INT_2_10_10_10_REV */
  27335. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27336. /** UNSIGNED_INT_24_8 */
  27337. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27338. /** UNSIGNED_INT_10F_11F_11F_REV */
  27339. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27340. /** UNSIGNED_INT_5_9_9_9_REV */
  27341. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27342. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27343. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27344. /** nearest is mag = nearest and min = nearest and mip = linear */
  27345. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27346. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27347. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27348. /** Trilinear is mag = linear and min = linear and mip = linear */
  27349. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27350. /** nearest is mag = nearest and min = nearest and mip = linear */
  27351. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27352. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27353. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27354. /** Trilinear is mag = linear and min = linear and mip = linear */
  27355. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27356. /** mag = nearest and min = nearest and mip = nearest */
  27357. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27358. /** mag = nearest and min = linear and mip = nearest */
  27359. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27360. /** mag = nearest and min = linear and mip = linear */
  27361. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27362. /** mag = nearest and min = linear and mip = none */
  27363. static readonly TEXTURE_NEAREST_LINEAR: number;
  27364. /** mag = nearest and min = nearest and mip = none */
  27365. static readonly TEXTURE_NEAREST_NEAREST: number;
  27366. /** mag = linear and min = nearest and mip = nearest */
  27367. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27368. /** mag = linear and min = nearest and mip = linear */
  27369. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27370. /** mag = linear and min = linear and mip = none */
  27371. static readonly TEXTURE_LINEAR_LINEAR: number;
  27372. /** mag = linear and min = nearest and mip = none */
  27373. static readonly TEXTURE_LINEAR_NEAREST: number;
  27374. /** Explicit coordinates mode */
  27375. static readonly TEXTURE_EXPLICIT_MODE: number;
  27376. /** Spherical coordinates mode */
  27377. static readonly TEXTURE_SPHERICAL_MODE: number;
  27378. /** Planar coordinates mode */
  27379. static readonly TEXTURE_PLANAR_MODE: number;
  27380. /** Cubic coordinates mode */
  27381. static readonly TEXTURE_CUBIC_MODE: number;
  27382. /** Projection coordinates mode */
  27383. static readonly TEXTURE_PROJECTION_MODE: number;
  27384. /** Skybox coordinates mode */
  27385. static readonly TEXTURE_SKYBOX_MODE: number;
  27386. /** Inverse Cubic coordinates mode */
  27387. static readonly TEXTURE_INVCUBIC_MODE: number;
  27388. /** Equirectangular coordinates mode */
  27389. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27390. /** Equirectangular Fixed coordinates mode */
  27391. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27392. /** Equirectangular Fixed Mirrored coordinates mode */
  27393. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27394. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27395. static readonly SCALEMODE_FLOOR: number;
  27396. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27397. static readonly SCALEMODE_NEAREST: number;
  27398. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27399. static readonly SCALEMODE_CEILING: number;
  27400. /**
  27401. * Returns the current npm package of the sdk
  27402. */
  27403. static readonly NpmPackage: string;
  27404. /**
  27405. * Returns the current version of the framework
  27406. */
  27407. static readonly Version: string;
  27408. /**
  27409. * Returns a string describing the current engine
  27410. */
  27411. readonly description: string;
  27412. /**
  27413. * Gets or sets the epsilon value used by collision engine
  27414. */
  27415. static CollisionsEpsilon: number;
  27416. /**
  27417. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27418. */
  27419. static ShadersRepository: string;
  27420. /**
  27421. * Method called to create the default loading screen.
  27422. * This can be overriden in your own app.
  27423. * @param canvas The rendering canvas element
  27424. * @returns The loading screen
  27425. */
  27426. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27427. /**
  27428. * Method called to create the default rescale post process on each engine.
  27429. */
  27430. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27431. /**
  27432. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27433. */
  27434. forcePOTTextures: boolean;
  27435. /**
  27436. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27437. */
  27438. isFullscreen: boolean;
  27439. /**
  27440. * Gets a boolean indicating if the pointer is currently locked
  27441. */
  27442. isPointerLock: boolean;
  27443. /**
  27444. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27445. */
  27446. cullBackFaces: boolean;
  27447. /**
  27448. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27449. */
  27450. renderEvenInBackground: boolean;
  27451. /**
  27452. * Gets or sets a boolean indicating that cache can be kept between frames
  27453. */
  27454. preventCacheWipeBetweenFrames: boolean;
  27455. /**
  27456. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27457. **/
  27458. enableOfflineSupport: boolean;
  27459. /**
  27460. * 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)
  27461. **/
  27462. disableManifestCheck: boolean;
  27463. /**
  27464. * Gets the list of created scenes
  27465. */
  27466. scenes: Scene[];
  27467. /**
  27468. * Event raised when a new scene is created
  27469. */
  27470. onNewSceneAddedObservable: Observable<Scene>;
  27471. /**
  27472. * Gets the list of created postprocesses
  27473. */
  27474. postProcesses: PostProcess[];
  27475. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27476. validateShaderPrograms: boolean;
  27477. /**
  27478. * Observable event triggered each time the rendering canvas is resized
  27479. */
  27480. onResizeObservable: Observable<Engine>;
  27481. /**
  27482. * Observable event triggered each time the canvas loses focus
  27483. */
  27484. onCanvasBlurObservable: Observable<Engine>;
  27485. /**
  27486. * Observable event triggered each time the canvas gains focus
  27487. */
  27488. onCanvasFocusObservable: Observable<Engine>;
  27489. /**
  27490. * Observable event triggered each time the canvas receives pointerout event
  27491. */
  27492. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27493. /**
  27494. * Observable event triggered before each texture is initialized
  27495. */
  27496. onBeforeTextureInitObservable: Observable<Texture>;
  27497. /**
  27498. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27499. */
  27500. disableUniformBuffers: boolean;
  27501. /** @hidden */
  27502. _uniformBuffers: UniformBuffer[];
  27503. /**
  27504. * Gets a boolean indicating that the engine supports uniform buffers
  27505. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27506. */
  27507. readonly supportsUniformBuffers: boolean;
  27508. /**
  27509. * Observable raised when the engine begins a new frame
  27510. */
  27511. onBeginFrameObservable: Observable<Engine>;
  27512. /**
  27513. * If set, will be used to request the next animation frame for the render loop
  27514. */
  27515. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27516. /**
  27517. * Observable raised when the engine ends the current frame
  27518. */
  27519. onEndFrameObservable: Observable<Engine>;
  27520. /**
  27521. * Observable raised when the engine is about to compile a shader
  27522. */
  27523. onBeforeShaderCompilationObservable: Observable<Engine>;
  27524. /**
  27525. * Observable raised when the engine has jsut compiled a shader
  27526. */
  27527. onAfterShaderCompilationObservable: Observable<Engine>;
  27528. /** @hidden */
  27529. _gl: WebGLRenderingContext;
  27530. private _renderingCanvas;
  27531. private _windowIsBackground;
  27532. private _webGLVersion;
  27533. protected _highPrecisionShadersAllowed: boolean;
  27534. /** @hidden */
  27535. readonly _shouldUseHighPrecisionShader: boolean;
  27536. /**
  27537. * Gets a boolean indicating that only power of 2 textures are supported
  27538. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27539. */
  27540. readonly needPOTTextures: boolean;
  27541. /** @hidden */
  27542. _badOS: boolean;
  27543. /** @hidden */
  27544. _badDesktopOS: boolean;
  27545. /**
  27546. * Gets the audio engine
  27547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27548. * @ignorenaming
  27549. */
  27550. static audioEngine: IAudioEngine;
  27551. /**
  27552. * Default AudioEngine factory responsible of creating the Audio Engine.
  27553. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27554. */
  27555. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27556. /**
  27557. * Default offline support factory responsible of creating a tool used to store data locally.
  27558. * By default, this will create a Database object if the workload has been embedded.
  27559. */
  27560. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27561. private _onFocus;
  27562. private _onBlur;
  27563. private _onCanvasPointerOut;
  27564. private _onCanvasBlur;
  27565. private _onCanvasFocus;
  27566. private _onFullscreenChange;
  27567. private _onPointerLockChange;
  27568. private _hardwareScalingLevel;
  27569. /** @hidden */
  27570. _caps: EngineCapabilities;
  27571. private _pointerLockRequested;
  27572. private _isStencilEnable;
  27573. private _colorWrite;
  27574. private _loadingScreen;
  27575. /** @hidden */
  27576. _drawCalls: PerfCounter;
  27577. private _glVersion;
  27578. private _glRenderer;
  27579. private _glVendor;
  27580. private _videoTextureSupported;
  27581. private _renderingQueueLaunched;
  27582. private _activeRenderLoops;
  27583. private _deterministicLockstep;
  27584. private _lockstepMaxSteps;
  27585. /**
  27586. * Observable signaled when a context lost event is raised
  27587. */
  27588. onContextLostObservable: Observable<Engine>;
  27589. /**
  27590. * Observable signaled when a context restored event is raised
  27591. */
  27592. onContextRestoredObservable: Observable<Engine>;
  27593. private _onContextLost;
  27594. private _onContextRestored;
  27595. private _contextWasLost;
  27596. /** @hidden */
  27597. _doNotHandleContextLost: boolean;
  27598. /**
  27599. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27600. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27601. */
  27602. doNotHandleContextLost: boolean;
  27603. private _performanceMonitor;
  27604. private _fps;
  27605. private _deltaTime;
  27606. /**
  27607. * Turn this value on if you want to pause FPS computation when in background
  27608. */
  27609. disablePerformanceMonitorInBackground: boolean;
  27610. /**
  27611. * Gets the performance monitor attached to this engine
  27612. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27613. */
  27614. readonly performanceMonitor: PerformanceMonitor;
  27615. /**
  27616. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27617. */
  27618. disableVertexArrayObjects: boolean;
  27619. /** @hidden */
  27620. protected _depthCullingState: _DepthCullingState;
  27621. /** @hidden */
  27622. protected _stencilState: _StencilState;
  27623. /** @hidden */
  27624. protected _alphaState: _AlphaState;
  27625. /** @hidden */
  27626. protected _alphaMode: number;
  27627. /** @hidden */
  27628. _internalTexturesCache: InternalTexture[];
  27629. /** @hidden */
  27630. protected _activeChannel: number;
  27631. private _currentTextureChannel;
  27632. /** @hidden */
  27633. protected _boundTexturesCache: {
  27634. [key: string]: Nullable<InternalTexture>;
  27635. };
  27636. /** @hidden */
  27637. protected _currentEffect: Nullable<Effect>;
  27638. /** @hidden */
  27639. protected _currentProgram: Nullable<WebGLProgram>;
  27640. private _compiledEffects;
  27641. private _vertexAttribArraysEnabled;
  27642. /** @hidden */
  27643. protected _cachedViewport: Nullable<Viewport>;
  27644. private _cachedVertexArrayObject;
  27645. /** @hidden */
  27646. protected _cachedVertexBuffers: any;
  27647. /** @hidden */
  27648. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27649. /** @hidden */
  27650. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27651. /** @hidden */
  27652. _currentRenderTarget: Nullable<InternalTexture>;
  27653. private _uintIndicesCurrentlySet;
  27654. private _currentBoundBuffer;
  27655. /** @hidden */
  27656. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27657. private _currentBufferPointers;
  27658. private _currentInstanceLocations;
  27659. private _currentInstanceBuffers;
  27660. private _textureUnits;
  27661. /** @hidden */
  27662. _workingCanvas: Nullable<HTMLCanvasElement>;
  27663. /** @hidden */
  27664. _workingContext: Nullable<CanvasRenderingContext2D>;
  27665. private _rescalePostProcess;
  27666. private _dummyFramebuffer;
  27667. private _externalData;
  27668. /** @hidden */
  27669. _bindedRenderFunction: any;
  27670. private _vaoRecordInProgress;
  27671. private _mustWipeVertexAttributes;
  27672. private _emptyTexture;
  27673. private _emptyCubeTexture;
  27674. private _emptyTexture3D;
  27675. /** @hidden */
  27676. _frameHandler: number;
  27677. private _nextFreeTextureSlots;
  27678. private _maxSimultaneousTextures;
  27679. private _activeRequests;
  27680. private _texturesSupported;
  27681. /** @hidden */
  27682. _textureFormatInUse: Nullable<string>;
  27683. /**
  27684. * Gets the list of texture formats supported
  27685. */
  27686. readonly texturesSupported: Array<string>;
  27687. /**
  27688. * Gets the list of texture formats in use
  27689. */
  27690. readonly textureFormatInUse: Nullable<string>;
  27691. /**
  27692. * Gets the current viewport
  27693. */
  27694. readonly currentViewport: Nullable<Viewport>;
  27695. /**
  27696. * Gets the default empty texture
  27697. */
  27698. readonly emptyTexture: InternalTexture;
  27699. /**
  27700. * Gets the default empty 3D texture
  27701. */
  27702. readonly emptyTexture3D: InternalTexture;
  27703. /**
  27704. * Gets the default empty cube texture
  27705. */
  27706. readonly emptyCubeTexture: InternalTexture;
  27707. /**
  27708. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27709. */
  27710. readonly premultipliedAlpha: boolean;
  27711. /**
  27712. * Creates a new engine
  27713. * @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
  27714. * @param antialias defines enable antialiasing (default: false)
  27715. * @param options defines further options to be sent to the getContext() function
  27716. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27717. */
  27718. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27719. /**
  27720. * Initializes a webVR display and starts listening to display change events
  27721. * The onVRDisplayChangedObservable will be notified upon these changes
  27722. * @returns The onVRDisplayChangedObservable
  27723. */
  27724. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27725. /** @hidden */
  27726. _prepareVRComponent(): void;
  27727. /** @hidden */
  27728. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27729. /** @hidden */
  27730. _submitVRFrame(): void;
  27731. /**
  27732. * Call this function to leave webVR mode
  27733. * Will do nothing if webVR is not supported or if there is no webVR device
  27734. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27735. */
  27736. disableVR(): void;
  27737. /**
  27738. * Gets a boolean indicating that the system is in VR mode and is presenting
  27739. * @returns true if VR mode is engaged
  27740. */
  27741. isVRPresenting(): boolean;
  27742. /** @hidden */
  27743. _requestVRFrame(): void;
  27744. private _disableTouchAction;
  27745. private _rebuildInternalTextures;
  27746. private _rebuildEffects;
  27747. /**
  27748. * Gets a boolean indicating if all created effects are ready
  27749. * @returns true if all effects are ready
  27750. */
  27751. areAllEffectsReady(): boolean;
  27752. private _rebuildBuffers;
  27753. private _initGLContext;
  27754. /**
  27755. * Gets version of the current webGL context
  27756. */
  27757. readonly webGLVersion: number;
  27758. /**
  27759. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27760. */
  27761. readonly isStencilEnable: boolean;
  27762. /** @hidden */
  27763. _prepareWorkingCanvas(): void;
  27764. /**
  27765. * Reset the texture cache to empty state
  27766. */
  27767. resetTextureCache(): void;
  27768. /**
  27769. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27770. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27771. * @returns true if engine is in deterministic lock step mode
  27772. */
  27773. isDeterministicLockStep(): boolean;
  27774. /**
  27775. * Gets the max steps when engine is running in deterministic lock step
  27776. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27777. * @returns the max steps
  27778. */
  27779. getLockstepMaxSteps(): number;
  27780. /**
  27781. * Gets an object containing information about the current webGL context
  27782. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27783. */
  27784. getGlInfo(): {
  27785. vendor: string;
  27786. renderer: string;
  27787. version: string;
  27788. };
  27789. /**
  27790. * Gets current aspect ratio
  27791. * @param camera defines the camera to use to get the aspect ratio
  27792. * @param useScreen defines if screen size must be used (or the current render target if any)
  27793. * @returns a number defining the aspect ratio
  27794. */
  27795. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27796. /**
  27797. * Gets current screen aspect ratio
  27798. * @returns a number defining the aspect ratio
  27799. */
  27800. getScreenAspectRatio(): number;
  27801. /**
  27802. * Gets the current render width
  27803. * @param useScreen defines if screen size must be used (or the current render target if any)
  27804. * @returns a number defining the current render width
  27805. */
  27806. getRenderWidth(useScreen?: boolean): number;
  27807. /**
  27808. * Gets the current render height
  27809. * @param useScreen defines if screen size must be used (or the current render target if any)
  27810. * @returns a number defining the current render height
  27811. */
  27812. getRenderHeight(useScreen?: boolean): number;
  27813. /**
  27814. * Gets the HTML canvas attached with the current webGL context
  27815. * @returns a HTML canvas
  27816. */
  27817. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27818. /**
  27819. * Gets the client rect of the HTML canvas attached with the current webGL context
  27820. * @returns a client rectanglee
  27821. */
  27822. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27823. /**
  27824. * Defines the hardware scaling level.
  27825. * By default the hardware scaling level is computed from the window device ratio.
  27826. * 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.
  27827. * @param level defines the level to use
  27828. */
  27829. setHardwareScalingLevel(level: number): void;
  27830. /**
  27831. * Gets the current hardware scaling level.
  27832. * By default the hardware scaling level is computed from the window device ratio.
  27833. * 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.
  27834. * @returns a number indicating the current hardware scaling level
  27835. */
  27836. getHardwareScalingLevel(): number;
  27837. /**
  27838. * Gets the list of loaded textures
  27839. * @returns an array containing all loaded textures
  27840. */
  27841. getLoadedTexturesCache(): InternalTexture[];
  27842. /**
  27843. * Gets the object containing all engine capabilities
  27844. * @returns the EngineCapabilities object
  27845. */
  27846. getCaps(): EngineCapabilities;
  27847. /**
  27848. * Gets the current depth function
  27849. * @returns a number defining the depth function
  27850. */
  27851. getDepthFunction(): Nullable<number>;
  27852. /**
  27853. * Sets the current depth function
  27854. * @param depthFunc defines the function to use
  27855. */
  27856. setDepthFunction(depthFunc: number): void;
  27857. /**
  27858. * Sets the current depth function to GREATER
  27859. */
  27860. setDepthFunctionToGreater(): void;
  27861. /**
  27862. * Sets the current depth function to GEQUAL
  27863. */
  27864. setDepthFunctionToGreaterOrEqual(): void;
  27865. /**
  27866. * Sets the current depth function to LESS
  27867. */
  27868. setDepthFunctionToLess(): void;
  27869. private _cachedStencilBuffer;
  27870. private _cachedStencilFunction;
  27871. private _cachedStencilMask;
  27872. private _cachedStencilOperationPass;
  27873. private _cachedStencilOperationFail;
  27874. private _cachedStencilOperationDepthFail;
  27875. private _cachedStencilReference;
  27876. /**
  27877. * Caches the the state of the stencil buffer
  27878. */
  27879. cacheStencilState(): void;
  27880. /**
  27881. * Restores the state of the stencil buffer
  27882. */
  27883. restoreStencilState(): void;
  27884. /**
  27885. * Sets the current depth function to LEQUAL
  27886. */
  27887. setDepthFunctionToLessOrEqual(): void;
  27888. /**
  27889. * Gets a boolean indicating if stencil buffer is enabled
  27890. * @returns the current stencil buffer state
  27891. */
  27892. getStencilBuffer(): boolean;
  27893. /**
  27894. * Enable or disable the stencil buffer
  27895. * @param enable defines if the stencil buffer must be enabled or disabled
  27896. */
  27897. setStencilBuffer(enable: boolean): void;
  27898. /**
  27899. * Gets the current stencil mask
  27900. * @returns a number defining the new stencil mask to use
  27901. */
  27902. getStencilMask(): number;
  27903. /**
  27904. * Sets the current stencil mask
  27905. * @param mask defines the new stencil mask to use
  27906. */
  27907. setStencilMask(mask: number): void;
  27908. /**
  27909. * Gets the current stencil function
  27910. * @returns a number defining the stencil function to use
  27911. */
  27912. getStencilFunction(): number;
  27913. /**
  27914. * Gets the current stencil reference value
  27915. * @returns a number defining the stencil reference value to use
  27916. */
  27917. getStencilFunctionReference(): number;
  27918. /**
  27919. * Gets the current stencil mask
  27920. * @returns a number defining the stencil mask to use
  27921. */
  27922. getStencilFunctionMask(): number;
  27923. /**
  27924. * Sets the current stencil function
  27925. * @param stencilFunc defines the new stencil function to use
  27926. */
  27927. setStencilFunction(stencilFunc: number): void;
  27928. /**
  27929. * Sets the current stencil reference
  27930. * @param reference defines the new stencil reference to use
  27931. */
  27932. setStencilFunctionReference(reference: number): void;
  27933. /**
  27934. * Sets the current stencil mask
  27935. * @param mask defines the new stencil mask to use
  27936. */
  27937. setStencilFunctionMask(mask: number): void;
  27938. /**
  27939. * Gets the current stencil operation when stencil fails
  27940. * @returns a number defining stencil operation to use when stencil fails
  27941. */
  27942. getStencilOperationFail(): number;
  27943. /**
  27944. * Gets the current stencil operation when depth fails
  27945. * @returns a number defining stencil operation to use when depth fails
  27946. */
  27947. getStencilOperationDepthFail(): number;
  27948. /**
  27949. * Gets the current stencil operation when stencil passes
  27950. * @returns a number defining stencil operation to use when stencil passes
  27951. */
  27952. getStencilOperationPass(): number;
  27953. /**
  27954. * Sets the stencil operation to use when stencil fails
  27955. * @param operation defines the stencil operation to use when stencil fails
  27956. */
  27957. setStencilOperationFail(operation: number): void;
  27958. /**
  27959. * Sets the stencil operation to use when depth fails
  27960. * @param operation defines the stencil operation to use when depth fails
  27961. */
  27962. setStencilOperationDepthFail(operation: number): void;
  27963. /**
  27964. * Sets the stencil operation to use when stencil passes
  27965. * @param operation defines the stencil operation to use when stencil passes
  27966. */
  27967. setStencilOperationPass(operation: number): void;
  27968. /**
  27969. * Sets a boolean indicating if the dithering state is enabled or disabled
  27970. * @param value defines the dithering state
  27971. */
  27972. setDitheringState(value: boolean): void;
  27973. /**
  27974. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27975. * @param value defines the rasterizer state
  27976. */
  27977. setRasterizerState(value: boolean): void;
  27978. /**
  27979. * stop executing a render loop function and remove it from the execution array
  27980. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27981. */
  27982. stopRenderLoop(renderFunction?: () => void): void;
  27983. /** @hidden */
  27984. _renderLoop(): void;
  27985. /**
  27986. * Register and execute a render loop. The engine can have more than one render function
  27987. * @param renderFunction defines the function to continuously execute
  27988. */
  27989. runRenderLoop(renderFunction: () => void): void;
  27990. /**
  27991. * Toggle full screen mode
  27992. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27993. */
  27994. switchFullscreen(requestPointerLock: boolean): void;
  27995. /**
  27996. * Enters full screen mode
  27997. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27998. */
  27999. enterFullscreen(requestPointerLock: boolean): void;
  28000. /**
  28001. * Exits full screen mode
  28002. */
  28003. exitFullscreen(): void;
  28004. /**
  28005. * Clear the current render buffer or the current render target (if any is set up)
  28006. * @param color defines the color to use
  28007. * @param backBuffer defines if the back buffer must be cleared
  28008. * @param depth defines if the depth buffer must be cleared
  28009. * @param stencil defines if the stencil buffer must be cleared
  28010. */
  28011. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28012. /**
  28013. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28014. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28015. * @param y defines the y-coordinate of the corner of the clear rectangle
  28016. * @param width defines the width of the clear rectangle
  28017. * @param height defines the height of the clear rectangle
  28018. * @param clearColor defines the clear color
  28019. */
  28020. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28021. /**
  28022. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28023. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28024. * @param y defines the y-coordinate of the corner of the clear rectangle
  28025. * @param width defines the width of the clear rectangle
  28026. * @param height defines the height of the clear rectangle
  28027. */
  28028. enableScissor(x: number, y: number, width: number, height: number): void;
  28029. /**
  28030. * Disable previously set scissor test rectangle
  28031. */
  28032. disableScissor(): void;
  28033. private _viewportCached;
  28034. /** @hidden */
  28035. _viewport(x: number, y: number, width: number, height: number): void;
  28036. /**
  28037. * Set the WebGL's viewport
  28038. * @param viewport defines the viewport element to be used
  28039. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28040. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28041. */
  28042. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28043. /**
  28044. * Directly set the WebGL Viewport
  28045. * @param x defines the x coordinate of the viewport (in screen space)
  28046. * @param y defines the y coordinate of the viewport (in screen space)
  28047. * @param width defines the width of the viewport (in screen space)
  28048. * @param height defines the height of the viewport (in screen space)
  28049. * @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
  28050. */
  28051. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28052. /**
  28053. * Begin a new frame
  28054. */
  28055. beginFrame(): void;
  28056. /**
  28057. * Enf the current frame
  28058. */
  28059. endFrame(): void;
  28060. /**
  28061. * Resize the view according to the canvas' size
  28062. */
  28063. resize(): void;
  28064. /**
  28065. * Force a specific size of the canvas
  28066. * @param width defines the new canvas' width
  28067. * @param height defines the new canvas' height
  28068. */
  28069. setSize(width: number, height: number): void;
  28070. /**
  28071. * Binds the frame buffer to the specified texture.
  28072. * @param texture The texture to render to or null for the default canvas
  28073. * @param faceIndex The face of the texture to render to in case of cube texture
  28074. * @param requiredWidth The width of the target to render to
  28075. * @param requiredHeight The height of the target to render to
  28076. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28077. * @param depthStencilTexture The depth stencil texture to use to render
  28078. * @param lodLevel defines le lod level to bind to the frame buffer
  28079. */
  28080. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28081. /** @hidden */
  28082. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28083. /**
  28084. * Unbind the current render target texture from the webGL context
  28085. * @param texture defines the render target texture to unbind
  28086. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28087. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28088. */
  28089. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28090. /**
  28091. * Force the mipmap generation for the given render target texture
  28092. * @param texture defines the render target texture to use
  28093. */
  28094. generateMipMapsForCubemap(texture: InternalTexture): void;
  28095. /**
  28096. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28097. */
  28098. flushFramebuffer(): void;
  28099. /**
  28100. * Unbind the current render target and bind the default framebuffer
  28101. */
  28102. restoreDefaultFramebuffer(): void;
  28103. /**
  28104. * Create an uniform buffer
  28105. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28106. * @param elements defines the content of the uniform buffer
  28107. * @returns the webGL uniform buffer
  28108. */
  28109. createUniformBuffer(elements: FloatArray): DataBuffer;
  28110. /**
  28111. * Create a dynamic uniform buffer
  28112. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28113. * @param elements defines the content of the uniform buffer
  28114. * @returns the webGL uniform buffer
  28115. */
  28116. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28117. /**
  28118. * Update an existing uniform buffer
  28119. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28120. * @param uniformBuffer defines the target uniform buffer
  28121. * @param elements defines the content to update
  28122. * @param offset defines the offset in the uniform buffer where update should start
  28123. * @param count defines the size of the data to update
  28124. */
  28125. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28126. private _resetVertexBufferBinding;
  28127. /**
  28128. * Creates a vertex buffer
  28129. * @param data the data for the vertex buffer
  28130. * @returns the new WebGL static buffer
  28131. */
  28132. createVertexBuffer(data: DataArray): DataBuffer;
  28133. /**
  28134. * Creates a dynamic vertex buffer
  28135. * @param data the data for the dynamic vertex buffer
  28136. * @returns the new WebGL dynamic buffer
  28137. */
  28138. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28139. /**
  28140. * Update a dynamic index buffer
  28141. * @param indexBuffer defines the target index buffer
  28142. * @param indices defines the data to update
  28143. * @param offset defines the offset in the target index buffer where update should start
  28144. */
  28145. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28146. /**
  28147. * Updates a dynamic vertex buffer.
  28148. * @param vertexBuffer the vertex buffer to update
  28149. * @param data the data used to update the vertex buffer
  28150. * @param byteOffset the byte offset of the data
  28151. * @param byteLength the byte length of the data
  28152. */
  28153. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28154. private _resetIndexBufferBinding;
  28155. /**
  28156. * Creates a new index buffer
  28157. * @param indices defines the content of the index buffer
  28158. * @param updatable defines if the index buffer must be updatable
  28159. * @returns a new webGL buffer
  28160. */
  28161. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28162. /**
  28163. * Bind a webGL buffer to the webGL context
  28164. * @param buffer defines the buffer to bind
  28165. */
  28166. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28167. /**
  28168. * Bind an uniform buffer to the current webGL context
  28169. * @param buffer defines the buffer to bind
  28170. */
  28171. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28172. /**
  28173. * Bind a buffer to the current webGL context at a given location
  28174. * @param buffer defines the buffer to bind
  28175. * @param location defines the index where to bind the buffer
  28176. */
  28177. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28178. /**
  28179. * Bind a specific block at a given index in a specific shader program
  28180. * @param pipelineContext defines the pipeline context to use
  28181. * @param blockName defines the block name
  28182. * @param index defines the index where to bind the block
  28183. */
  28184. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28185. private bindIndexBuffer;
  28186. private bindBuffer;
  28187. /**
  28188. * update the bound buffer with the given data
  28189. * @param data defines the data to update
  28190. */
  28191. updateArrayBuffer(data: Float32Array): void;
  28192. private _vertexAttribPointer;
  28193. private _bindIndexBufferWithCache;
  28194. private _bindVertexBuffersAttributes;
  28195. /**
  28196. * Records a vertex array object
  28197. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28198. * @param vertexBuffers defines the list of vertex buffers to store
  28199. * @param indexBuffer defines the index buffer to store
  28200. * @param effect defines the effect to store
  28201. * @returns the new vertex array object
  28202. */
  28203. recordVertexArrayObject(vertexBuffers: {
  28204. [key: string]: VertexBuffer;
  28205. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28206. /**
  28207. * Bind a specific vertex array object
  28208. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28209. * @param vertexArrayObject defines the vertex array object to bind
  28210. * @param indexBuffer defines the index buffer to bind
  28211. */
  28212. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28213. /**
  28214. * Bind webGl buffers directly to the webGL context
  28215. * @param vertexBuffer defines the vertex buffer to bind
  28216. * @param indexBuffer defines the index buffer to bind
  28217. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28218. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28219. * @param effect defines the effect associated with the vertex buffer
  28220. */
  28221. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28222. private _unbindVertexArrayObject;
  28223. /**
  28224. * Bind a list of vertex buffers to the webGL context
  28225. * @param vertexBuffers defines the list of vertex buffers to bind
  28226. * @param indexBuffer defines the index buffer to bind
  28227. * @param effect defines the effect associated with the vertex buffers
  28228. */
  28229. bindBuffers(vertexBuffers: {
  28230. [key: string]: Nullable<VertexBuffer>;
  28231. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28232. /**
  28233. * Unbind all instance attributes
  28234. */
  28235. unbindInstanceAttributes(): void;
  28236. /**
  28237. * Release and free the memory of a vertex array object
  28238. * @param vao defines the vertex array object to delete
  28239. */
  28240. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28241. /** @hidden */
  28242. _releaseBuffer(buffer: DataBuffer): boolean;
  28243. /**
  28244. * Creates a webGL buffer to use with instanciation
  28245. * @param capacity defines the size of the buffer
  28246. * @returns the webGL buffer
  28247. */
  28248. createInstancesBuffer(capacity: number): DataBuffer;
  28249. /**
  28250. * Delete a webGL buffer used with instanciation
  28251. * @param buffer defines the webGL buffer to delete
  28252. */
  28253. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28254. /**
  28255. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28256. * @param instancesBuffer defines the webGL buffer to update and bind
  28257. * @param data defines the data to store in the buffer
  28258. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28259. */
  28260. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28261. /**
  28262. * Apply all cached states (depth, culling, stencil and alpha)
  28263. */
  28264. applyStates(): void;
  28265. /**
  28266. * Send a draw order
  28267. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28268. * @param indexStart defines the starting index
  28269. * @param indexCount defines the number of index to draw
  28270. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28271. */
  28272. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28273. /**
  28274. * Draw a list of points
  28275. * @param verticesStart defines the index of first vertex to draw
  28276. * @param verticesCount defines the count of vertices to draw
  28277. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28278. */
  28279. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28280. /**
  28281. * Draw a list of unindexed primitives
  28282. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28283. * @param verticesStart defines the index of first vertex to draw
  28284. * @param verticesCount defines the count of vertices to draw
  28285. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28286. */
  28287. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28288. /**
  28289. * Draw a list of indexed primitives
  28290. * @param fillMode defines the primitive to use
  28291. * @param indexStart defines the starting index
  28292. * @param indexCount defines the number of index to draw
  28293. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28294. */
  28295. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28296. /**
  28297. * Draw a list of unindexed primitives
  28298. * @param fillMode defines the primitive to use
  28299. * @param verticesStart defines the index of first vertex to draw
  28300. * @param verticesCount defines the count of vertices to draw
  28301. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28302. */
  28303. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28304. private _drawMode;
  28305. /** @hidden */
  28306. _releaseEffect(effect: Effect): void;
  28307. /** @hidden */
  28308. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28309. /**
  28310. * Create a new effect (used to store vertex/fragment shaders)
  28311. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28312. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28313. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28314. * @param samplers defines an array of string used to represent textures
  28315. * @param defines defines the string containing the defines to use to compile the shaders
  28316. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28317. * @param onCompiled defines a function to call when the effect creation is successful
  28318. * @param onError defines a function to call when the effect creation has failed
  28319. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28320. * @returns the new Effect
  28321. */
  28322. 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;
  28323. private _compileShader;
  28324. private _compileRawShader;
  28325. /**
  28326. * Directly creates a webGL program
  28327. * @param pipelineContext defines the pipeline context to attach to
  28328. * @param vertexCode defines the vertex shader code to use
  28329. * @param fragmentCode defines the fragment shader code to use
  28330. * @param context defines the webGL context to use (if not set, the current one will be used)
  28331. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28332. * @returns the new webGL program
  28333. */
  28334. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28335. /**
  28336. * Creates a webGL program
  28337. * @param pipelineContext defines the pipeline context to attach to
  28338. * @param vertexCode defines the vertex shader code to use
  28339. * @param fragmentCode defines the fragment shader code to use
  28340. * @param defines defines the string containing the defines to use to compile the shaders
  28341. * @param context defines the webGL context to use (if not set, the current one will be used)
  28342. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28343. * @returns the new webGL program
  28344. */
  28345. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28346. /**
  28347. * Creates a new pipeline context
  28348. * @returns the new pipeline
  28349. */
  28350. createPipelineContext(): WebGLPipelineContext;
  28351. private _createShaderProgram;
  28352. private _finalizePipelineContext;
  28353. /** @hidden */
  28354. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28355. /** @hidden */
  28356. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28357. /** @hidden */
  28358. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28359. /**
  28360. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28361. * @param pipelineContext defines the pipeline context to use
  28362. * @param uniformsNames defines the list of uniform names
  28363. * @returns an array of webGL uniform locations
  28364. */
  28365. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28366. /**
  28367. * Gets the lsit of active attributes for a given webGL program
  28368. * @param pipelineContext defines the pipeline context to use
  28369. * @param attributesNames defines the list of attribute names to get
  28370. * @returns an array of indices indicating the offset of each attribute
  28371. */
  28372. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28373. /**
  28374. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28375. * @param effect defines the effect to activate
  28376. */
  28377. enableEffect(effect: Nullable<Effect>): void;
  28378. /**
  28379. * Set the value of an uniform to an array of int32
  28380. * @param uniform defines the webGL uniform location where to store the value
  28381. * @param array defines the array of int32 to store
  28382. */
  28383. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28384. /**
  28385. * Set the value of an uniform to an array of int32 (stored as vec2)
  28386. * @param uniform defines the webGL uniform location where to store the value
  28387. * @param array defines the array of int32 to store
  28388. */
  28389. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28390. /**
  28391. * Set the value of an uniform to an array of int32 (stored as vec3)
  28392. * @param uniform defines the webGL uniform location where to store the value
  28393. * @param array defines the array of int32 to store
  28394. */
  28395. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28396. /**
  28397. * Set the value of an uniform to an array of int32 (stored as vec4)
  28398. * @param uniform defines the webGL uniform location where to store the value
  28399. * @param array defines the array of int32 to store
  28400. */
  28401. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28402. /**
  28403. * Set the value of an uniform to an array of float32
  28404. * @param uniform defines the webGL uniform location where to store the value
  28405. * @param array defines the array of float32 to store
  28406. */
  28407. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28408. /**
  28409. * Set the value of an uniform to an array of float32 (stored as vec2)
  28410. * @param uniform defines the webGL uniform location where to store the value
  28411. * @param array defines the array of float32 to store
  28412. */
  28413. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28414. /**
  28415. * Set the value of an uniform to an array of float32 (stored as vec3)
  28416. * @param uniform defines the webGL uniform location where to store the value
  28417. * @param array defines the array of float32 to store
  28418. */
  28419. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28420. /**
  28421. * Set the value of an uniform to an array of float32 (stored as vec4)
  28422. * @param uniform defines the webGL uniform location where to store the value
  28423. * @param array defines the array of float32 to store
  28424. */
  28425. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28426. /**
  28427. * Set the value of an uniform to an array of number
  28428. * @param uniform defines the webGL uniform location where to store the value
  28429. * @param array defines the array of number to store
  28430. */
  28431. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28432. /**
  28433. * Set the value of an uniform to an array of number (stored as vec2)
  28434. * @param uniform defines the webGL uniform location where to store the value
  28435. * @param array defines the array of number to store
  28436. */
  28437. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28438. /**
  28439. * Set the value of an uniform to an array of number (stored as vec3)
  28440. * @param uniform defines the webGL uniform location where to store the value
  28441. * @param array defines the array of number to store
  28442. */
  28443. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28444. /**
  28445. * Set the value of an uniform to an array of number (stored as vec4)
  28446. * @param uniform defines the webGL uniform location where to store the value
  28447. * @param array defines the array of number to store
  28448. */
  28449. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28450. /**
  28451. * Set the value of an uniform to an array of float32 (stored as matrices)
  28452. * @param uniform defines the webGL uniform location where to store the value
  28453. * @param matrices defines the array of float32 to store
  28454. */
  28455. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28456. /**
  28457. * Set the value of an uniform to a matrix
  28458. * @param uniform defines the webGL uniform location where to store the value
  28459. * @param matrix defines the matrix to store
  28460. */
  28461. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28462. /**
  28463. * Set the value of an uniform to a matrix (3x3)
  28464. * @param uniform defines the webGL uniform location where to store the value
  28465. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28466. */
  28467. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28468. /**
  28469. * Set the value of an uniform to a matrix (2x2)
  28470. * @param uniform defines the webGL uniform location where to store the value
  28471. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28472. */
  28473. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28474. /**
  28475. * Set the value of an uniform to a number (int)
  28476. * @param uniform defines the webGL uniform location where to store the value
  28477. * @param value defines the int number to store
  28478. */
  28479. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28480. /**
  28481. * Set the value of an uniform to a number (float)
  28482. * @param uniform defines the webGL uniform location where to store the value
  28483. * @param value defines the float number to store
  28484. */
  28485. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28486. /**
  28487. * Set the value of an uniform to a vec2
  28488. * @param uniform defines the webGL uniform location where to store the value
  28489. * @param x defines the 1st component of the value
  28490. * @param y defines the 2nd component of the value
  28491. */
  28492. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28493. /**
  28494. * Set the value of an uniform to a vec3
  28495. * @param uniform defines the webGL uniform location where to store the value
  28496. * @param x defines the 1st component of the value
  28497. * @param y defines the 2nd component of the value
  28498. * @param z defines the 3rd component of the value
  28499. */
  28500. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28501. /**
  28502. * Set the value of an uniform to a boolean
  28503. * @param uniform defines the webGL uniform location where to store the value
  28504. * @param bool defines the boolean to store
  28505. */
  28506. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28507. /**
  28508. * Set the value of an uniform to a vec4
  28509. * @param uniform defines the webGL uniform location where to store the value
  28510. * @param x defines the 1st component of the value
  28511. * @param y defines the 2nd component of the value
  28512. * @param z defines the 3rd component of the value
  28513. * @param w defines the 4th component of the value
  28514. */
  28515. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28516. /**
  28517. * Set the value of an uniform to a Color3
  28518. * @param uniform defines the webGL uniform location where to store the value
  28519. * @param color3 defines the color to store
  28520. */
  28521. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28522. /**
  28523. * Set the value of an uniform to a Color3 and an alpha value
  28524. * @param uniform defines the webGL uniform location where to store the value
  28525. * @param color3 defines the color to store
  28526. * @param alpha defines the alpha component to store
  28527. */
  28528. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28529. /**
  28530. * Sets a Color4 on a uniform variable
  28531. * @param uniform defines the uniform location
  28532. * @param color4 defines the value to be set
  28533. */
  28534. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28535. /**
  28536. * Set various states to the webGL context
  28537. * @param culling defines backface culling state
  28538. * @param zOffset defines the value to apply to zOffset (0 by default)
  28539. * @param force defines if states must be applied even if cache is up to date
  28540. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28541. */
  28542. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28543. /**
  28544. * Set the z offset to apply to current rendering
  28545. * @param value defines the offset to apply
  28546. */
  28547. setZOffset(value: number): void;
  28548. /**
  28549. * Gets the current value of the zOffset
  28550. * @returns the current zOffset state
  28551. */
  28552. getZOffset(): number;
  28553. /**
  28554. * Enable or disable depth buffering
  28555. * @param enable defines the state to set
  28556. */
  28557. setDepthBuffer(enable: boolean): void;
  28558. /**
  28559. * Gets a boolean indicating if depth writing is enabled
  28560. * @returns the current depth writing state
  28561. */
  28562. getDepthWrite(): boolean;
  28563. /**
  28564. * Enable or disable depth writing
  28565. * @param enable defines the state to set
  28566. */
  28567. setDepthWrite(enable: boolean): void;
  28568. /**
  28569. * Enable or disable color writing
  28570. * @param enable defines the state to set
  28571. */
  28572. setColorWrite(enable: boolean): void;
  28573. /**
  28574. * Gets a boolean indicating if color writing is enabled
  28575. * @returns the current color writing state
  28576. */
  28577. getColorWrite(): boolean;
  28578. /**
  28579. * Sets alpha constants used by some alpha blending modes
  28580. * @param r defines the red component
  28581. * @param g defines the green component
  28582. * @param b defines the blue component
  28583. * @param a defines the alpha component
  28584. */
  28585. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28586. /**
  28587. * Sets the current alpha mode
  28588. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28589. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28590. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28591. */
  28592. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28593. /**
  28594. * Gets the current alpha mode
  28595. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28596. * @returns the current alpha mode
  28597. */
  28598. getAlphaMode(): number;
  28599. /**
  28600. * Clears the list of texture accessible through engine.
  28601. * This can help preventing texture load conflict due to name collision.
  28602. */
  28603. clearInternalTexturesCache(): void;
  28604. /**
  28605. * Force the entire cache to be cleared
  28606. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28607. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28608. */
  28609. wipeCaches(bruteForce?: boolean): void;
  28610. /**
  28611. * Set the compressed texture format to use, based on the formats you have, and the formats
  28612. * supported by the hardware / browser.
  28613. *
  28614. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28615. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28616. * to API arguments needed to compressed textures. This puts the burden on the container
  28617. * generator to house the arcane code for determining these for current & future formats.
  28618. *
  28619. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28620. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28621. *
  28622. * Note: The result of this call is not taken into account when a texture is base64.
  28623. *
  28624. * @param formatsAvailable defines the list of those format families you have created
  28625. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28626. *
  28627. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28628. * @returns The extension selected.
  28629. */
  28630. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28631. /** @hidden */
  28632. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28633. min: number;
  28634. mag: number;
  28635. };
  28636. /** @hidden */
  28637. _createTexture(): WebGLTexture;
  28638. /**
  28639. * Usually called from Texture.ts.
  28640. * Passed information to create a WebGLTexture
  28641. * @param urlArg defines a value which contains one of the following:
  28642. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28643. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28644. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28645. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28646. * @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)
  28647. * @param scene needed for loading to the correct scene
  28648. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28649. * @param onLoad optional callback to be called upon successful completion
  28650. * @param onError optional callback to be called upon failure
  28651. * @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
  28652. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28653. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28654. * @param forcedExtension defines the extension to use to pick the right loader
  28655. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28656. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28657. */
  28658. 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;
  28659. private _rescaleTexture;
  28660. private _unpackFlipYCached;
  28661. /**
  28662. * In case you are sharing the context with other applications, it might
  28663. * be interested to not cache the unpack flip y state to ensure a consistent
  28664. * value would be set.
  28665. */
  28666. enableUnpackFlipYCached: boolean;
  28667. /** @hidden */
  28668. _unpackFlipY(value: boolean): void;
  28669. /** @hidden */
  28670. _getUnpackAlignement(): number;
  28671. /**
  28672. * Creates a dynamic texture
  28673. * @param width defines the width of the texture
  28674. * @param height defines the height of the texture
  28675. * @param generateMipMaps defines if the engine should generate the mip levels
  28676. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28677. * @returns the dynamic texture inside an InternalTexture
  28678. */
  28679. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28680. /**
  28681. * Update the sampling mode of a given texture
  28682. * @param samplingMode defines the required sampling mode
  28683. * @param texture defines the texture to update
  28684. */
  28685. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28686. /**
  28687. * Update the content of a dynamic texture
  28688. * @param texture defines the texture to update
  28689. * @param canvas defines the canvas containing the source
  28690. * @param invertY defines if data must be stored with Y axis inverted
  28691. * @param premulAlpha defines if alpha is stored as premultiplied
  28692. * @param format defines the format of the data
  28693. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28694. */
  28695. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28696. /**
  28697. * Update a video texture
  28698. * @param texture defines the texture to update
  28699. * @param video defines the video element to use
  28700. * @param invertY defines if data must be stored with Y axis inverted
  28701. */
  28702. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28703. /**
  28704. * Updates a depth texture Comparison Mode and Function.
  28705. * If the comparison Function is equal to 0, the mode will be set to none.
  28706. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28707. * @param texture The texture to set the comparison function for
  28708. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28709. */
  28710. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28711. /** @hidden */
  28712. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28713. width: number;
  28714. height: number;
  28715. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28716. /**
  28717. * Creates a depth stencil texture.
  28718. * This is only available in WebGL 2 or with the depth texture extension available.
  28719. * @param size The size of face edge in the texture.
  28720. * @param options The options defining the texture.
  28721. * @returns The texture
  28722. */
  28723. createDepthStencilTexture(size: number | {
  28724. width: number;
  28725. height: number;
  28726. }, options: DepthTextureCreationOptions): InternalTexture;
  28727. /**
  28728. * Creates a depth stencil texture.
  28729. * This is only available in WebGL 2 or with the depth texture extension available.
  28730. * @param size The size of face edge in the texture.
  28731. * @param options The options defining the texture.
  28732. * @returns The texture
  28733. */
  28734. private _createDepthStencilTexture;
  28735. /**
  28736. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28737. * @param renderTarget The render target to set the frame buffer for
  28738. */
  28739. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28740. /**
  28741. * Creates a new render target texture
  28742. * @param size defines the size of the texture
  28743. * @param options defines the options used to create the texture
  28744. * @returns a new render target texture stored in an InternalTexture
  28745. */
  28746. createRenderTargetTexture(size: number | {
  28747. width: number;
  28748. height: number;
  28749. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28750. /** @hidden */
  28751. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28752. /**
  28753. * Updates the sample count of a render target texture
  28754. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28755. * @param texture defines the texture to update
  28756. * @param samples defines the sample count to set
  28757. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28758. */
  28759. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28760. /** @hidden */
  28761. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28762. /** @hidden */
  28763. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28764. /** @hidden */
  28765. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28766. /** @hidden */
  28767. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28768. /**
  28769. * @hidden
  28770. */
  28771. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28772. private _prepareWebGLTextureContinuation;
  28773. private _prepareWebGLTexture;
  28774. /** @hidden */
  28775. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28776. /** @hidden */
  28777. _releaseFramebufferObjects(texture: InternalTexture): void;
  28778. /** @hidden */
  28779. _releaseTexture(texture: InternalTexture): void;
  28780. private setProgram;
  28781. private _boundUniforms;
  28782. /**
  28783. * Binds an effect to the webGL context
  28784. * @param effect defines the effect to bind
  28785. */
  28786. bindSamplers(effect: Effect): void;
  28787. private _activateCurrentTexture;
  28788. /** @hidden */
  28789. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28790. /** @hidden */
  28791. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28792. /**
  28793. * Sets a texture to the webGL context from a postprocess
  28794. * @param channel defines the channel to use
  28795. * @param postProcess defines the source postprocess
  28796. */
  28797. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28798. /**
  28799. * Binds the output of the passed in post process to the texture channel specified
  28800. * @param channel The channel the texture should be bound to
  28801. * @param postProcess The post process which's output should be bound
  28802. */
  28803. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28804. /**
  28805. * Unbind all textures from the webGL context
  28806. */
  28807. unbindAllTextures(): void;
  28808. /**
  28809. * Sets a texture to the according uniform.
  28810. * @param channel The texture channel
  28811. * @param uniform The uniform to set
  28812. * @param texture The texture to apply
  28813. */
  28814. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28815. /**
  28816. * Sets a depth stencil texture from a render target to the according uniform.
  28817. * @param channel The texture channel
  28818. * @param uniform The uniform to set
  28819. * @param texture The render target texture containing the depth stencil texture to apply
  28820. */
  28821. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28822. private _bindSamplerUniformToChannel;
  28823. private _getTextureWrapMode;
  28824. private _setTexture;
  28825. /**
  28826. * Sets an array of texture to the webGL context
  28827. * @param channel defines the channel where the texture array must be set
  28828. * @param uniform defines the associated uniform location
  28829. * @param textures defines the array of textures to bind
  28830. */
  28831. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28832. /** @hidden */
  28833. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28834. private _setTextureParameterFloat;
  28835. private _setTextureParameterInteger;
  28836. /**
  28837. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28838. * @param x defines the x coordinate of the rectangle where pixels must be read
  28839. * @param y defines the y coordinate of the rectangle where pixels must be read
  28840. * @param width defines the width of the rectangle where pixels must be read
  28841. * @param height defines the height of the rectangle where pixels must be read
  28842. * @returns a Uint8Array containing RGBA colors
  28843. */
  28844. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28845. /**
  28846. * Add an externaly attached data from its key.
  28847. * This method call will fail and return false, if such key already exists.
  28848. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28849. * @param key the unique key that identifies the data
  28850. * @param data the data object to associate to the key for this Engine instance
  28851. * @return true if no such key were already present and the data was added successfully, false otherwise
  28852. */
  28853. addExternalData<T>(key: string, data: T): boolean;
  28854. /**
  28855. * Get an externaly attached data from its key
  28856. * @param key the unique key that identifies the data
  28857. * @return the associated data, if present (can be null), or undefined if not present
  28858. */
  28859. getExternalData<T>(key: string): T;
  28860. /**
  28861. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28862. * @param key the unique key that identifies the data
  28863. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28864. * @return the associated data, can be null if the factory returned null.
  28865. */
  28866. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28867. /**
  28868. * Remove an externaly attached data from the Engine instance
  28869. * @param key the unique key that identifies the data
  28870. * @return true if the data was successfully removed, false if it doesn't exist
  28871. */
  28872. removeExternalData(key: string): boolean;
  28873. /**
  28874. * Unbind all vertex attributes from the webGL context
  28875. */
  28876. unbindAllAttributes(): void;
  28877. /**
  28878. * 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
  28879. */
  28880. releaseEffects(): void;
  28881. /**
  28882. * Dispose and release all associated resources
  28883. */
  28884. dispose(): void;
  28885. /**
  28886. * Display the loading screen
  28887. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28888. */
  28889. displayLoadingUI(): void;
  28890. /**
  28891. * Hide the loading screen
  28892. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28893. */
  28894. hideLoadingUI(): void;
  28895. /**
  28896. * Gets the current loading screen object
  28897. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28898. */
  28899. /**
  28900. * Sets the current loading screen object
  28901. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28902. */
  28903. loadingScreen: ILoadingScreen;
  28904. /**
  28905. * Sets the current loading screen text
  28906. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28907. */
  28908. loadingUIText: string;
  28909. /**
  28910. * Sets the current loading screen background color
  28911. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28912. */
  28913. loadingUIBackgroundColor: string;
  28914. /**
  28915. * Attach a new callback raised when context lost event is fired
  28916. * @param callback defines the callback to call
  28917. */
  28918. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28919. /**
  28920. * Attach a new callback raised when context restored event is fired
  28921. * @param callback defines the callback to call
  28922. */
  28923. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28924. /**
  28925. * Gets the source code of the vertex shader associated with a specific webGL program
  28926. * @param program defines the program to use
  28927. * @returns a string containing the source code of the vertex shader associated with the program
  28928. */
  28929. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28930. /**
  28931. * Gets the source code of the fragment shader associated with a specific webGL program
  28932. * @param program defines the program to use
  28933. * @returns a string containing the source code of the fragment shader associated with the program
  28934. */
  28935. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28936. /**
  28937. * Get the current error code of the webGL context
  28938. * @returns the error code
  28939. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28940. */
  28941. getError(): number;
  28942. /**
  28943. * Gets the current framerate
  28944. * @returns a number representing the framerate
  28945. */
  28946. getFps(): number;
  28947. /**
  28948. * Gets the time spent between current and previous frame
  28949. * @returns a number representing the delta time in ms
  28950. */
  28951. getDeltaTime(): number;
  28952. private _measureFps;
  28953. /** @hidden */
  28954. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28955. private _canRenderToFloatFramebuffer;
  28956. private _canRenderToHalfFloatFramebuffer;
  28957. private _canRenderToFramebuffer;
  28958. /** @hidden */
  28959. _getWebGLTextureType(type: number): number;
  28960. /** @hidden */
  28961. _getInternalFormat(format: number): number;
  28962. /** @hidden */
  28963. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28964. /** @hidden */
  28965. _getRGBAMultiSampleBufferFormat(type: number): number;
  28966. /** @hidden */
  28967. _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;
  28968. /** @hidden */
  28969. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28970. /**
  28971. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28972. * @returns true if the engine can be created
  28973. * @ignorenaming
  28974. */
  28975. static isSupported(): boolean;
  28976. }
  28977. }
  28978. declare module BABYLON {
  28979. /**
  28980. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28981. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28982. */
  28983. export class EffectFallbacks {
  28984. private _defines;
  28985. private _currentRank;
  28986. private _maxRank;
  28987. private _mesh;
  28988. /**
  28989. * Removes the fallback from the bound mesh.
  28990. */
  28991. unBindMesh(): void;
  28992. /**
  28993. * Adds a fallback on the specified property.
  28994. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28995. * @param define The name of the define in the shader
  28996. */
  28997. addFallback(rank: number, define: string): void;
  28998. /**
  28999. * Sets the mesh to use CPU skinning when needing to fallback.
  29000. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29001. * @param mesh The mesh to use the fallbacks.
  29002. */
  29003. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29004. /**
  29005. * Checks to see if more fallbacks are still availible.
  29006. */
  29007. readonly isMoreFallbacks: boolean;
  29008. /**
  29009. * Removes the defines that shoould be removed when falling back.
  29010. * @param currentDefines defines the current define statements for the shader.
  29011. * @param effect defines the current effect we try to compile
  29012. * @returns The resulting defines with defines of the current rank removed.
  29013. */
  29014. reduce(currentDefines: string, effect: Effect): string;
  29015. }
  29016. /**
  29017. * Options to be used when creating an effect.
  29018. */
  29019. export class EffectCreationOptions {
  29020. /**
  29021. * Atrributes that will be used in the shader.
  29022. */
  29023. attributes: string[];
  29024. /**
  29025. * Uniform varible names that will be set in the shader.
  29026. */
  29027. uniformsNames: string[];
  29028. /**
  29029. * Uniform buffer varible names that will be set in the shader.
  29030. */
  29031. uniformBuffersNames: string[];
  29032. /**
  29033. * Sampler texture variable names that will be set in the shader.
  29034. */
  29035. samplers: string[];
  29036. /**
  29037. * Define statements that will be set in the shader.
  29038. */
  29039. defines: any;
  29040. /**
  29041. * Possible fallbacks for this effect to improve performance when needed.
  29042. */
  29043. fallbacks: Nullable<EffectFallbacks>;
  29044. /**
  29045. * Callback that will be called when the shader is compiled.
  29046. */
  29047. onCompiled: Nullable<(effect: Effect) => void>;
  29048. /**
  29049. * Callback that will be called if an error occurs during shader compilation.
  29050. */
  29051. onError: Nullable<(effect: Effect, errors: string) => void>;
  29052. /**
  29053. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29054. */
  29055. indexParameters: any;
  29056. /**
  29057. * Max number of lights that can be used in the shader.
  29058. */
  29059. maxSimultaneousLights: number;
  29060. /**
  29061. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29062. */
  29063. transformFeedbackVaryings: Nullable<string[]>;
  29064. }
  29065. /**
  29066. * Effect containing vertex and fragment shader that can be executed on an object.
  29067. */
  29068. export class Effect implements IDisposable {
  29069. /**
  29070. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29071. */
  29072. static ShadersRepository: string;
  29073. /**
  29074. * Name of the effect.
  29075. */
  29076. name: any;
  29077. /**
  29078. * String container all the define statements that should be set on the shader.
  29079. */
  29080. defines: string;
  29081. /**
  29082. * Callback that will be called when the shader is compiled.
  29083. */
  29084. onCompiled: Nullable<(effect: Effect) => void>;
  29085. /**
  29086. * Callback that will be called if an error occurs during shader compilation.
  29087. */
  29088. onError: Nullable<(effect: Effect, errors: string) => void>;
  29089. /**
  29090. * Callback that will be called when effect is bound.
  29091. */
  29092. onBind: Nullable<(effect: Effect) => void>;
  29093. /**
  29094. * Unique ID of the effect.
  29095. */
  29096. uniqueId: number;
  29097. /**
  29098. * Observable that will be called when the shader is compiled.
  29099. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29100. */
  29101. onCompileObservable: Observable<Effect>;
  29102. /**
  29103. * Observable that will be called if an error occurs during shader compilation.
  29104. */
  29105. onErrorObservable: Observable<Effect>;
  29106. /** @hidden */
  29107. _onBindObservable: Nullable<Observable<Effect>>;
  29108. /**
  29109. * Observable that will be called when effect is bound.
  29110. */
  29111. readonly onBindObservable: Observable<Effect>;
  29112. /** @hidden */
  29113. _bonesComputationForcedToCPU: boolean;
  29114. private static _uniqueIdSeed;
  29115. private _engine;
  29116. private _uniformBuffersNames;
  29117. private _uniformsNames;
  29118. private _samplerList;
  29119. private _samplers;
  29120. private _isReady;
  29121. private _compilationError;
  29122. private _attributesNames;
  29123. private _attributes;
  29124. private _uniforms;
  29125. /**
  29126. * Key for the effect.
  29127. * @hidden
  29128. */
  29129. _key: string;
  29130. private _indexParameters;
  29131. private _fallbacks;
  29132. private _vertexSourceCode;
  29133. private _fragmentSourceCode;
  29134. private _vertexSourceCodeOverride;
  29135. private _fragmentSourceCodeOverride;
  29136. private _transformFeedbackVaryings;
  29137. /**
  29138. * Compiled shader to webGL program.
  29139. * @hidden
  29140. */
  29141. _pipelineContext: Nullable<IPipelineContext>;
  29142. private _valueCache;
  29143. private static _baseCache;
  29144. /**
  29145. * Instantiates an effect.
  29146. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29147. * @param baseName Name of the effect.
  29148. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29149. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29150. * @param samplers List of sampler variables that will be passed to the shader.
  29151. * @param engine Engine to be used to render the effect
  29152. * @param defines Define statements to be added to the shader.
  29153. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29154. * @param onCompiled Callback that will be called when the shader is compiled.
  29155. * @param onError Callback that will be called if an error occurs during shader compilation.
  29156. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29157. */
  29158. 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);
  29159. /**
  29160. * Unique key for this effect
  29161. */
  29162. readonly key: string;
  29163. /**
  29164. * If the effect has been compiled and prepared.
  29165. * @returns if the effect is compiled and prepared.
  29166. */
  29167. isReady(): boolean;
  29168. /**
  29169. * The engine the effect was initialized with.
  29170. * @returns the engine.
  29171. */
  29172. getEngine(): Engine;
  29173. /**
  29174. * The pipeline context for this effect
  29175. * @returns the associated pipeline context
  29176. */
  29177. getPipelineContext(): Nullable<IPipelineContext>;
  29178. /**
  29179. * The set of names of attribute variables for the shader.
  29180. * @returns An array of attribute names.
  29181. */
  29182. getAttributesNames(): string[];
  29183. /**
  29184. * Returns the attribute at the given index.
  29185. * @param index The index of the attribute.
  29186. * @returns The location of the attribute.
  29187. */
  29188. getAttributeLocation(index: number): number;
  29189. /**
  29190. * Returns the attribute based on the name of the variable.
  29191. * @param name of the attribute to look up.
  29192. * @returns the attribute location.
  29193. */
  29194. getAttributeLocationByName(name: string): number;
  29195. /**
  29196. * The number of attributes.
  29197. * @returns the numnber of attributes.
  29198. */
  29199. getAttributesCount(): number;
  29200. /**
  29201. * Gets the index of a uniform variable.
  29202. * @param uniformName of the uniform to look up.
  29203. * @returns the index.
  29204. */
  29205. getUniformIndex(uniformName: string): number;
  29206. /**
  29207. * Returns the attribute based on the name of the variable.
  29208. * @param uniformName of the uniform to look up.
  29209. * @returns the location of the uniform.
  29210. */
  29211. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29212. /**
  29213. * Returns an array of sampler variable names
  29214. * @returns The array of sampler variable neames.
  29215. */
  29216. getSamplers(): string[];
  29217. /**
  29218. * The error from the last compilation.
  29219. * @returns the error string.
  29220. */
  29221. getCompilationError(): string;
  29222. /**
  29223. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29224. * @param func The callback to be used.
  29225. */
  29226. executeWhenCompiled(func: (effect: Effect) => void): void;
  29227. private _checkIsReady;
  29228. /** @hidden */
  29229. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29230. /** @hidden */
  29231. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29232. /** @hidden */
  29233. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29234. private _processShaderConversion;
  29235. private _processIncludes;
  29236. private _processPrecision;
  29237. /**
  29238. * Recompiles the webGL program
  29239. * @param vertexSourceCode The source code for the vertex shader.
  29240. * @param fragmentSourceCode The source code for the fragment shader.
  29241. * @param onCompiled Callback called when completed.
  29242. * @param onError Callback called on error.
  29243. * @hidden
  29244. */
  29245. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29246. /**
  29247. * Prepares the effect
  29248. * @hidden
  29249. */
  29250. _prepareEffect(): void;
  29251. /**
  29252. * Checks if the effect is supported. (Must be called after compilation)
  29253. */
  29254. readonly isSupported: boolean;
  29255. /**
  29256. * Binds a texture to the engine to be used as output of the shader.
  29257. * @param channel Name of the output variable.
  29258. * @param texture Texture to bind.
  29259. * @hidden
  29260. */
  29261. _bindTexture(channel: string, texture: InternalTexture): void;
  29262. /**
  29263. * Sets a texture on the engine to be used in the shader.
  29264. * @param channel Name of the sampler variable.
  29265. * @param texture Texture to set.
  29266. */
  29267. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29268. /**
  29269. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29270. * @param channel Name of the sampler variable.
  29271. * @param texture Texture to set.
  29272. */
  29273. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29274. /**
  29275. * Sets an array of textures on the engine to be used in the shader.
  29276. * @param channel Name of the variable.
  29277. * @param textures Textures to set.
  29278. */
  29279. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29280. /**
  29281. * 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)
  29282. * @param channel Name of the sampler variable.
  29283. * @param postProcess Post process to get the input texture from.
  29284. */
  29285. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29286. /**
  29287. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29288. * 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)
  29289. * @param channel Name of the sampler variable.
  29290. * @param postProcess Post process to get the output texture from.
  29291. */
  29292. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29293. /** @hidden */
  29294. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29295. /** @hidden */
  29296. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29297. /** @hidden */
  29298. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29299. /** @hidden */
  29300. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29301. /**
  29302. * Binds a buffer to a uniform.
  29303. * @param buffer Buffer to bind.
  29304. * @param name Name of the uniform variable to bind to.
  29305. */
  29306. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29307. /**
  29308. * Binds block to a uniform.
  29309. * @param blockName Name of the block to bind.
  29310. * @param index Index to bind.
  29311. */
  29312. bindUniformBlock(blockName: string, index: number): void;
  29313. /**
  29314. * Sets an interger value on a uniform variable.
  29315. * @param uniformName Name of the variable.
  29316. * @param value Value to be set.
  29317. * @returns this effect.
  29318. */
  29319. setInt(uniformName: string, value: number): Effect;
  29320. /**
  29321. * Sets an int array on a uniform variable.
  29322. * @param uniformName Name of the variable.
  29323. * @param array array to be set.
  29324. * @returns this effect.
  29325. */
  29326. setIntArray(uniformName: string, array: Int32Array): Effect;
  29327. /**
  29328. * 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)
  29329. * @param uniformName Name of the variable.
  29330. * @param array array to be set.
  29331. * @returns this effect.
  29332. */
  29333. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29334. /**
  29335. * 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)
  29336. * @param uniformName Name of the variable.
  29337. * @param array array to be set.
  29338. * @returns this effect.
  29339. */
  29340. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29341. /**
  29342. * 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)
  29343. * @param uniformName Name of the variable.
  29344. * @param array array to be set.
  29345. * @returns this effect.
  29346. */
  29347. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29348. /**
  29349. * Sets an float array on a uniform variable.
  29350. * @param uniformName Name of the variable.
  29351. * @param array array to be set.
  29352. * @returns this effect.
  29353. */
  29354. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29355. /**
  29356. * 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)
  29357. * @param uniformName Name of the variable.
  29358. * @param array array to be set.
  29359. * @returns this effect.
  29360. */
  29361. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29362. /**
  29363. * 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)
  29364. * @param uniformName Name of the variable.
  29365. * @param array array to be set.
  29366. * @returns this effect.
  29367. */
  29368. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29369. /**
  29370. * 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)
  29371. * @param uniformName Name of the variable.
  29372. * @param array array to be set.
  29373. * @returns this effect.
  29374. */
  29375. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29376. /**
  29377. * Sets an array on a uniform variable.
  29378. * @param uniformName Name of the variable.
  29379. * @param array array to be set.
  29380. * @returns this effect.
  29381. */
  29382. setArray(uniformName: string, array: number[]): Effect;
  29383. /**
  29384. * 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)
  29385. * @param uniformName Name of the variable.
  29386. * @param array array to be set.
  29387. * @returns this effect.
  29388. */
  29389. setArray2(uniformName: string, array: number[]): Effect;
  29390. /**
  29391. * 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)
  29392. * @param uniformName Name of the variable.
  29393. * @param array array to be set.
  29394. * @returns this effect.
  29395. */
  29396. setArray3(uniformName: string, array: number[]): Effect;
  29397. /**
  29398. * 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)
  29399. * @param uniformName Name of the variable.
  29400. * @param array array to be set.
  29401. * @returns this effect.
  29402. */
  29403. setArray4(uniformName: string, array: number[]): Effect;
  29404. /**
  29405. * Sets matrices on a uniform variable.
  29406. * @param uniformName Name of the variable.
  29407. * @param matrices matrices to be set.
  29408. * @returns this effect.
  29409. */
  29410. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29411. /**
  29412. * Sets matrix on a uniform variable.
  29413. * @param uniformName Name of the variable.
  29414. * @param matrix matrix to be set.
  29415. * @returns this effect.
  29416. */
  29417. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29418. /**
  29419. * 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)
  29420. * @param uniformName Name of the variable.
  29421. * @param matrix matrix to be set.
  29422. * @returns this effect.
  29423. */
  29424. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29425. /**
  29426. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29427. * @param uniformName Name of the variable.
  29428. * @param matrix matrix to be set.
  29429. * @returns this effect.
  29430. */
  29431. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29432. /**
  29433. * Sets a float on a uniform variable.
  29434. * @param uniformName Name of the variable.
  29435. * @param value value to be set.
  29436. * @returns this effect.
  29437. */
  29438. setFloat(uniformName: string, value: number): Effect;
  29439. /**
  29440. * Sets a boolean on a uniform variable.
  29441. * @param uniformName Name of the variable.
  29442. * @param bool value to be set.
  29443. * @returns this effect.
  29444. */
  29445. setBool(uniformName: string, bool: boolean): Effect;
  29446. /**
  29447. * Sets a Vector2 on a uniform variable.
  29448. * @param uniformName Name of the variable.
  29449. * @param vector2 vector2 to be set.
  29450. * @returns this effect.
  29451. */
  29452. setVector2(uniformName: string, vector2: Vector2): Effect;
  29453. /**
  29454. * Sets a float2 on a uniform variable.
  29455. * @param uniformName Name of the variable.
  29456. * @param x First float in float2.
  29457. * @param y Second float in float2.
  29458. * @returns this effect.
  29459. */
  29460. setFloat2(uniformName: string, x: number, y: number): Effect;
  29461. /**
  29462. * Sets a Vector3 on a uniform variable.
  29463. * @param uniformName Name of the variable.
  29464. * @param vector3 Value to be set.
  29465. * @returns this effect.
  29466. */
  29467. setVector3(uniformName: string, vector3: Vector3): Effect;
  29468. /**
  29469. * Sets a float3 on a uniform variable.
  29470. * @param uniformName Name of the variable.
  29471. * @param x First float in float3.
  29472. * @param y Second float in float3.
  29473. * @param z Third float in float3.
  29474. * @returns this effect.
  29475. */
  29476. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29477. /**
  29478. * Sets a Vector4 on a uniform variable.
  29479. * @param uniformName Name of the variable.
  29480. * @param vector4 Value to be set.
  29481. * @returns this effect.
  29482. */
  29483. setVector4(uniformName: string, vector4: Vector4): Effect;
  29484. /**
  29485. * Sets a float4 on a uniform variable.
  29486. * @param uniformName Name of the variable.
  29487. * @param x First float in float4.
  29488. * @param y Second float in float4.
  29489. * @param z Third float in float4.
  29490. * @param w Fourth float in float4.
  29491. * @returns this effect.
  29492. */
  29493. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29494. /**
  29495. * Sets a Color3 on a uniform variable.
  29496. * @param uniformName Name of the variable.
  29497. * @param color3 Value to be set.
  29498. * @returns this effect.
  29499. */
  29500. setColor3(uniformName: string, color3: Color3): Effect;
  29501. /**
  29502. * Sets a Color4 on a uniform variable.
  29503. * @param uniformName Name of the variable.
  29504. * @param color3 Value to be set.
  29505. * @param alpha Alpha value to be set.
  29506. * @returns this effect.
  29507. */
  29508. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29509. /**
  29510. * Sets a Color4 on a uniform variable
  29511. * @param uniformName defines the name of the variable
  29512. * @param color4 defines the value to be set
  29513. * @returns this effect.
  29514. */
  29515. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29516. /** Release all associated resources */
  29517. dispose(): void;
  29518. /**
  29519. * This function will add a new shader to the shader store
  29520. * @param name the name of the shader
  29521. * @param pixelShader optional pixel shader content
  29522. * @param vertexShader optional vertex shader content
  29523. */
  29524. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29525. /**
  29526. * Store of each shader (The can be looked up using effect.key)
  29527. */
  29528. static ShadersStore: {
  29529. [key: string]: string;
  29530. };
  29531. /**
  29532. * Store of each included file for a shader (The can be looked up using effect.key)
  29533. */
  29534. static IncludesShadersStore: {
  29535. [key: string]: string;
  29536. };
  29537. /**
  29538. * Resets the cache of effects.
  29539. */
  29540. static ResetCache(): void;
  29541. }
  29542. }
  29543. declare module BABYLON {
  29544. /**
  29545. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29546. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29547. * 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;
  29548. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29549. */
  29550. export class ColorCurves {
  29551. private _dirty;
  29552. private _tempColor;
  29553. private _globalCurve;
  29554. private _highlightsCurve;
  29555. private _midtonesCurve;
  29556. private _shadowsCurve;
  29557. private _positiveCurve;
  29558. private _negativeCurve;
  29559. private _globalHue;
  29560. private _globalDensity;
  29561. private _globalSaturation;
  29562. private _globalExposure;
  29563. /**
  29564. * Gets the global Hue value.
  29565. * 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).
  29566. */
  29567. /**
  29568. * Sets the global Hue value.
  29569. * 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).
  29570. */
  29571. globalHue: number;
  29572. /**
  29573. * Gets the global Density value.
  29574. * 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.
  29575. * Values less than zero provide a filter of opposite hue.
  29576. */
  29577. /**
  29578. * Sets the global Density value.
  29579. * 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.
  29580. * Values less than zero provide a filter of opposite hue.
  29581. */
  29582. globalDensity: number;
  29583. /**
  29584. * Gets the global Saturation value.
  29585. * 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.
  29586. */
  29587. /**
  29588. * Sets the global Saturation value.
  29589. * 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.
  29590. */
  29591. globalSaturation: number;
  29592. /**
  29593. * Gets the global Exposure value.
  29594. * 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.
  29595. */
  29596. /**
  29597. * Sets the global Exposure value.
  29598. * 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.
  29599. */
  29600. globalExposure: number;
  29601. private _highlightsHue;
  29602. private _highlightsDensity;
  29603. private _highlightsSaturation;
  29604. private _highlightsExposure;
  29605. /**
  29606. * Gets the highlights Hue value.
  29607. * 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).
  29608. */
  29609. /**
  29610. * Sets the highlights Hue value.
  29611. * 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).
  29612. */
  29613. highlightsHue: number;
  29614. /**
  29615. * Gets the highlights Density value.
  29616. * 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.
  29617. * Values less than zero provide a filter of opposite hue.
  29618. */
  29619. /**
  29620. * Sets the highlights Density value.
  29621. * 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.
  29622. * Values less than zero provide a filter of opposite hue.
  29623. */
  29624. highlightsDensity: number;
  29625. /**
  29626. * Gets the highlights Saturation value.
  29627. * 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.
  29628. */
  29629. /**
  29630. * Sets the highlights Saturation value.
  29631. * 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.
  29632. */
  29633. highlightsSaturation: number;
  29634. /**
  29635. * Gets the highlights Exposure value.
  29636. * 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.
  29637. */
  29638. /**
  29639. * Sets the highlights Exposure 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 exposure and negative values decrease exposure.
  29641. */
  29642. highlightsExposure: number;
  29643. private _midtonesHue;
  29644. private _midtonesDensity;
  29645. private _midtonesSaturation;
  29646. private _midtonesExposure;
  29647. /**
  29648. * Gets the midtones Hue value.
  29649. * 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).
  29650. */
  29651. /**
  29652. * Sets the midtones Hue value.
  29653. * 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).
  29654. */
  29655. midtonesHue: number;
  29656. /**
  29657. * Gets the midtones Density value.
  29658. * 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.
  29659. * Values less than zero provide a filter of opposite hue.
  29660. */
  29661. /**
  29662. * Sets the midtones Density value.
  29663. * 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.
  29664. * Values less than zero provide a filter of opposite hue.
  29665. */
  29666. midtonesDensity: number;
  29667. /**
  29668. * Gets the midtones Saturation value.
  29669. * 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.
  29670. */
  29671. /**
  29672. * Sets the midtones Saturation value.
  29673. * 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.
  29674. */
  29675. midtonesSaturation: number;
  29676. /**
  29677. * Gets the midtones Exposure value.
  29678. * 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.
  29679. */
  29680. /**
  29681. * Sets the midtones Exposure 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 exposure and negative values decrease exposure.
  29683. */
  29684. midtonesExposure: number;
  29685. private _shadowsHue;
  29686. private _shadowsDensity;
  29687. private _shadowsSaturation;
  29688. private _shadowsExposure;
  29689. /**
  29690. * Gets the shadows Hue value.
  29691. * 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).
  29692. */
  29693. /**
  29694. * Sets the shadows Hue value.
  29695. * 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).
  29696. */
  29697. shadowsHue: number;
  29698. /**
  29699. * Gets the shadows Density value.
  29700. * 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.
  29701. * Values less than zero provide a filter of opposite hue.
  29702. */
  29703. /**
  29704. * Sets the shadows Density value.
  29705. * 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.
  29706. * Values less than zero provide a filter of opposite hue.
  29707. */
  29708. shadowsDensity: number;
  29709. /**
  29710. * Gets the shadows Saturation value.
  29711. * 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.
  29712. */
  29713. /**
  29714. * Sets the shadows Saturation value.
  29715. * 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.
  29716. */
  29717. shadowsSaturation: number;
  29718. /**
  29719. * Gets the shadows Exposure value.
  29720. * 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.
  29721. */
  29722. /**
  29723. * Sets the shadows Exposure 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 exposure and negative values decrease exposure.
  29725. */
  29726. shadowsExposure: number;
  29727. /**
  29728. * Returns the class name
  29729. * @returns The class name
  29730. */
  29731. getClassName(): string;
  29732. /**
  29733. * Binds the color curves to the shader.
  29734. * @param colorCurves The color curve to bind
  29735. * @param effect The effect to bind to
  29736. * @param positiveUniform The positive uniform shader parameter
  29737. * @param neutralUniform The neutral uniform shader parameter
  29738. * @param negativeUniform The negative uniform shader parameter
  29739. */
  29740. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29741. /**
  29742. * Prepare the list of uniforms associated with the ColorCurves effects.
  29743. * @param uniformsList The list of uniforms used in the effect
  29744. */
  29745. static PrepareUniforms(uniformsList: string[]): void;
  29746. /**
  29747. * Returns color grading data based on a hue, density, saturation and exposure value.
  29748. * @param filterHue The hue of the color filter.
  29749. * @param filterDensity The density of the color filter.
  29750. * @param saturation The saturation.
  29751. * @param exposure The exposure.
  29752. * @param result The result data container.
  29753. */
  29754. private getColorGradingDataToRef;
  29755. /**
  29756. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29757. * @param value The input slider value in range [-100,100].
  29758. * @returns Adjusted value.
  29759. */
  29760. private static applyColorGradingSliderNonlinear;
  29761. /**
  29762. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29763. * @param hue The hue (H) input.
  29764. * @param saturation The saturation (S) input.
  29765. * @param brightness The brightness (B) input.
  29766. * @result An RGBA color represented as Vector4.
  29767. */
  29768. private static fromHSBToRef;
  29769. /**
  29770. * Returns a value clamped between min and max
  29771. * @param value The value to clamp
  29772. * @param min The minimum of value
  29773. * @param max The maximum of value
  29774. * @returns The clamped value.
  29775. */
  29776. private static clamp;
  29777. /**
  29778. * Clones the current color curve instance.
  29779. * @return The cloned curves
  29780. */
  29781. clone(): ColorCurves;
  29782. /**
  29783. * Serializes the current color curve instance to a json representation.
  29784. * @return a JSON representation
  29785. */
  29786. serialize(): any;
  29787. /**
  29788. * Parses the color curve from a json representation.
  29789. * @param source the JSON source to parse
  29790. * @return The parsed curves
  29791. */
  29792. static Parse(source: any): ColorCurves;
  29793. }
  29794. }
  29795. declare module BABYLON {
  29796. /**
  29797. * Interface to follow in your material defines to integrate easily the
  29798. * Image proccessing functions.
  29799. * @hidden
  29800. */
  29801. export interface IImageProcessingConfigurationDefines {
  29802. IMAGEPROCESSING: boolean;
  29803. VIGNETTE: boolean;
  29804. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29805. VIGNETTEBLENDMODEOPAQUE: boolean;
  29806. TONEMAPPING: boolean;
  29807. TONEMAPPING_ACES: boolean;
  29808. CONTRAST: boolean;
  29809. EXPOSURE: boolean;
  29810. COLORCURVES: boolean;
  29811. COLORGRADING: boolean;
  29812. COLORGRADING3D: boolean;
  29813. SAMPLER3DGREENDEPTH: boolean;
  29814. SAMPLER3DBGRMAP: boolean;
  29815. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29816. }
  29817. /**
  29818. * @hidden
  29819. */
  29820. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29821. IMAGEPROCESSING: boolean;
  29822. VIGNETTE: boolean;
  29823. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29824. VIGNETTEBLENDMODEOPAQUE: boolean;
  29825. TONEMAPPING: boolean;
  29826. TONEMAPPING_ACES: boolean;
  29827. CONTRAST: boolean;
  29828. COLORCURVES: boolean;
  29829. COLORGRADING: boolean;
  29830. COLORGRADING3D: boolean;
  29831. SAMPLER3DGREENDEPTH: boolean;
  29832. SAMPLER3DBGRMAP: boolean;
  29833. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29834. EXPOSURE: boolean;
  29835. constructor();
  29836. }
  29837. /**
  29838. * This groups together the common properties used for image processing either in direct forward pass
  29839. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29840. * or not.
  29841. */
  29842. export class ImageProcessingConfiguration {
  29843. /**
  29844. * Default tone mapping applied in BabylonJS.
  29845. */
  29846. static readonly TONEMAPPING_STANDARD: number;
  29847. /**
  29848. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29849. * to other engines rendering to increase portability.
  29850. */
  29851. static readonly TONEMAPPING_ACES: number;
  29852. /**
  29853. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29854. */
  29855. colorCurves: Nullable<ColorCurves>;
  29856. private _colorCurvesEnabled;
  29857. /**
  29858. * Gets wether the color curves effect is enabled.
  29859. */
  29860. /**
  29861. * Sets wether the color curves effect is enabled.
  29862. */
  29863. colorCurvesEnabled: boolean;
  29864. private _colorGradingTexture;
  29865. /**
  29866. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29867. */
  29868. /**
  29869. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29870. */
  29871. colorGradingTexture: Nullable<BaseTexture>;
  29872. private _colorGradingEnabled;
  29873. /**
  29874. * Gets wether the color grading effect is enabled.
  29875. */
  29876. /**
  29877. * Sets wether the color grading effect is enabled.
  29878. */
  29879. colorGradingEnabled: boolean;
  29880. private _colorGradingWithGreenDepth;
  29881. /**
  29882. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29883. */
  29884. /**
  29885. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29886. */
  29887. colorGradingWithGreenDepth: boolean;
  29888. private _colorGradingBGR;
  29889. /**
  29890. * Gets wether the color grading texture contains BGR values.
  29891. */
  29892. /**
  29893. * Sets wether the color grading texture contains BGR values.
  29894. */
  29895. colorGradingBGR: boolean;
  29896. /** @hidden */
  29897. _exposure: number;
  29898. /**
  29899. * Gets the Exposure used in the effect.
  29900. */
  29901. /**
  29902. * Sets the Exposure used in the effect.
  29903. */
  29904. exposure: number;
  29905. private _toneMappingEnabled;
  29906. /**
  29907. * Gets wether the tone mapping effect is enabled.
  29908. */
  29909. /**
  29910. * Sets wether the tone mapping effect is enabled.
  29911. */
  29912. toneMappingEnabled: boolean;
  29913. private _toneMappingType;
  29914. /**
  29915. * Gets the type of tone mapping effect.
  29916. */
  29917. /**
  29918. * Sets the type of tone mapping effect used in BabylonJS.
  29919. */
  29920. toneMappingType: number;
  29921. protected _contrast: number;
  29922. /**
  29923. * Gets the contrast used in the effect.
  29924. */
  29925. /**
  29926. * Sets the contrast used in the effect.
  29927. */
  29928. contrast: number;
  29929. /**
  29930. * Vignette stretch size.
  29931. */
  29932. vignetteStretch: number;
  29933. /**
  29934. * Vignette centre X Offset.
  29935. */
  29936. vignetteCentreX: number;
  29937. /**
  29938. * Vignette centre Y Offset.
  29939. */
  29940. vignetteCentreY: number;
  29941. /**
  29942. * Vignette weight or intensity of the vignette effect.
  29943. */
  29944. vignetteWeight: number;
  29945. /**
  29946. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29947. * if vignetteEnabled is set to true.
  29948. */
  29949. vignetteColor: Color4;
  29950. /**
  29951. * Camera field of view used by the Vignette effect.
  29952. */
  29953. vignetteCameraFov: number;
  29954. private _vignetteBlendMode;
  29955. /**
  29956. * Gets the vignette blend mode allowing different kind of effect.
  29957. */
  29958. /**
  29959. * Sets the vignette blend mode allowing different kind of effect.
  29960. */
  29961. vignetteBlendMode: number;
  29962. private _vignetteEnabled;
  29963. /**
  29964. * Gets wether the vignette effect is enabled.
  29965. */
  29966. /**
  29967. * Sets wether the vignette effect is enabled.
  29968. */
  29969. vignetteEnabled: boolean;
  29970. private _applyByPostProcess;
  29971. /**
  29972. * Gets wether the image processing is applied through a post process or not.
  29973. */
  29974. /**
  29975. * Sets wether the image processing is applied through a post process or not.
  29976. */
  29977. applyByPostProcess: boolean;
  29978. private _isEnabled;
  29979. /**
  29980. * Gets wether the image processing is enabled or not.
  29981. */
  29982. /**
  29983. * Sets wether the image processing is enabled or not.
  29984. */
  29985. isEnabled: boolean;
  29986. /**
  29987. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29988. */
  29989. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29990. /**
  29991. * Method called each time the image processing information changes requires to recompile the effect.
  29992. */
  29993. protected _updateParameters(): void;
  29994. /**
  29995. * Gets the current class name.
  29996. * @return "ImageProcessingConfiguration"
  29997. */
  29998. getClassName(): string;
  29999. /**
  30000. * Prepare the list of uniforms associated with the Image Processing effects.
  30001. * @param uniforms The list of uniforms used in the effect
  30002. * @param defines the list of defines currently in use
  30003. */
  30004. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30005. /**
  30006. * Prepare the list of samplers associated with the Image Processing effects.
  30007. * @param samplersList The list of uniforms used in the effect
  30008. * @param defines the list of defines currently in use
  30009. */
  30010. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30011. /**
  30012. * Prepare the list of defines associated to the shader.
  30013. * @param defines the list of defines to complete
  30014. * @param forPostProcess Define if we are currently in post process mode or not
  30015. */
  30016. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30017. /**
  30018. * Returns true if all the image processing information are ready.
  30019. * @returns True if ready, otherwise, false
  30020. */
  30021. isReady(): boolean;
  30022. /**
  30023. * Binds the image processing to the shader.
  30024. * @param effect The effect to bind to
  30025. * @param aspectRatio Define the current aspect ratio of the effect
  30026. */
  30027. bind(effect: Effect, aspectRatio?: number): void;
  30028. /**
  30029. * Clones the current image processing instance.
  30030. * @return The cloned image processing
  30031. */
  30032. clone(): ImageProcessingConfiguration;
  30033. /**
  30034. * Serializes the current image processing instance to a json representation.
  30035. * @return a JSON representation
  30036. */
  30037. serialize(): any;
  30038. /**
  30039. * Parses the image processing from a json representation.
  30040. * @param source the JSON source to parse
  30041. * @return The parsed image processing
  30042. */
  30043. static Parse(source: any): ImageProcessingConfiguration;
  30044. private static _VIGNETTEMODE_MULTIPLY;
  30045. private static _VIGNETTEMODE_OPAQUE;
  30046. /**
  30047. * Used to apply the vignette as a mix with the pixel color.
  30048. */
  30049. static readonly VIGNETTEMODE_MULTIPLY: number;
  30050. /**
  30051. * Used to apply the vignette as a replacement of the pixel color.
  30052. */
  30053. static readonly VIGNETTEMODE_OPAQUE: number;
  30054. }
  30055. }
  30056. declare module BABYLON {
  30057. /**
  30058. * This represents all the required information to add a fresnel effect on a material:
  30059. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30060. */
  30061. export class FresnelParameters {
  30062. private _isEnabled;
  30063. /**
  30064. * Define if the fresnel effect is enable or not.
  30065. */
  30066. isEnabled: boolean;
  30067. /**
  30068. * Define the color used on edges (grazing angle)
  30069. */
  30070. leftColor: Color3;
  30071. /**
  30072. * Define the color used on center
  30073. */
  30074. rightColor: Color3;
  30075. /**
  30076. * Define bias applied to computed fresnel term
  30077. */
  30078. bias: number;
  30079. /**
  30080. * Defined the power exponent applied to fresnel term
  30081. */
  30082. power: number;
  30083. /**
  30084. * Clones the current fresnel and its valuues
  30085. * @returns a clone fresnel configuration
  30086. */
  30087. clone(): FresnelParameters;
  30088. /**
  30089. * Serializes the current fresnel parameters to a JSON representation.
  30090. * @return the JSON serialization
  30091. */
  30092. serialize(): any;
  30093. /**
  30094. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30095. * @param parsedFresnelParameters Define the JSON representation
  30096. * @returns the parsed parameters
  30097. */
  30098. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30099. }
  30100. }
  30101. declare module BABYLON {
  30102. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30103. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30104. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30105. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30106. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30107. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30108. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30109. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30110. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30111. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30112. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30113. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30114. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30115. /**
  30116. * Decorator used to define property that can be serialized as reference to a camera
  30117. * @param sourceName defines the name of the property to decorate
  30118. */
  30119. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30120. /**
  30121. * Class used to help serialization objects
  30122. */
  30123. export class SerializationHelper {
  30124. /** hidden */
  30125. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30126. /** hidden */
  30127. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30128. /** hidden */
  30129. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30130. /** hidden */
  30131. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30132. /**
  30133. * Appends the serialized animations from the source animations
  30134. * @param source Source containing the animations
  30135. * @param destination Target to store the animations
  30136. */
  30137. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30138. /**
  30139. * Static function used to serialized a specific entity
  30140. * @param entity defines the entity to serialize
  30141. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30142. * @returns a JSON compatible object representing the serialization of the entity
  30143. */
  30144. static Serialize<T>(entity: T, serializationObject?: any): any;
  30145. /**
  30146. * Creates a new entity from a serialization data object
  30147. * @param creationFunction defines a function used to instanciated the new entity
  30148. * @param source defines the source serialization data
  30149. * @param scene defines the hosting scene
  30150. * @param rootUrl defines the root url for resources
  30151. * @returns a new entity
  30152. */
  30153. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30154. /**
  30155. * Clones an object
  30156. * @param creationFunction defines the function used to instanciate the new object
  30157. * @param source defines the source object
  30158. * @returns the cloned object
  30159. */
  30160. static Clone<T>(creationFunction: () => T, source: T): T;
  30161. /**
  30162. * Instanciates a new object based on a source one (some data will be shared between both object)
  30163. * @param creationFunction defines the function used to instanciate the new object
  30164. * @param source defines the source object
  30165. * @returns the new object
  30166. */
  30167. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30168. }
  30169. }
  30170. declare module BABYLON {
  30171. /**
  30172. * This is the base class of all the camera used in the application.
  30173. * @see http://doc.babylonjs.com/features/cameras
  30174. */
  30175. export class Camera extends Node {
  30176. /** @hidden */
  30177. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30178. /**
  30179. * This is the default projection mode used by the cameras.
  30180. * It helps recreating a feeling of perspective and better appreciate depth.
  30181. * This is the best way to simulate real life cameras.
  30182. */
  30183. static readonly PERSPECTIVE_CAMERA: number;
  30184. /**
  30185. * This helps creating camera with an orthographic mode.
  30186. * 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.
  30187. */
  30188. static readonly ORTHOGRAPHIC_CAMERA: number;
  30189. /**
  30190. * This is the default FOV mode for perspective cameras.
  30191. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30192. */
  30193. static readonly FOVMODE_VERTICAL_FIXED: number;
  30194. /**
  30195. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30196. */
  30197. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30198. /**
  30199. * This specifies ther is no need for a camera rig.
  30200. * Basically only one eye is rendered corresponding to the camera.
  30201. */
  30202. static readonly RIG_MODE_NONE: number;
  30203. /**
  30204. * Simulates a camera Rig with one blue eye and one red eye.
  30205. * This can be use with 3d blue and red glasses.
  30206. */
  30207. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30208. /**
  30209. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30210. */
  30211. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30212. /**
  30213. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30214. */
  30215. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30216. /**
  30217. * Defines that both eyes of the camera will be rendered over under each other.
  30218. */
  30219. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30220. /**
  30221. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30222. */
  30223. static readonly RIG_MODE_VR: number;
  30224. /**
  30225. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30226. */
  30227. static readonly RIG_MODE_WEBVR: number;
  30228. /**
  30229. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30230. */
  30231. static readonly RIG_MODE_CUSTOM: number;
  30232. /**
  30233. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30234. */
  30235. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30236. /**
  30237. * Define the input manager associated with the camera.
  30238. */
  30239. inputs: CameraInputsManager<Camera>;
  30240. /** @hidden */
  30241. _position: Vector3;
  30242. /**
  30243. * Define the current local position of the camera in the scene
  30244. */
  30245. position: Vector3;
  30246. /**
  30247. * The vector the camera should consider as up.
  30248. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30249. */
  30250. upVector: Vector3;
  30251. /**
  30252. * Define the current limit on the left side for an orthographic camera
  30253. * In scene unit
  30254. */
  30255. orthoLeft: Nullable<number>;
  30256. /**
  30257. * Define the current limit on the right side for an orthographic camera
  30258. * In scene unit
  30259. */
  30260. orthoRight: Nullable<number>;
  30261. /**
  30262. * Define the current limit on the bottom side for an orthographic camera
  30263. * In scene unit
  30264. */
  30265. orthoBottom: Nullable<number>;
  30266. /**
  30267. * Define the current limit on the top side for an orthographic camera
  30268. * In scene unit
  30269. */
  30270. orthoTop: Nullable<number>;
  30271. /**
  30272. * Field Of View is set in Radians. (default is 0.8)
  30273. */
  30274. fov: number;
  30275. /**
  30276. * Define the minimum distance the camera can see from.
  30277. * This is important to note that the depth buffer are not infinite and the closer it starts
  30278. * the more your scene might encounter depth fighting issue.
  30279. */
  30280. minZ: number;
  30281. /**
  30282. * Define the maximum distance the camera can see to.
  30283. * This is important to note that the depth buffer are not infinite and the further it end
  30284. * the more your scene might encounter depth fighting issue.
  30285. */
  30286. maxZ: number;
  30287. /**
  30288. * Define the default inertia of the camera.
  30289. * This helps giving a smooth feeling to the camera movement.
  30290. */
  30291. inertia: number;
  30292. /**
  30293. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30294. */
  30295. mode: number;
  30296. /**
  30297. * Define wether the camera is intermediate.
  30298. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30299. */
  30300. isIntermediate: boolean;
  30301. /**
  30302. * Define the viewport of the camera.
  30303. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30304. */
  30305. viewport: Viewport;
  30306. /**
  30307. * Restricts the camera to viewing objects with the same layerMask.
  30308. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30309. */
  30310. layerMask: number;
  30311. /**
  30312. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30313. */
  30314. fovMode: number;
  30315. /**
  30316. * Rig mode of the camera.
  30317. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30318. * This is normally controlled byt the camera themselves as internal use.
  30319. */
  30320. cameraRigMode: number;
  30321. /**
  30322. * Defines the distance between both "eyes" in case of a RIG
  30323. */
  30324. interaxialDistance: number;
  30325. /**
  30326. * Defines if stereoscopic rendering is done side by side or over under.
  30327. */
  30328. isStereoscopicSideBySide: boolean;
  30329. /**
  30330. * 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
  30331. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30332. * else in the scene.
  30333. */
  30334. customRenderTargets: RenderTargetTexture[];
  30335. /**
  30336. * When set, the camera will render to this render target instead of the default canvas
  30337. */
  30338. outputRenderTarget: Nullable<RenderTargetTexture>;
  30339. /**
  30340. * Observable triggered when the camera view matrix has changed.
  30341. */
  30342. onViewMatrixChangedObservable: Observable<Camera>;
  30343. /**
  30344. * Observable triggered when the camera Projection matrix has changed.
  30345. */
  30346. onProjectionMatrixChangedObservable: Observable<Camera>;
  30347. /**
  30348. * Observable triggered when the inputs have been processed.
  30349. */
  30350. onAfterCheckInputsObservable: Observable<Camera>;
  30351. /**
  30352. * Observable triggered when reset has been called and applied to the camera.
  30353. */
  30354. onRestoreStateObservable: Observable<Camera>;
  30355. /** @hidden */
  30356. _cameraRigParams: any;
  30357. /** @hidden */
  30358. _rigCameras: Camera[];
  30359. /** @hidden */
  30360. _rigPostProcess: Nullable<PostProcess>;
  30361. protected _webvrViewMatrix: Matrix;
  30362. /** @hidden */
  30363. _skipRendering: boolean;
  30364. /** @hidden */
  30365. _projectionMatrix: Matrix;
  30366. /** @hidden */
  30367. _postProcesses: Nullable<PostProcess>[];
  30368. /** @hidden */
  30369. _activeMeshes: SmartArray<AbstractMesh>;
  30370. protected _globalPosition: Vector3;
  30371. /** hidden */
  30372. _computedViewMatrix: Matrix;
  30373. private _doNotComputeProjectionMatrix;
  30374. private _transformMatrix;
  30375. private _frustumPlanes;
  30376. private _refreshFrustumPlanes;
  30377. private _storedFov;
  30378. private _stateStored;
  30379. /**
  30380. * Instantiates a new camera object.
  30381. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30382. * @see http://doc.babylonjs.com/features/cameras
  30383. * @param name Defines the name of the camera in the scene
  30384. * @param position Defines the position of the camera
  30385. * @param scene Defines the scene the camera belongs too
  30386. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30387. */
  30388. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30389. /**
  30390. * Store current camera state (fov, position, etc..)
  30391. * @returns the camera
  30392. */
  30393. storeState(): Camera;
  30394. /**
  30395. * Restores the camera state values if it has been stored. You must call storeState() first
  30396. */
  30397. protected _restoreStateValues(): boolean;
  30398. /**
  30399. * Restored camera state. You must call storeState() first.
  30400. * @returns true if restored and false otherwise
  30401. */
  30402. restoreState(): boolean;
  30403. /**
  30404. * Gets the class name of the camera.
  30405. * @returns the class name
  30406. */
  30407. getClassName(): string;
  30408. /** @hidden */
  30409. readonly _isCamera: boolean;
  30410. /**
  30411. * Gets a string representation of the camera useful for debug purpose.
  30412. * @param fullDetails Defines that a more verboe level of logging is required
  30413. * @returns the string representation
  30414. */
  30415. toString(fullDetails?: boolean): string;
  30416. /**
  30417. * Gets the current world space position of the camera.
  30418. */
  30419. readonly globalPosition: Vector3;
  30420. /**
  30421. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30422. * @returns the active meshe list
  30423. */
  30424. getActiveMeshes(): SmartArray<AbstractMesh>;
  30425. /**
  30426. * Check wether a mesh is part of the current active mesh list of the camera
  30427. * @param mesh Defines the mesh to check
  30428. * @returns true if active, false otherwise
  30429. */
  30430. isActiveMesh(mesh: Mesh): boolean;
  30431. /**
  30432. * Is this camera ready to be used/rendered
  30433. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30434. * @return true if the camera is ready
  30435. */
  30436. isReady(completeCheck?: boolean): boolean;
  30437. /** @hidden */
  30438. _initCache(): void;
  30439. /** @hidden */
  30440. _updateCache(ignoreParentClass?: boolean): void;
  30441. /** @hidden */
  30442. _isSynchronized(): boolean;
  30443. /** @hidden */
  30444. _isSynchronizedViewMatrix(): boolean;
  30445. /** @hidden */
  30446. _isSynchronizedProjectionMatrix(): boolean;
  30447. /**
  30448. * Attach the input controls to a specific dom element to get the input from.
  30449. * @param element Defines the element the controls should be listened from
  30450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30451. */
  30452. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30453. /**
  30454. * Detach the current controls from the specified dom element.
  30455. * @param element Defines the element to stop listening the inputs from
  30456. */
  30457. detachControl(element: HTMLElement): void;
  30458. /**
  30459. * Update the camera state according to the different inputs gathered during the frame.
  30460. */
  30461. update(): void;
  30462. /** @hidden */
  30463. _checkInputs(): void;
  30464. /** @hidden */
  30465. readonly rigCameras: Camera[];
  30466. /**
  30467. * Gets the post process used by the rig cameras
  30468. */
  30469. readonly rigPostProcess: Nullable<PostProcess>;
  30470. /**
  30471. * Internal, gets the first post proces.
  30472. * @returns the first post process to be run on this camera.
  30473. */
  30474. _getFirstPostProcess(): Nullable<PostProcess>;
  30475. private _cascadePostProcessesToRigCams;
  30476. /**
  30477. * Attach a post process to the camera.
  30478. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30479. * @param postProcess The post process to attach to the camera
  30480. * @param insertAt The position of the post process in case several of them are in use in the scene
  30481. * @returns the position the post process has been inserted at
  30482. */
  30483. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30484. /**
  30485. * Detach a post process to the camera.
  30486. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30487. * @param postProcess The post process to detach from the camera
  30488. */
  30489. detachPostProcess(postProcess: PostProcess): void;
  30490. /**
  30491. * Gets the current world matrix of the camera
  30492. */
  30493. getWorldMatrix(): Matrix;
  30494. /** @hidden */
  30495. _getViewMatrix(): Matrix;
  30496. /**
  30497. * Gets the current view matrix of the camera.
  30498. * @param force forces the camera to recompute the matrix without looking at the cached state
  30499. * @returns the view matrix
  30500. */
  30501. getViewMatrix(force?: boolean): Matrix;
  30502. /**
  30503. * Freeze the projection matrix.
  30504. * It will prevent the cache check of the camera projection compute and can speed up perf
  30505. * if no parameter of the camera are meant to change
  30506. * @param projection Defines manually a projection if necessary
  30507. */
  30508. freezeProjectionMatrix(projection?: Matrix): void;
  30509. /**
  30510. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30511. */
  30512. unfreezeProjectionMatrix(): void;
  30513. /**
  30514. * Gets the current projection matrix of the camera.
  30515. * @param force forces the camera to recompute the matrix without looking at the cached state
  30516. * @returns the projection matrix
  30517. */
  30518. getProjectionMatrix(force?: boolean): Matrix;
  30519. /**
  30520. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30521. * @returns a Matrix
  30522. */
  30523. getTransformationMatrix(): Matrix;
  30524. private _updateFrustumPlanes;
  30525. /**
  30526. * Checks if a cullable object (mesh...) is in the camera frustum
  30527. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30528. * @param target The object to check
  30529. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30530. * @returns true if the object is in frustum otherwise false
  30531. */
  30532. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30533. /**
  30534. * Checks if a cullable object (mesh...) is in the camera frustum
  30535. * Unlike isInFrustum this cheks the full bounding box
  30536. * @param target The object to check
  30537. * @returns true if the object is in frustum otherwise false
  30538. */
  30539. isCompletelyInFrustum(target: ICullable): boolean;
  30540. /**
  30541. * Gets a ray in the forward direction from the camera.
  30542. * @param length Defines the length of the ray to create
  30543. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30544. * @param origin Defines the start point of the ray which defaults to the camera position
  30545. * @returns the forward ray
  30546. */
  30547. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30548. /**
  30549. * Releases resources associated with this node.
  30550. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30551. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30552. */
  30553. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30554. /** @hidden */
  30555. _isLeftCamera: boolean;
  30556. /**
  30557. * Gets the left camera of a rig setup in case of Rigged Camera
  30558. */
  30559. readonly isLeftCamera: boolean;
  30560. /** @hidden */
  30561. _isRightCamera: boolean;
  30562. /**
  30563. * Gets the right camera of a rig setup in case of Rigged Camera
  30564. */
  30565. readonly isRightCamera: boolean;
  30566. /**
  30567. * Gets the left camera of a rig setup in case of Rigged Camera
  30568. */
  30569. readonly leftCamera: Nullable<FreeCamera>;
  30570. /**
  30571. * Gets the right camera of a rig setup in case of Rigged Camera
  30572. */
  30573. readonly rightCamera: Nullable<FreeCamera>;
  30574. /**
  30575. * Gets the left camera target of a rig setup in case of Rigged Camera
  30576. * @returns the target position
  30577. */
  30578. getLeftTarget(): Nullable<Vector3>;
  30579. /**
  30580. * Gets the right camera target of a rig setup in case of Rigged Camera
  30581. * @returns the target position
  30582. */
  30583. getRightTarget(): Nullable<Vector3>;
  30584. /**
  30585. * @hidden
  30586. */
  30587. setCameraRigMode(mode: number, rigParams: any): void;
  30588. /** @hidden */
  30589. static _setStereoscopicRigMode(camera: Camera): void;
  30590. /** @hidden */
  30591. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30592. /** @hidden */
  30593. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30594. /** @hidden */
  30595. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30596. /** @hidden */
  30597. _getVRProjectionMatrix(): Matrix;
  30598. protected _updateCameraRotationMatrix(): void;
  30599. protected _updateWebVRCameraRotationMatrix(): void;
  30600. /**
  30601. * This function MUST be overwritten by the different WebVR cameras available.
  30602. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30603. * @hidden
  30604. */
  30605. _getWebVRProjectionMatrix(): Matrix;
  30606. /**
  30607. * This function MUST be overwritten by the different WebVR cameras available.
  30608. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30609. * @hidden
  30610. */
  30611. _getWebVRViewMatrix(): Matrix;
  30612. /** @hidden */
  30613. setCameraRigParameter(name: string, value: any): void;
  30614. /**
  30615. * needs to be overridden by children so sub has required properties to be copied
  30616. * @hidden
  30617. */
  30618. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30619. /**
  30620. * May need to be overridden by children
  30621. * @hidden
  30622. */
  30623. _updateRigCameras(): void;
  30624. /** @hidden */
  30625. _setupInputs(): void;
  30626. /**
  30627. * Serialiaze the camera setup to a json represention
  30628. * @returns the JSON representation
  30629. */
  30630. serialize(): any;
  30631. /**
  30632. * Clones the current camera.
  30633. * @param name The cloned camera name
  30634. * @returns the cloned camera
  30635. */
  30636. clone(name: string): Camera;
  30637. /**
  30638. * Gets the direction of the camera relative to a given local axis.
  30639. * @param localAxis Defines the reference axis to provide a relative direction.
  30640. * @return the direction
  30641. */
  30642. getDirection(localAxis: Vector3): Vector3;
  30643. /**
  30644. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30645. * @param localAxis Defines the reference axis to provide a relative direction.
  30646. * @param result Defines the vector to store the result in
  30647. */
  30648. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30649. /**
  30650. * Gets a camera constructor for a given camera type
  30651. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30652. * @param name The name of the camera the result will be able to instantiate
  30653. * @param scene The scene the result will construct the camera in
  30654. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30655. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30656. * @returns a factory method to construc the camera
  30657. */
  30658. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30659. /**
  30660. * Compute the world matrix of the camera.
  30661. * @returns the camera workd matrix
  30662. */
  30663. computeWorldMatrix(): Matrix;
  30664. /**
  30665. * Parse a JSON and creates the camera from the parsed information
  30666. * @param parsedCamera The JSON to parse
  30667. * @param scene The scene to instantiate the camera in
  30668. * @returns the newly constructed camera
  30669. */
  30670. static Parse(parsedCamera: any, scene: Scene): Camera;
  30671. }
  30672. }
  30673. declare module BABYLON {
  30674. /**
  30675. * Interface for any object that can request an animation frame
  30676. */
  30677. export interface ICustomAnimationFrameRequester {
  30678. /**
  30679. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30680. */
  30681. renderFunction?: Function;
  30682. /**
  30683. * Called to request the next frame to render to
  30684. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30685. */
  30686. requestAnimationFrame: Function;
  30687. /**
  30688. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30689. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30690. */
  30691. requestID?: number;
  30692. }
  30693. /**
  30694. * Interface containing an array of animations
  30695. */
  30696. export interface IAnimatable {
  30697. /**
  30698. * Array of animations
  30699. */
  30700. animations: Nullable<Array<Animation>>;
  30701. }
  30702. /** Interface used by value gradients (color, factor, ...) */
  30703. export interface IValueGradient {
  30704. /**
  30705. * Gets or sets the gradient value (between 0 and 1)
  30706. */
  30707. gradient: number;
  30708. }
  30709. /** Class used to store color4 gradient */
  30710. export class ColorGradient implements IValueGradient {
  30711. /**
  30712. * Gets or sets the gradient value (between 0 and 1)
  30713. */
  30714. gradient: number;
  30715. /**
  30716. * Gets or sets first associated color
  30717. */
  30718. color1: Color4;
  30719. /**
  30720. * Gets or sets second associated color
  30721. */
  30722. color2?: Color4;
  30723. /**
  30724. * Will get a color picked randomly between color1 and color2.
  30725. * If color2 is undefined then color1 will be used
  30726. * @param result defines the target Color4 to store the result in
  30727. */
  30728. getColorToRef(result: Color4): void;
  30729. }
  30730. /** Class used to store color 3 gradient */
  30731. export class Color3Gradient implements IValueGradient {
  30732. /**
  30733. * Gets or sets the gradient value (between 0 and 1)
  30734. */
  30735. gradient: number;
  30736. /**
  30737. * Gets or sets the associated color
  30738. */
  30739. color: Color3;
  30740. }
  30741. /** Class used to store factor gradient */
  30742. export class FactorGradient implements IValueGradient {
  30743. /**
  30744. * Gets or sets the gradient value (between 0 and 1)
  30745. */
  30746. gradient: number;
  30747. /**
  30748. * Gets or sets first associated factor
  30749. */
  30750. factor1: number;
  30751. /**
  30752. * Gets or sets second associated factor
  30753. */
  30754. factor2?: number;
  30755. /**
  30756. * Will get a number picked randomly between factor1 and factor2.
  30757. * If factor2 is undefined then factor1 will be used
  30758. * @returns the picked number
  30759. */
  30760. getFactor(): number;
  30761. }
  30762. /**
  30763. * @ignore
  30764. * Application error to support additional information when loading a file
  30765. */
  30766. export class LoadFileError extends Error {
  30767. /** defines the optional web request */
  30768. request?: WebRequest | undefined;
  30769. private static _setPrototypeOf;
  30770. /**
  30771. * Creates a new LoadFileError
  30772. * @param message defines the message of the error
  30773. * @param request defines the optional web request
  30774. */
  30775. constructor(message: string,
  30776. /** defines the optional web request */
  30777. request?: WebRequest | undefined);
  30778. }
  30779. /**
  30780. * Class used to define a retry strategy when error happens while loading assets
  30781. */
  30782. export class RetryStrategy {
  30783. /**
  30784. * Function used to defines an exponential back off strategy
  30785. * @param maxRetries defines the maximum number of retries (3 by default)
  30786. * @param baseInterval defines the interval between retries
  30787. * @returns the strategy function to use
  30788. */
  30789. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30790. }
  30791. /**
  30792. * File request interface
  30793. */
  30794. export interface IFileRequest {
  30795. /**
  30796. * Raised when the request is complete (success or error).
  30797. */
  30798. onCompleteObservable: Observable<IFileRequest>;
  30799. /**
  30800. * Aborts the request for a file.
  30801. */
  30802. abort: () => void;
  30803. }
  30804. /**
  30805. * Class containing a set of static utilities functions
  30806. */
  30807. export class Tools {
  30808. /**
  30809. * Gets or sets the base URL to use to load assets
  30810. */
  30811. static BaseUrl: string;
  30812. /**
  30813. * Enable/Disable Custom HTTP Request Headers globally.
  30814. * default = false
  30815. * @see CustomRequestHeaders
  30816. */
  30817. static UseCustomRequestHeaders: boolean;
  30818. /**
  30819. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30820. * i.e. when loading files, where the server/service expects an Authorization header
  30821. */
  30822. static CustomRequestHeaders: {
  30823. [key: string]: string;
  30824. };
  30825. /**
  30826. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30827. */
  30828. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30829. /**
  30830. * Default behaviour for cors in the application.
  30831. * It can be a string if the expected behavior is identical in the entire app.
  30832. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30833. */
  30834. static CorsBehavior: string | ((url: string | string[]) => string);
  30835. /**
  30836. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30837. * @ignorenaming
  30838. */
  30839. static UseFallbackTexture: boolean;
  30840. /**
  30841. * Use this object to register external classes like custom textures or material
  30842. * to allow the laoders to instantiate them
  30843. */
  30844. static RegisteredExternalClasses: {
  30845. [key: string]: Object;
  30846. };
  30847. /**
  30848. * Texture content used if a texture cannot loaded
  30849. * @ignorenaming
  30850. */
  30851. static fallbackTexture: string;
  30852. /**
  30853. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30854. * @param u defines the coordinate on X axis
  30855. * @param v defines the coordinate on Y axis
  30856. * @param width defines the width of the source data
  30857. * @param height defines the height of the source data
  30858. * @param pixels defines the source byte array
  30859. * @param color defines the output color
  30860. */
  30861. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30862. /**
  30863. * Interpolates between a and b via alpha
  30864. * @param a The lower value (returned when alpha = 0)
  30865. * @param b The upper value (returned when alpha = 1)
  30866. * @param alpha The interpolation-factor
  30867. * @return The mixed value
  30868. */
  30869. static Mix(a: number, b: number, alpha: number): number;
  30870. /**
  30871. * Tries to instantiate a new object from a given class name
  30872. * @param className defines the class name to instantiate
  30873. * @returns the new object or null if the system was not able to do the instantiation
  30874. */
  30875. static Instantiate(className: string): any;
  30876. /**
  30877. * Provides a slice function that will work even on IE
  30878. * @param data defines the array to slice
  30879. * @param start defines the start of the data (optional)
  30880. * @param end defines the end of the data (optional)
  30881. * @returns the new sliced array
  30882. */
  30883. static Slice<T>(data: T, start?: number, end?: number): T;
  30884. /**
  30885. * Polyfill for setImmediate
  30886. * @param action defines the action to execute after the current execution block
  30887. */
  30888. static SetImmediate(action: () => void): void;
  30889. /**
  30890. * Function indicating if a number is an exponent of 2
  30891. * @param value defines the value to test
  30892. * @returns true if the value is an exponent of 2
  30893. */
  30894. static IsExponentOfTwo(value: number): boolean;
  30895. private static _tmpFloatArray;
  30896. /**
  30897. * Returns the nearest 32-bit single precision float representation of a Number
  30898. * @param value A Number. If the parameter is of a different type, it will get converted
  30899. * to a number or to NaN if it cannot be converted
  30900. * @returns number
  30901. */
  30902. static FloatRound(value: number): number;
  30903. /**
  30904. * Find the next highest power of two.
  30905. * @param x Number to start search from.
  30906. * @return Next highest power of two.
  30907. */
  30908. static CeilingPOT(x: number): number;
  30909. /**
  30910. * Find the next lowest power of two.
  30911. * @param x Number to start search from.
  30912. * @return Next lowest power of two.
  30913. */
  30914. static FloorPOT(x: number): number;
  30915. /**
  30916. * Find the nearest power of two.
  30917. * @param x Number to start search from.
  30918. * @return Next nearest power of two.
  30919. */
  30920. static NearestPOT(x: number): number;
  30921. /**
  30922. * Get the closest exponent of two
  30923. * @param value defines the value to approximate
  30924. * @param max defines the maximum value to return
  30925. * @param mode defines how to define the closest value
  30926. * @returns closest exponent of two of the given value
  30927. */
  30928. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30929. /**
  30930. * Extracts the filename from a path
  30931. * @param path defines the path to use
  30932. * @returns the filename
  30933. */
  30934. static GetFilename(path: string): string;
  30935. /**
  30936. * Extracts the "folder" part of a path (everything before the filename).
  30937. * @param uri The URI to extract the info from
  30938. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30939. * @returns The "folder" part of the path
  30940. */
  30941. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30942. /**
  30943. * Extracts text content from a DOM element hierarchy
  30944. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30945. */
  30946. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30947. /**
  30948. * Convert an angle in radians to degrees
  30949. * @param angle defines the angle to convert
  30950. * @returns the angle in degrees
  30951. */
  30952. static ToDegrees(angle: number): number;
  30953. /**
  30954. * Convert an angle in degrees to radians
  30955. * @param angle defines the angle to convert
  30956. * @returns the angle in radians
  30957. */
  30958. static ToRadians(angle: number): number;
  30959. /**
  30960. * Encode a buffer to a base64 string
  30961. * @param buffer defines the buffer to encode
  30962. * @returns the encoded string
  30963. */
  30964. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30965. /**
  30966. * Extracts minimum and maximum values from a list of indexed positions
  30967. * @param positions defines the positions to use
  30968. * @param indices defines the indices to the positions
  30969. * @param indexStart defines the start index
  30970. * @param indexCount defines the end index
  30971. * @param bias defines bias value to add to the result
  30972. * @return minimum and maximum values
  30973. */
  30974. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30975. minimum: Vector3;
  30976. maximum: Vector3;
  30977. };
  30978. /**
  30979. * Extracts minimum and maximum values from a list of positions
  30980. * @param positions defines the positions to use
  30981. * @param start defines the start index in the positions array
  30982. * @param count defines the number of positions to handle
  30983. * @param bias defines bias value to add to the result
  30984. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30985. * @return minimum and maximum values
  30986. */
  30987. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30988. minimum: Vector3;
  30989. maximum: Vector3;
  30990. };
  30991. /**
  30992. * Returns an array if obj is not an array
  30993. * @param obj defines the object to evaluate as an array
  30994. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30995. * @returns either obj directly if obj is an array or a new array containing obj
  30996. */
  30997. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30998. /**
  30999. * Gets the pointer prefix to use
  31000. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31001. */
  31002. static GetPointerPrefix(): string;
  31003. /**
  31004. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31005. * @param func - the function to be called
  31006. * @param requester - the object that will request the next frame. Falls back to window.
  31007. * @returns frame number
  31008. */
  31009. static QueueNewFrame(func: () => void, requester?: any): number;
  31010. /**
  31011. * Ask the browser to promote the current element to fullscreen rendering mode
  31012. * @param element defines the DOM element to promote
  31013. */
  31014. static RequestFullscreen(element: HTMLElement): void;
  31015. /**
  31016. * Asks the browser to exit fullscreen mode
  31017. */
  31018. static ExitFullscreen(): void;
  31019. /**
  31020. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31021. * @param url define the url we are trying
  31022. * @param element define the dom element where to configure the cors policy
  31023. */
  31024. static SetCorsBehavior(url: string | string[], element: {
  31025. crossOrigin: string | null;
  31026. }): void;
  31027. /**
  31028. * Removes unwanted characters from an url
  31029. * @param url defines the url to clean
  31030. * @returns the cleaned url
  31031. */
  31032. static CleanUrl(url: string): string;
  31033. /**
  31034. * Gets or sets a function used to pre-process url before using them to load assets
  31035. */
  31036. static PreprocessUrl: (url: string) => string;
  31037. /**
  31038. * Loads an image as an HTMLImageElement.
  31039. * @param input url string, ArrayBuffer, or Blob to load
  31040. * @param onLoad callback called when the image successfully loads
  31041. * @param onError callback called when the image fails to load
  31042. * @param offlineProvider offline provider for caching
  31043. * @returns the HTMLImageElement of the loaded image
  31044. */
  31045. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31046. /**
  31047. * Loads a file
  31048. * @param url url string, ArrayBuffer, or Blob to load
  31049. * @param onSuccess callback called when the file successfully loads
  31050. * @param onProgress callback called while file is loading (if the server supports this mode)
  31051. * @param offlineProvider defines the offline provider for caching
  31052. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31053. * @param onError callback called when the file fails to load
  31054. * @returns a file request object
  31055. */
  31056. 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;
  31057. /**
  31058. * Load a script (identified by an url). When the url returns, the
  31059. * content of this file is added into a new script element, attached to the DOM (body element)
  31060. * @param scriptUrl defines the url of the script to laod
  31061. * @param onSuccess defines the callback called when the script is loaded
  31062. * @param onError defines the callback to call if an error occurs
  31063. * @param scriptId defines the id of the script element
  31064. */
  31065. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31066. /**
  31067. * Load an asynchronous script (identified by an url). When the url returns, the
  31068. * content of this file is added into a new script element, attached to the DOM (body element)
  31069. * @param scriptUrl defines the url of the script to laod
  31070. * @param scriptId defines the id of the script element
  31071. * @returns a promise request object
  31072. */
  31073. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31074. /**
  31075. * Loads a file from a blob
  31076. * @param fileToLoad defines the blob to use
  31077. * @param callback defines the callback to call when data is loaded
  31078. * @param progressCallback defines the callback to call during loading process
  31079. * @returns a file request object
  31080. */
  31081. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31082. /**
  31083. * Loads a file
  31084. * @param fileToLoad defines the file to load
  31085. * @param callback defines the callback to call when data is loaded
  31086. * @param progressCallBack defines the callback to call during loading process
  31087. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31088. * @returns a file request object
  31089. */
  31090. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31091. /**
  31092. * Creates a data url from a given string content
  31093. * @param content defines the content to convert
  31094. * @returns the new data url link
  31095. */
  31096. static FileAsURL(content: string): string;
  31097. /**
  31098. * Format the given number to a specific decimal format
  31099. * @param value defines the number to format
  31100. * @param decimals defines the number of decimals to use
  31101. * @returns the formatted string
  31102. */
  31103. static Format(value: number, decimals?: number): string;
  31104. /**
  31105. * Checks if a given vector is inside a specific range
  31106. * @param v defines the vector to test
  31107. * @param min defines the minimum range
  31108. * @param max defines the maximum range
  31109. */
  31110. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31111. /**
  31112. * Tries to copy an object by duplicating every property
  31113. * @param source defines the source object
  31114. * @param destination defines the target object
  31115. * @param doNotCopyList defines a list of properties to avoid
  31116. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31117. */
  31118. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31119. /**
  31120. * Gets a boolean indicating if the given object has no own property
  31121. * @param obj defines the object to test
  31122. * @returns true if object has no own property
  31123. */
  31124. static IsEmpty(obj: any): boolean;
  31125. /**
  31126. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31127. * @param str Source string
  31128. * @param suffix Suffix to search for in the source string
  31129. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31130. */
  31131. static EndsWith(str: string, suffix: string): boolean;
  31132. /**
  31133. * Function used to register events at window level
  31134. * @param events defines the events to register
  31135. */
  31136. static RegisterTopRootEvents(events: {
  31137. name: string;
  31138. handler: Nullable<(e: FocusEvent) => any>;
  31139. }[]): void;
  31140. /**
  31141. * Function used to unregister events from window level
  31142. * @param events defines the events to unregister
  31143. */
  31144. static UnregisterTopRootEvents(events: {
  31145. name: string;
  31146. handler: Nullable<(e: FocusEvent) => any>;
  31147. }[]): void;
  31148. /**
  31149. * @ignore
  31150. */
  31151. static _ScreenshotCanvas: HTMLCanvasElement;
  31152. /**
  31153. * Dumps the current bound framebuffer
  31154. * @param width defines the rendering width
  31155. * @param height defines the rendering height
  31156. * @param engine defines the hosting engine
  31157. * @param successCallback defines the callback triggered once the data are available
  31158. * @param mimeType defines the mime type of the result
  31159. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31160. */
  31161. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31162. /**
  31163. * Converts the canvas data to blob.
  31164. * This acts as a polyfill for browsers not supporting the to blob function.
  31165. * @param canvas Defines the canvas to extract the data from
  31166. * @param successCallback Defines the callback triggered once the data are available
  31167. * @param mimeType Defines the mime type of the result
  31168. */
  31169. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31170. /**
  31171. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31172. * @param successCallback defines the callback triggered once the data are available
  31173. * @param mimeType defines the mime type of the result
  31174. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31175. */
  31176. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31177. /**
  31178. * Downloads a blob in the browser
  31179. * @param blob defines the blob to download
  31180. * @param fileName defines the name of the downloaded file
  31181. */
  31182. static Download(blob: Blob, fileName: string): void;
  31183. /**
  31184. * Captures a screenshot of the current rendering
  31185. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31186. * @param engine defines the rendering engine
  31187. * @param camera defines the source camera
  31188. * @param size This parameter can be set to a single number or to an object with the
  31189. * following (optional) properties: precision, width, height. If a single number is passed,
  31190. * it will be used for both width and height. If an object is passed, the screenshot size
  31191. * will be derived from the parameters. The precision property is a multiplier allowing
  31192. * rendering at a higher or lower resolution
  31193. * @param successCallback defines the callback receives a single parameter which contains the
  31194. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31195. * src parameter of an <img> to display it
  31196. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31197. * Check your browser for supported MIME types
  31198. */
  31199. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31200. /**
  31201. * Generates an image screenshot from the specified camera.
  31202. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31203. * @param engine The engine to use for rendering
  31204. * @param camera The camera to use for rendering
  31205. * @param size This parameter can be set to a single number or to an object with the
  31206. * following (optional) properties: precision, width, height. If a single number is passed,
  31207. * it will be used for both width and height. If an object is passed, the screenshot size
  31208. * will be derived from the parameters. The precision property is a multiplier allowing
  31209. * rendering at a higher or lower resolution
  31210. * @param successCallback The callback receives a single parameter which contains the
  31211. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31212. * src parameter of an <img> to display it
  31213. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31214. * Check your browser for supported MIME types
  31215. * @param samples Texture samples (default: 1)
  31216. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31217. * @param fileName A name for for the downloaded file.
  31218. */
  31219. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31220. /**
  31221. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31222. * Be aware Math.random() could cause collisions, but:
  31223. * "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"
  31224. * @returns a pseudo random id
  31225. */
  31226. static RandomId(): string;
  31227. /**
  31228. * Test if the given uri is a base64 string
  31229. * @param uri The uri to test
  31230. * @return True if the uri is a base64 string or false otherwise
  31231. */
  31232. static IsBase64(uri: string): boolean;
  31233. /**
  31234. * Decode the given base64 uri.
  31235. * @param uri The uri to decode
  31236. * @return The decoded base64 data.
  31237. */
  31238. static DecodeBase64(uri: string): ArrayBuffer;
  31239. /**
  31240. * Gets the absolute url.
  31241. * @param url the input url
  31242. * @return the absolute url
  31243. */
  31244. static GetAbsoluteUrl(url: string): string;
  31245. /**
  31246. * No log
  31247. */
  31248. static readonly NoneLogLevel: number;
  31249. /**
  31250. * Only message logs
  31251. */
  31252. static readonly MessageLogLevel: number;
  31253. /**
  31254. * Only warning logs
  31255. */
  31256. static readonly WarningLogLevel: number;
  31257. /**
  31258. * Only error logs
  31259. */
  31260. static readonly ErrorLogLevel: number;
  31261. /**
  31262. * All logs
  31263. */
  31264. static readonly AllLogLevel: number;
  31265. /**
  31266. * Gets a value indicating the number of loading errors
  31267. * @ignorenaming
  31268. */
  31269. static readonly errorsCount: number;
  31270. /**
  31271. * Callback called when a new log is added
  31272. */
  31273. static OnNewCacheEntry: (entry: string) => void;
  31274. /**
  31275. * Log a message to the console
  31276. * @param message defines the message to log
  31277. */
  31278. static Log(message: string): void;
  31279. /**
  31280. * Write a warning message to the console
  31281. * @param message defines the message to log
  31282. */
  31283. static Warn(message: string): void;
  31284. /**
  31285. * Write an error message to the console
  31286. * @param message defines the message to log
  31287. */
  31288. static Error(message: string): void;
  31289. /**
  31290. * Gets current log cache (list of logs)
  31291. */
  31292. static readonly LogCache: string;
  31293. /**
  31294. * Clears the log cache
  31295. */
  31296. static ClearLogCache(): void;
  31297. /**
  31298. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31299. */
  31300. static LogLevels: number;
  31301. /**
  31302. * Checks if the loaded document was accessed via `file:`-Protocol.
  31303. * @returns boolean
  31304. */
  31305. static IsFileURL(): boolean;
  31306. /**
  31307. * Checks if the window object exists
  31308. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31309. */
  31310. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31311. /**
  31312. * No performance log
  31313. */
  31314. static readonly PerformanceNoneLogLevel: number;
  31315. /**
  31316. * Use user marks to log performance
  31317. */
  31318. static readonly PerformanceUserMarkLogLevel: number;
  31319. /**
  31320. * Log performance to the console
  31321. */
  31322. static readonly PerformanceConsoleLogLevel: number;
  31323. private static _performance;
  31324. /**
  31325. * Sets the current performance log level
  31326. */
  31327. static PerformanceLogLevel: number;
  31328. private static _StartPerformanceCounterDisabled;
  31329. private static _EndPerformanceCounterDisabled;
  31330. private static _StartUserMark;
  31331. private static _EndUserMark;
  31332. private static _StartPerformanceConsole;
  31333. private static _EndPerformanceConsole;
  31334. /**
  31335. * Starts a performance counter
  31336. */
  31337. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31338. /**
  31339. * Ends a specific performance coutner
  31340. */
  31341. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31342. /**
  31343. * Gets either window.performance.now() if supported or Date.now() else
  31344. */
  31345. static readonly Now: number;
  31346. /**
  31347. * This method will return the name of the class used to create the instance of the given object.
  31348. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31349. * @param object the object to get the class name from
  31350. * @param isType defines if the object is actually a type
  31351. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31352. */
  31353. static GetClassName(object: any, isType?: boolean): string;
  31354. /**
  31355. * Gets the first element of an array satisfying a given predicate
  31356. * @param array defines the array to browse
  31357. * @param predicate defines the predicate to use
  31358. * @returns null if not found or the element
  31359. */
  31360. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31361. /**
  31362. * This method will return the name of the full name of the class, including its owning module (if any).
  31363. * 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).
  31364. * @param object the object to get the class name from
  31365. * @param isType defines if the object is actually a type
  31366. * @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.
  31367. * @ignorenaming
  31368. */
  31369. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31370. /**
  31371. * Returns a promise that resolves after the given amount of time.
  31372. * @param delay Number of milliseconds to delay
  31373. * @returns Promise that resolves after the given amount of time
  31374. */
  31375. static DelayAsync(delay: number): Promise<void>;
  31376. /**
  31377. * Gets the current gradient from an array of IValueGradient
  31378. * @param ratio defines the current ratio to get
  31379. * @param gradients defines the array of IValueGradient
  31380. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31381. */
  31382. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31383. }
  31384. /**
  31385. * This class is used to track a performance counter which is number based.
  31386. * The user has access to many properties which give statistics of different nature.
  31387. *
  31388. * The implementer can track two kinds of Performance Counter: time and count.
  31389. * 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.
  31390. * 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.
  31391. */
  31392. export class PerfCounter {
  31393. /**
  31394. * Gets or sets a global boolean to turn on and off all the counters
  31395. */
  31396. static Enabled: boolean;
  31397. /**
  31398. * Returns the smallest value ever
  31399. */
  31400. readonly min: number;
  31401. /**
  31402. * Returns the biggest value ever
  31403. */
  31404. readonly max: number;
  31405. /**
  31406. * Returns the average value since the performance counter is running
  31407. */
  31408. readonly average: number;
  31409. /**
  31410. * Returns the average value of the last second the counter was monitored
  31411. */
  31412. readonly lastSecAverage: number;
  31413. /**
  31414. * Returns the current value
  31415. */
  31416. readonly current: number;
  31417. /**
  31418. * Gets the accumulated total
  31419. */
  31420. readonly total: number;
  31421. /**
  31422. * Gets the total value count
  31423. */
  31424. readonly count: number;
  31425. /**
  31426. * Creates a new counter
  31427. */
  31428. constructor();
  31429. /**
  31430. * Call this method to start monitoring a new frame.
  31431. * 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.
  31432. */
  31433. fetchNewFrame(): void;
  31434. /**
  31435. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31436. * @param newCount the count value to add to the monitored count
  31437. * @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.
  31438. */
  31439. addCount(newCount: number, fetchResult: boolean): void;
  31440. /**
  31441. * Start monitoring this performance counter
  31442. */
  31443. beginMonitoring(): void;
  31444. /**
  31445. * Compute the time lapsed since the previous beginMonitoring() call.
  31446. * @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
  31447. */
  31448. endMonitoring(newFrame?: boolean): void;
  31449. private _fetchResult;
  31450. private _startMonitoringTime;
  31451. private _min;
  31452. private _max;
  31453. private _average;
  31454. private _current;
  31455. private _totalValueCount;
  31456. private _totalAccumulated;
  31457. private _lastSecAverage;
  31458. private _lastSecAccumulated;
  31459. private _lastSecTime;
  31460. private _lastSecValueCount;
  31461. }
  31462. /**
  31463. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31464. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31465. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31466. * @param name The name of the class, case should be preserved
  31467. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31468. */
  31469. export function className(name: string, module?: string): (target: Object) => void;
  31470. /**
  31471. * An implementation of a loop for asynchronous functions.
  31472. */
  31473. export class AsyncLoop {
  31474. /**
  31475. * Defines the number of iterations for the loop
  31476. */
  31477. iterations: number;
  31478. /**
  31479. * Defines the current index of the loop.
  31480. */
  31481. index: number;
  31482. private _done;
  31483. private _fn;
  31484. private _successCallback;
  31485. /**
  31486. * Constructor.
  31487. * @param iterations the number of iterations.
  31488. * @param func the function to run each iteration
  31489. * @param successCallback the callback that will be called upon succesful execution
  31490. * @param offset starting offset.
  31491. */
  31492. constructor(
  31493. /**
  31494. * Defines the number of iterations for the loop
  31495. */
  31496. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31497. /**
  31498. * Execute the next iteration. Must be called after the last iteration was finished.
  31499. */
  31500. executeNext(): void;
  31501. /**
  31502. * Break the loop and run the success callback.
  31503. */
  31504. breakLoop(): void;
  31505. /**
  31506. * Create and run an async loop.
  31507. * @param iterations the number of iterations.
  31508. * @param fn the function to run each iteration
  31509. * @param successCallback the callback that will be called upon succesful execution
  31510. * @param offset starting offset.
  31511. * @returns the created async loop object
  31512. */
  31513. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31514. /**
  31515. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31516. * @param iterations total number of iterations
  31517. * @param syncedIterations number of synchronous iterations in each async iteration.
  31518. * @param fn the function to call each iteration.
  31519. * @param callback a success call back that will be called when iterating stops.
  31520. * @param breakFunction a break condition (optional)
  31521. * @param timeout timeout settings for the setTimeout function. default - 0.
  31522. * @returns the created async loop object
  31523. */
  31524. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31525. }
  31526. }
  31527. declare module BABYLON {
  31528. /** @hidden */
  31529. export interface ICollisionCoordinator {
  31530. createCollider(): Collider;
  31531. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31532. init(scene: Scene): void;
  31533. }
  31534. /** @hidden */
  31535. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31536. private _scene;
  31537. private _scaledPosition;
  31538. private _scaledVelocity;
  31539. private _finalPosition;
  31540. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31541. createCollider(): Collider;
  31542. init(scene: Scene): void;
  31543. private _collideWithWorld;
  31544. }
  31545. }
  31546. declare module BABYLON {
  31547. /**
  31548. * Class used to manage all inputs for the scene.
  31549. */
  31550. export class InputManager {
  31551. /** The distance in pixel that you have to move to prevent some events */
  31552. static DragMovementThreshold: number;
  31553. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31554. static LongPressDelay: number;
  31555. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31556. static DoubleClickDelay: number;
  31557. /** If you need to check double click without raising a single click at first click, enable this flag */
  31558. static ExclusiveDoubleClickMode: boolean;
  31559. private _wheelEventName;
  31560. private _onPointerMove;
  31561. private _onPointerDown;
  31562. private _onPointerUp;
  31563. private _initClickEvent;
  31564. private _initActionManager;
  31565. private _delayedSimpleClick;
  31566. private _delayedSimpleClickTimeout;
  31567. private _previousDelayedSimpleClickTimeout;
  31568. private _meshPickProceed;
  31569. private _previousButtonPressed;
  31570. private _currentPickResult;
  31571. private _previousPickResult;
  31572. private _totalPointersPressed;
  31573. private _doubleClickOccured;
  31574. private _pointerOverMesh;
  31575. private _pickedDownMesh;
  31576. private _pickedUpMesh;
  31577. private _pointerX;
  31578. private _pointerY;
  31579. private _unTranslatedPointerX;
  31580. private _unTranslatedPointerY;
  31581. private _startingPointerPosition;
  31582. private _previousStartingPointerPosition;
  31583. private _startingPointerTime;
  31584. private _previousStartingPointerTime;
  31585. private _pointerCaptures;
  31586. private _onKeyDown;
  31587. private _onKeyUp;
  31588. private _onCanvasFocusObserver;
  31589. private _onCanvasBlurObserver;
  31590. private _scene;
  31591. /**
  31592. * Creates a new InputManager
  31593. * @param scene defines the hosting scene
  31594. */
  31595. constructor(scene: Scene);
  31596. /**
  31597. * Gets the mesh that is currently under the pointer
  31598. */
  31599. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31600. /**
  31601. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31602. */
  31603. readonly unTranslatedPointer: Vector2;
  31604. /**
  31605. * Gets or sets the current on-screen X position of the pointer
  31606. */
  31607. pointerX: number;
  31608. /**
  31609. * Gets or sets the current on-screen Y position of the pointer
  31610. */
  31611. pointerY: number;
  31612. private _updatePointerPosition;
  31613. private _processPointerMove;
  31614. private _setRayOnPointerInfo;
  31615. private _checkPrePointerObservable;
  31616. /**
  31617. * Use this method to simulate a pointer move on a mesh
  31618. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31619. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31620. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31621. */
  31622. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31623. /**
  31624. * Use this method to simulate a pointer down on a mesh
  31625. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31626. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31627. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31628. */
  31629. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31630. private _processPointerDown;
  31631. /** @hidden */
  31632. _isPointerSwiping(): boolean;
  31633. /**
  31634. * Use this method to simulate a pointer up on a mesh
  31635. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31636. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31637. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31638. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31639. */
  31640. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31641. private _processPointerUp;
  31642. /**
  31643. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31644. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31645. * @returns true if the pointer was captured
  31646. */
  31647. isPointerCaptured(pointerId?: number): boolean;
  31648. /**
  31649. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31650. * @param attachUp defines if you want to attach events to pointerup
  31651. * @param attachDown defines if you want to attach events to pointerdown
  31652. * @param attachMove defines if you want to attach events to pointermove
  31653. */
  31654. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31655. /**
  31656. * Detaches all event handlers
  31657. */
  31658. detachControl(): void;
  31659. /**
  31660. * Force the value of meshUnderPointer
  31661. * @param mesh defines the mesh to use
  31662. */
  31663. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31664. /**
  31665. * Gets the mesh under the pointer
  31666. * @returns a Mesh or null if no mesh is under the pointer
  31667. */
  31668. getPointerOverMesh(): Nullable<AbstractMesh>;
  31669. }
  31670. }
  31671. declare module BABYLON {
  31672. /**
  31673. * This class defines the direct association between an animation and a target
  31674. */
  31675. export class TargetedAnimation {
  31676. /**
  31677. * Animation to perform
  31678. */
  31679. animation: Animation;
  31680. /**
  31681. * Target to animate
  31682. */
  31683. target: any;
  31684. }
  31685. /**
  31686. * Use this class to create coordinated animations on multiple targets
  31687. */
  31688. export class AnimationGroup implements IDisposable {
  31689. /** The name of the animation group */
  31690. name: string;
  31691. private _scene;
  31692. private _targetedAnimations;
  31693. private _animatables;
  31694. private _from;
  31695. private _to;
  31696. private _isStarted;
  31697. private _isPaused;
  31698. private _speedRatio;
  31699. private _loopAnimation;
  31700. /**
  31701. * Gets or sets the unique id of the node
  31702. */
  31703. uniqueId: number;
  31704. /**
  31705. * This observable will notify when one animation have ended
  31706. */
  31707. onAnimationEndObservable: Observable<TargetedAnimation>;
  31708. /**
  31709. * Observer raised when one animation loops
  31710. */
  31711. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31712. /**
  31713. * This observable will notify when all animations have ended.
  31714. */
  31715. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31716. /**
  31717. * This observable will notify when all animations have paused.
  31718. */
  31719. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31720. /**
  31721. * This observable will notify when all animations are playing.
  31722. */
  31723. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31724. /**
  31725. * Gets the first frame
  31726. */
  31727. readonly from: number;
  31728. /**
  31729. * Gets the last frame
  31730. */
  31731. readonly to: number;
  31732. /**
  31733. * Define if the animations are started
  31734. */
  31735. readonly isStarted: boolean;
  31736. /**
  31737. * Gets a value indicating that the current group is playing
  31738. */
  31739. readonly isPlaying: boolean;
  31740. /**
  31741. * Gets or sets the speed ratio to use for all animations
  31742. */
  31743. /**
  31744. * Gets or sets the speed ratio to use for all animations
  31745. */
  31746. speedRatio: number;
  31747. /**
  31748. * Gets or sets if all animations should loop or not
  31749. */
  31750. loopAnimation: boolean;
  31751. /**
  31752. * Gets the targeted animations for this animation group
  31753. */
  31754. readonly targetedAnimations: Array<TargetedAnimation>;
  31755. /**
  31756. * returning the list of animatables controlled by this animation group.
  31757. */
  31758. readonly animatables: Array<Animatable>;
  31759. /**
  31760. * Instantiates a new Animation Group.
  31761. * This helps managing several animations at once.
  31762. * @see http://doc.babylonjs.com/how_to/group
  31763. * @param name Defines the name of the group
  31764. * @param scene Defines the scene the group belongs to
  31765. */
  31766. constructor(
  31767. /** The name of the animation group */
  31768. name: string, scene?: Nullable<Scene>);
  31769. /**
  31770. * Add an animation (with its target) in the group
  31771. * @param animation defines the animation we want to add
  31772. * @param target defines the target of the animation
  31773. * @returns the TargetedAnimation object
  31774. */
  31775. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31776. /**
  31777. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31778. * It can add constant keys at begin or end
  31779. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31780. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31781. * @returns the animation group
  31782. */
  31783. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31784. /**
  31785. * Start all animations on given targets
  31786. * @param loop defines if animations must loop
  31787. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31788. * @param from defines the from key (optional)
  31789. * @param to defines the to key (optional)
  31790. * @returns the current animation group
  31791. */
  31792. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31793. /**
  31794. * Pause all animations
  31795. * @returns the animation group
  31796. */
  31797. pause(): AnimationGroup;
  31798. /**
  31799. * Play all animations to initial state
  31800. * This function will start() the animations if they were not started or will restart() them if they were paused
  31801. * @param loop defines if animations must loop
  31802. * @returns the animation group
  31803. */
  31804. play(loop?: boolean): AnimationGroup;
  31805. /**
  31806. * Reset all animations to initial state
  31807. * @returns the animation group
  31808. */
  31809. reset(): AnimationGroup;
  31810. /**
  31811. * Restart animations from key 0
  31812. * @returns the animation group
  31813. */
  31814. restart(): AnimationGroup;
  31815. /**
  31816. * Stop all animations
  31817. * @returns the animation group
  31818. */
  31819. stop(): AnimationGroup;
  31820. /**
  31821. * Set animation weight for all animatables
  31822. * @param weight defines the weight to use
  31823. * @return the animationGroup
  31824. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31825. */
  31826. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31827. /**
  31828. * Synchronize and normalize all animatables with a source animatable
  31829. * @param root defines the root animatable to synchronize with
  31830. * @return the animationGroup
  31831. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31832. */
  31833. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31834. /**
  31835. * Goes to a specific frame in this animation group
  31836. * @param frame the frame number to go to
  31837. * @return the animationGroup
  31838. */
  31839. goToFrame(frame: number): AnimationGroup;
  31840. /**
  31841. * Dispose all associated resources
  31842. */
  31843. dispose(): void;
  31844. private _checkAnimationGroupEnded;
  31845. /**
  31846. * Clone the current animation group and returns a copy
  31847. * @param newName defines the name of the new group
  31848. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31849. * @returns the new aniamtion group
  31850. */
  31851. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31852. /**
  31853. * Returns a new AnimationGroup object parsed from the source provided.
  31854. * @param parsedAnimationGroup defines the source
  31855. * @param scene defines the scene that will receive the animationGroup
  31856. * @returns a new AnimationGroup
  31857. */
  31858. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31859. /**
  31860. * Returns the string "AnimationGroup"
  31861. * @returns "AnimationGroup"
  31862. */
  31863. getClassName(): string;
  31864. /**
  31865. * Creates a detailled string about the object
  31866. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31867. * @returns a string representing the object
  31868. */
  31869. toString(fullDetails?: boolean): string;
  31870. }
  31871. }
  31872. declare module BABYLON {
  31873. /**
  31874. * Define an interface for all classes that will hold resources
  31875. */
  31876. export interface IDisposable {
  31877. /**
  31878. * Releases all held resources
  31879. */
  31880. dispose(): void;
  31881. }
  31882. /** Interface defining initialization parameters for Scene class */
  31883. export interface SceneOptions {
  31884. /**
  31885. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31886. * It will improve performance when the number of geometries becomes important.
  31887. */
  31888. useGeometryUniqueIdsMap?: boolean;
  31889. /**
  31890. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31891. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31892. */
  31893. useMaterialMeshMap?: boolean;
  31894. /**
  31895. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31896. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31897. */
  31898. useClonedMeshhMap?: boolean;
  31899. }
  31900. /**
  31901. * Represents a scene to be rendered by the engine.
  31902. * @see http://doc.babylonjs.com/features/scene
  31903. */
  31904. export class Scene extends AbstractScene implements IAnimatable {
  31905. private static _uniqueIdCounter;
  31906. /** The fog is deactivated */
  31907. static readonly FOGMODE_NONE: number;
  31908. /** The fog density is following an exponential function */
  31909. static readonly FOGMODE_EXP: number;
  31910. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31911. static readonly FOGMODE_EXP2: number;
  31912. /** The fog density is following a linear function. */
  31913. static readonly FOGMODE_LINEAR: number;
  31914. /**
  31915. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31916. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31917. */
  31918. static MinDeltaTime: number;
  31919. /**
  31920. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31921. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31922. */
  31923. static MaxDeltaTime: number;
  31924. /**
  31925. * Factory used to create the default material.
  31926. * @param name The name of the material to create
  31927. * @param scene The scene to create the material for
  31928. * @returns The default material
  31929. */
  31930. static DefaultMaterialFactory(scene: Scene): Material;
  31931. /**
  31932. * Factory used to create the a collision coordinator.
  31933. * @returns The collision coordinator
  31934. */
  31935. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31936. /** @hidden */
  31937. _inputManager: InputManager;
  31938. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31939. cameraToUseForPointers: Nullable<Camera>;
  31940. /** @hidden */
  31941. readonly _isScene: boolean;
  31942. /**
  31943. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31944. */
  31945. autoClear: boolean;
  31946. /**
  31947. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31948. */
  31949. autoClearDepthAndStencil: boolean;
  31950. /**
  31951. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31952. */
  31953. clearColor: Color4;
  31954. /**
  31955. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31956. */
  31957. ambientColor: Color3;
  31958. /**
  31959. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31960. * It should only be one of the following (if not the default embedded one):
  31961. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31962. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31963. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31964. * The material properties need to be setup according to the type of texture in use.
  31965. */
  31966. environmentBRDFTexture: BaseTexture;
  31967. /** @hidden */
  31968. protected _environmentTexture: Nullable<BaseTexture>;
  31969. /**
  31970. * Texture used in all pbr material as the reflection texture.
  31971. * As in the majority of the scene they are the same (exception for multi room and so on),
  31972. * this is easier to reference from here than from all the materials.
  31973. */
  31974. /**
  31975. * Texture used in all pbr material as the reflection texture.
  31976. * As in the majority of the scene they are the same (exception for multi room and so on),
  31977. * this is easier to set here than in all the materials.
  31978. */
  31979. environmentTexture: Nullable<BaseTexture>;
  31980. /** @hidden */
  31981. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31982. /**
  31983. * Default image processing configuration used either in the rendering
  31984. * Forward main pass or through the imageProcessingPostProcess if present.
  31985. * As in the majority of the scene they are the same (exception for multi camera),
  31986. * this is easier to reference from here than from all the materials and post process.
  31987. *
  31988. * No setter as we it is a shared configuration, you can set the values instead.
  31989. */
  31990. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31991. private _forceWireframe;
  31992. /**
  31993. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31994. */
  31995. forceWireframe: boolean;
  31996. private _forcePointsCloud;
  31997. /**
  31998. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31999. */
  32000. forcePointsCloud: boolean;
  32001. /**
  32002. * Gets or sets the active clipplane 1
  32003. */
  32004. clipPlane: Nullable<Plane>;
  32005. /**
  32006. * Gets or sets the active clipplane 2
  32007. */
  32008. clipPlane2: Nullable<Plane>;
  32009. /**
  32010. * Gets or sets the active clipplane 3
  32011. */
  32012. clipPlane3: Nullable<Plane>;
  32013. /**
  32014. * Gets or sets the active clipplane 4
  32015. */
  32016. clipPlane4: Nullable<Plane>;
  32017. /**
  32018. * Gets or sets a boolean indicating if animations are enabled
  32019. */
  32020. animationsEnabled: boolean;
  32021. private _animationPropertiesOverride;
  32022. /**
  32023. * Gets or sets the animation properties override
  32024. */
  32025. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32026. /**
  32027. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32028. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32029. */
  32030. useConstantAnimationDeltaTime: boolean;
  32031. /**
  32032. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32033. * Please note that it requires to run a ray cast through the scene on every frame
  32034. */
  32035. constantlyUpdateMeshUnderPointer: boolean;
  32036. /**
  32037. * Defines the HTML cursor to use when hovering over interactive elements
  32038. */
  32039. hoverCursor: string;
  32040. /**
  32041. * Defines the HTML default cursor to use (empty by default)
  32042. */
  32043. defaultCursor: string;
  32044. /**
  32045. * This is used to call preventDefault() on pointer down
  32046. * in order to block unwanted artifacts like system double clicks
  32047. */
  32048. preventDefaultOnPointerDown: boolean;
  32049. /**
  32050. * This is used to call preventDefault() on pointer up
  32051. * in order to block unwanted artifacts like system double clicks
  32052. */
  32053. preventDefaultOnPointerUp: boolean;
  32054. /**
  32055. * Gets or sets user defined metadata
  32056. */
  32057. metadata: any;
  32058. /**
  32059. * For internal use only. Please do not use.
  32060. */
  32061. reservedDataStore: any;
  32062. /**
  32063. * Gets the name of the plugin used to load this scene (null by default)
  32064. */
  32065. loadingPluginName: string;
  32066. /**
  32067. * Use this array to add regular expressions used to disable offline support for specific urls
  32068. */
  32069. disableOfflineSupportExceptionRules: RegExp[];
  32070. /**
  32071. * An event triggered when the scene is disposed.
  32072. */
  32073. onDisposeObservable: Observable<Scene>;
  32074. private _onDisposeObserver;
  32075. /** Sets a function to be executed when this scene is disposed. */
  32076. onDispose: () => void;
  32077. /**
  32078. * An event triggered before rendering the scene (right after animations and physics)
  32079. */
  32080. onBeforeRenderObservable: Observable<Scene>;
  32081. private _onBeforeRenderObserver;
  32082. /** Sets a function to be executed before rendering this scene */
  32083. beforeRender: Nullable<() => void>;
  32084. /**
  32085. * An event triggered after rendering the scene
  32086. */
  32087. onAfterRenderObservable: Observable<Scene>;
  32088. private _onAfterRenderObserver;
  32089. /** Sets a function to be executed after rendering this scene */
  32090. afterRender: Nullable<() => void>;
  32091. /**
  32092. * An event triggered before animating the scene
  32093. */
  32094. onBeforeAnimationsObservable: Observable<Scene>;
  32095. /**
  32096. * An event triggered after animations processing
  32097. */
  32098. onAfterAnimationsObservable: Observable<Scene>;
  32099. /**
  32100. * An event triggered before draw calls are ready to be sent
  32101. */
  32102. onBeforeDrawPhaseObservable: Observable<Scene>;
  32103. /**
  32104. * An event triggered after draw calls have been sent
  32105. */
  32106. onAfterDrawPhaseObservable: Observable<Scene>;
  32107. /**
  32108. * An event triggered when the scene is ready
  32109. */
  32110. onReadyObservable: Observable<Scene>;
  32111. /**
  32112. * An event triggered before rendering a camera
  32113. */
  32114. onBeforeCameraRenderObservable: Observable<Camera>;
  32115. private _onBeforeCameraRenderObserver;
  32116. /** Sets a function to be executed before rendering a camera*/
  32117. beforeCameraRender: () => void;
  32118. /**
  32119. * An event triggered after rendering a camera
  32120. */
  32121. onAfterCameraRenderObservable: Observable<Camera>;
  32122. private _onAfterCameraRenderObserver;
  32123. /** Sets a function to be executed after rendering a camera*/
  32124. afterCameraRender: () => void;
  32125. /**
  32126. * An event triggered when active meshes evaluation is about to start
  32127. */
  32128. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32129. /**
  32130. * An event triggered when active meshes evaluation is done
  32131. */
  32132. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32133. /**
  32134. * An event triggered when particles rendering is about to start
  32135. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32136. */
  32137. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32138. /**
  32139. * An event triggered when particles rendering is done
  32140. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32141. */
  32142. onAfterParticlesRenderingObservable: Observable<Scene>;
  32143. /**
  32144. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32145. */
  32146. onDataLoadedObservable: Observable<Scene>;
  32147. /**
  32148. * An event triggered when a camera is created
  32149. */
  32150. onNewCameraAddedObservable: Observable<Camera>;
  32151. /**
  32152. * An event triggered when a camera is removed
  32153. */
  32154. onCameraRemovedObservable: Observable<Camera>;
  32155. /**
  32156. * An event triggered when a light is created
  32157. */
  32158. onNewLightAddedObservable: Observable<Light>;
  32159. /**
  32160. * An event triggered when a light is removed
  32161. */
  32162. onLightRemovedObservable: Observable<Light>;
  32163. /**
  32164. * An event triggered when a geometry is created
  32165. */
  32166. onNewGeometryAddedObservable: Observable<Geometry>;
  32167. /**
  32168. * An event triggered when a geometry is removed
  32169. */
  32170. onGeometryRemovedObservable: Observable<Geometry>;
  32171. /**
  32172. * An event triggered when a transform node is created
  32173. */
  32174. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32175. /**
  32176. * An event triggered when a transform node is removed
  32177. */
  32178. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32179. /**
  32180. * An event triggered when a mesh is created
  32181. */
  32182. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32183. /**
  32184. * An event triggered when a mesh is removed
  32185. */
  32186. onMeshRemovedObservable: Observable<AbstractMesh>;
  32187. /**
  32188. * An event triggered when a skeleton is created
  32189. */
  32190. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32191. /**
  32192. * An event triggered when a skeleton is removed
  32193. */
  32194. onSkeletonRemovedObservable: Observable<Skeleton>;
  32195. /**
  32196. * An event triggered when a material is created
  32197. */
  32198. onNewMaterialAddedObservable: Observable<Material>;
  32199. /**
  32200. * An event triggered when a material is removed
  32201. */
  32202. onMaterialRemovedObservable: Observable<Material>;
  32203. /**
  32204. * An event triggered when a texture is created
  32205. */
  32206. onNewTextureAddedObservable: Observable<BaseTexture>;
  32207. /**
  32208. * An event triggered when a texture is removed
  32209. */
  32210. onTextureRemovedObservable: Observable<BaseTexture>;
  32211. /**
  32212. * An event triggered when render targets are about to be rendered
  32213. * Can happen multiple times per frame.
  32214. */
  32215. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32216. /**
  32217. * An event triggered when render targets were rendered.
  32218. * Can happen multiple times per frame.
  32219. */
  32220. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32221. /**
  32222. * An event triggered before calculating deterministic simulation step
  32223. */
  32224. onBeforeStepObservable: Observable<Scene>;
  32225. /**
  32226. * An event triggered after calculating deterministic simulation step
  32227. */
  32228. onAfterStepObservable: Observable<Scene>;
  32229. /**
  32230. * An event triggered when the activeCamera property is updated
  32231. */
  32232. onActiveCameraChanged: Observable<Scene>;
  32233. /**
  32234. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32235. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32236. * 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)
  32237. */
  32238. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32239. /**
  32240. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32241. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32242. * 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)
  32243. */
  32244. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32245. /**
  32246. * This Observable will when a mesh has been imported into the scene.
  32247. */
  32248. onMeshImportedObservable: Observable<AbstractMesh>;
  32249. /**
  32250. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32251. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32252. */
  32253. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32254. /** @hidden */
  32255. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32256. /**
  32257. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32258. */
  32259. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32260. /**
  32261. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32262. */
  32263. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32264. /**
  32265. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32266. */
  32267. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32268. /** Callback called when a pointer move is detected */
  32269. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32270. /** Callback called when a pointer down is detected */
  32271. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32272. /** Callback called when a pointer up is detected */
  32273. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32274. /** Callback called when a pointer pick is detected */
  32275. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32276. /**
  32277. * 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).
  32278. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32279. */
  32280. onPrePointerObservable: Observable<PointerInfoPre>;
  32281. /**
  32282. * Observable event triggered each time an input event is received from the rendering canvas
  32283. */
  32284. onPointerObservable: Observable<PointerInfo>;
  32285. /**
  32286. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32287. */
  32288. readonly unTranslatedPointer: Vector2;
  32289. /**
  32290. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32291. */
  32292. static DragMovementThreshold: number;
  32293. /**
  32294. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32295. */
  32296. static LongPressDelay: number;
  32297. /**
  32298. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32299. */
  32300. static DoubleClickDelay: number;
  32301. /** If you need to check double click without raising a single click at first click, enable this flag */
  32302. static ExclusiveDoubleClickMode: boolean;
  32303. /** @hidden */
  32304. _mirroredCameraPosition: Nullable<Vector3>;
  32305. /**
  32306. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32307. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32308. */
  32309. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32310. /**
  32311. * Observable event triggered each time an keyboard event is received from the hosting window
  32312. */
  32313. onKeyboardObservable: Observable<KeyboardInfo>;
  32314. private _useRightHandedSystem;
  32315. /**
  32316. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32317. */
  32318. useRightHandedSystem: boolean;
  32319. private _timeAccumulator;
  32320. private _currentStepId;
  32321. private _currentInternalStep;
  32322. /**
  32323. * Sets the step Id used by deterministic lock step
  32324. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32325. * @param newStepId defines the step Id
  32326. */
  32327. setStepId(newStepId: number): void;
  32328. /**
  32329. * Gets the step Id used by deterministic lock step
  32330. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32331. * @returns the step Id
  32332. */
  32333. getStepId(): number;
  32334. /**
  32335. * Gets the internal step used by deterministic lock step
  32336. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32337. * @returns the internal step
  32338. */
  32339. getInternalStep(): number;
  32340. private _fogEnabled;
  32341. /**
  32342. * Gets or sets a boolean indicating if fog is enabled on this scene
  32343. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32344. * (Default is true)
  32345. */
  32346. fogEnabled: boolean;
  32347. private _fogMode;
  32348. /**
  32349. * Gets or sets the fog mode to use
  32350. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32351. * | mode | value |
  32352. * | --- | --- |
  32353. * | FOGMODE_NONE | 0 |
  32354. * | FOGMODE_EXP | 1 |
  32355. * | FOGMODE_EXP2 | 2 |
  32356. * | FOGMODE_LINEAR | 3 |
  32357. */
  32358. fogMode: number;
  32359. /**
  32360. * Gets or sets the fog color to use
  32361. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32362. * (Default is Color3(0.2, 0.2, 0.3))
  32363. */
  32364. fogColor: Color3;
  32365. /**
  32366. * Gets or sets the fog density to use
  32367. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32368. * (Default is 0.1)
  32369. */
  32370. fogDensity: number;
  32371. /**
  32372. * Gets or sets the fog start distance to use
  32373. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32374. * (Default is 0)
  32375. */
  32376. fogStart: number;
  32377. /**
  32378. * Gets or sets the fog end distance to use
  32379. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32380. * (Default is 1000)
  32381. */
  32382. fogEnd: number;
  32383. private _shadowsEnabled;
  32384. /**
  32385. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32386. */
  32387. shadowsEnabled: boolean;
  32388. private _lightsEnabled;
  32389. /**
  32390. * Gets or sets a boolean indicating if lights are enabled on this scene
  32391. */
  32392. lightsEnabled: boolean;
  32393. /** All of the active cameras added to this scene. */
  32394. activeCameras: Camera[];
  32395. /** @hidden */
  32396. _activeCamera: Nullable<Camera>;
  32397. /** Gets or sets the current active camera */
  32398. activeCamera: Nullable<Camera>;
  32399. private _defaultMaterial;
  32400. /** The default material used on meshes when no material is affected */
  32401. /** The default material used on meshes when no material is affected */
  32402. defaultMaterial: Material;
  32403. private _texturesEnabled;
  32404. /**
  32405. * Gets or sets a boolean indicating if textures are enabled on this scene
  32406. */
  32407. texturesEnabled: boolean;
  32408. /**
  32409. * Gets or sets a boolean indicating if particles are enabled on this scene
  32410. */
  32411. particlesEnabled: boolean;
  32412. /**
  32413. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32414. */
  32415. spritesEnabled: boolean;
  32416. private _skeletonsEnabled;
  32417. /**
  32418. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32419. */
  32420. skeletonsEnabled: boolean;
  32421. /**
  32422. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32423. */
  32424. lensFlaresEnabled: boolean;
  32425. /**
  32426. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32427. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32428. */
  32429. collisionsEnabled: boolean;
  32430. private _collisionCoordinator;
  32431. /** @hidden */
  32432. readonly collisionCoordinator: ICollisionCoordinator;
  32433. /**
  32434. * Defines the gravity applied to this scene (used only for collisions)
  32435. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32436. */
  32437. gravity: Vector3;
  32438. /**
  32439. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32440. */
  32441. postProcessesEnabled: boolean;
  32442. /**
  32443. * The list of postprocesses added to the scene
  32444. */
  32445. postProcesses: PostProcess[];
  32446. /**
  32447. * Gets the current postprocess manager
  32448. */
  32449. postProcessManager: PostProcessManager;
  32450. /**
  32451. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32452. */
  32453. renderTargetsEnabled: boolean;
  32454. /**
  32455. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32456. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32457. */
  32458. dumpNextRenderTargets: boolean;
  32459. /**
  32460. * The list of user defined render targets added to the scene
  32461. */
  32462. customRenderTargets: RenderTargetTexture[];
  32463. /**
  32464. * Defines if texture loading must be delayed
  32465. * If true, textures will only be loaded when they need to be rendered
  32466. */
  32467. useDelayedTextureLoading: boolean;
  32468. /**
  32469. * Gets the list of meshes imported to the scene through SceneLoader
  32470. */
  32471. importedMeshesFiles: String[];
  32472. /**
  32473. * Gets or sets a boolean indicating if probes are enabled on this scene
  32474. */
  32475. probesEnabled: boolean;
  32476. /**
  32477. * Gets or sets the current offline provider to use to store scene data
  32478. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32479. */
  32480. offlineProvider: IOfflineProvider;
  32481. /**
  32482. * Gets or sets the action manager associated with the scene
  32483. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32484. */
  32485. actionManager: AbstractActionManager;
  32486. private _meshesForIntersections;
  32487. /**
  32488. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32489. */
  32490. proceduralTexturesEnabled: boolean;
  32491. private _engine;
  32492. private _totalVertices;
  32493. /** @hidden */
  32494. _activeIndices: PerfCounter;
  32495. /** @hidden */
  32496. _activeParticles: PerfCounter;
  32497. /** @hidden */
  32498. _activeBones: PerfCounter;
  32499. private _animationRatio;
  32500. /** @hidden */
  32501. _animationTimeLast: number;
  32502. /** @hidden */
  32503. _animationTime: number;
  32504. /**
  32505. * Gets or sets a general scale for animation speed
  32506. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32507. */
  32508. animationTimeScale: number;
  32509. /** @hidden */
  32510. _cachedMaterial: Nullable<Material>;
  32511. /** @hidden */
  32512. _cachedEffect: Nullable<Effect>;
  32513. /** @hidden */
  32514. _cachedVisibility: Nullable<number>;
  32515. private _renderId;
  32516. private _frameId;
  32517. private _executeWhenReadyTimeoutId;
  32518. private _intermediateRendering;
  32519. private _viewUpdateFlag;
  32520. private _projectionUpdateFlag;
  32521. /** @hidden */
  32522. _toBeDisposed: Nullable<IDisposable>[];
  32523. private _activeRequests;
  32524. /** @hidden */
  32525. _pendingData: any[];
  32526. private _isDisposed;
  32527. /**
  32528. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32529. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32530. */
  32531. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32532. private _activeMeshes;
  32533. private _processedMaterials;
  32534. private _renderTargets;
  32535. /** @hidden */
  32536. _activeParticleSystems: SmartArray<IParticleSystem>;
  32537. private _activeSkeletons;
  32538. private _softwareSkinnedMeshes;
  32539. private _renderingManager;
  32540. /** @hidden */
  32541. _activeAnimatables: Animatable[];
  32542. private _transformMatrix;
  32543. private _sceneUbo;
  32544. /** @hidden */
  32545. _viewMatrix: Matrix;
  32546. private _projectionMatrix;
  32547. /** @hidden */
  32548. _forcedViewPosition: Nullable<Vector3>;
  32549. /** @hidden */
  32550. _frustumPlanes: Plane[];
  32551. /**
  32552. * Gets the list of frustum planes (built from the active camera)
  32553. */
  32554. readonly frustumPlanes: Plane[];
  32555. /**
  32556. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32557. * This is useful if there are more lights that the maximum simulteanous authorized
  32558. */
  32559. requireLightSorting: boolean;
  32560. /** @hidden */
  32561. readonly useMaterialMeshMap: boolean;
  32562. /** @hidden */
  32563. readonly useClonedMeshhMap: boolean;
  32564. private _externalData;
  32565. private _uid;
  32566. /**
  32567. * @hidden
  32568. * Backing store of defined scene components.
  32569. */
  32570. _components: ISceneComponent[];
  32571. /**
  32572. * @hidden
  32573. * Backing store of defined scene components.
  32574. */
  32575. _serializableComponents: ISceneSerializableComponent[];
  32576. /**
  32577. * List of components to register on the next registration step.
  32578. */
  32579. private _transientComponents;
  32580. /**
  32581. * Registers the transient components if needed.
  32582. */
  32583. private _registerTransientComponents;
  32584. /**
  32585. * @hidden
  32586. * Add a component to the scene.
  32587. * Note that the ccomponent could be registered on th next frame if this is called after
  32588. * the register component stage.
  32589. * @param component Defines the component to add to the scene
  32590. */
  32591. _addComponent(component: ISceneComponent): void;
  32592. /**
  32593. * @hidden
  32594. * Gets a component from the scene.
  32595. * @param name defines the name of the component to retrieve
  32596. * @returns the component or null if not present
  32597. */
  32598. _getComponent(name: string): Nullable<ISceneComponent>;
  32599. /**
  32600. * @hidden
  32601. * Defines the actions happening before camera updates.
  32602. */
  32603. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32604. /**
  32605. * @hidden
  32606. * Defines the actions happening before clear the canvas.
  32607. */
  32608. _beforeClearStage: Stage<SimpleStageAction>;
  32609. /**
  32610. * @hidden
  32611. * Defines the actions when collecting render targets for the frame.
  32612. */
  32613. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32614. /**
  32615. * @hidden
  32616. * Defines the actions happening for one camera in the frame.
  32617. */
  32618. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32619. /**
  32620. * @hidden
  32621. * Defines the actions happening during the per mesh ready checks.
  32622. */
  32623. _isReadyForMeshStage: Stage<MeshStageAction>;
  32624. /**
  32625. * @hidden
  32626. * Defines the actions happening before evaluate active mesh checks.
  32627. */
  32628. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32629. /**
  32630. * @hidden
  32631. * Defines the actions happening during the evaluate sub mesh checks.
  32632. */
  32633. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32634. /**
  32635. * @hidden
  32636. * Defines the actions happening during the active mesh stage.
  32637. */
  32638. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32639. /**
  32640. * @hidden
  32641. * Defines the actions happening during the per camera render target step.
  32642. */
  32643. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32644. /**
  32645. * @hidden
  32646. * Defines the actions happening just before the active camera is drawing.
  32647. */
  32648. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32649. /**
  32650. * @hidden
  32651. * Defines the actions happening just before a render target is drawing.
  32652. */
  32653. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32654. /**
  32655. * @hidden
  32656. * Defines the actions happening just before a rendering group is drawing.
  32657. */
  32658. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32659. /**
  32660. * @hidden
  32661. * Defines the actions happening just before a mesh is drawing.
  32662. */
  32663. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32664. /**
  32665. * @hidden
  32666. * Defines the actions happening just after a mesh has been drawn.
  32667. */
  32668. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32669. /**
  32670. * @hidden
  32671. * Defines the actions happening just after a rendering group has been drawn.
  32672. */
  32673. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32674. /**
  32675. * @hidden
  32676. * Defines the actions happening just after the active camera has been drawn.
  32677. */
  32678. _afterCameraDrawStage: Stage<CameraStageAction>;
  32679. /**
  32680. * @hidden
  32681. * Defines the actions happening just after a render target has been drawn.
  32682. */
  32683. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32684. /**
  32685. * @hidden
  32686. * Defines the actions happening just after rendering all cameras and computing intersections.
  32687. */
  32688. _afterRenderStage: Stage<SimpleStageAction>;
  32689. /**
  32690. * @hidden
  32691. * Defines the actions happening when a pointer move event happens.
  32692. */
  32693. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32694. /**
  32695. * @hidden
  32696. * Defines the actions happening when a pointer down event happens.
  32697. */
  32698. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32699. /**
  32700. * @hidden
  32701. * Defines the actions happening when a pointer up event happens.
  32702. */
  32703. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32704. /**
  32705. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32706. */
  32707. private geometriesByUniqueId;
  32708. /**
  32709. * Creates a new Scene
  32710. * @param engine defines the engine to use to render this scene
  32711. * @param options defines the scene options
  32712. */
  32713. constructor(engine: Engine, options?: SceneOptions);
  32714. /**
  32715. * Gets a string idenfifying the name of the class
  32716. * @returns "Scene" string
  32717. */
  32718. getClassName(): string;
  32719. private _defaultMeshCandidates;
  32720. /**
  32721. * @hidden
  32722. */
  32723. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32724. private _defaultSubMeshCandidates;
  32725. /**
  32726. * @hidden
  32727. */
  32728. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32729. /**
  32730. * Sets the default candidate providers for the scene.
  32731. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32732. * and getCollidingSubMeshCandidates to their default function
  32733. */
  32734. setDefaultCandidateProviders(): void;
  32735. /**
  32736. * Gets the mesh that is currently under the pointer
  32737. */
  32738. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32739. /**
  32740. * Gets or sets the current on-screen X position of the pointer
  32741. */
  32742. pointerX: number;
  32743. /**
  32744. * Gets or sets the current on-screen Y position of the pointer
  32745. */
  32746. pointerY: number;
  32747. /**
  32748. * Gets the cached material (ie. the latest rendered one)
  32749. * @returns the cached material
  32750. */
  32751. getCachedMaterial(): Nullable<Material>;
  32752. /**
  32753. * Gets the cached effect (ie. the latest rendered one)
  32754. * @returns the cached effect
  32755. */
  32756. getCachedEffect(): Nullable<Effect>;
  32757. /**
  32758. * Gets the cached visibility state (ie. the latest rendered one)
  32759. * @returns the cached visibility state
  32760. */
  32761. getCachedVisibility(): Nullable<number>;
  32762. /**
  32763. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32764. * @param material defines the current material
  32765. * @param effect defines the current effect
  32766. * @param visibility defines the current visibility state
  32767. * @returns true if one parameter is not cached
  32768. */
  32769. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32770. /**
  32771. * Gets the engine associated with the scene
  32772. * @returns an Engine
  32773. */
  32774. getEngine(): Engine;
  32775. /**
  32776. * Gets the total number of vertices rendered per frame
  32777. * @returns the total number of vertices rendered per frame
  32778. */
  32779. getTotalVertices(): number;
  32780. /**
  32781. * Gets the performance counter for total vertices
  32782. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32783. */
  32784. readonly totalVerticesPerfCounter: PerfCounter;
  32785. /**
  32786. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32787. * @returns the total number of active indices rendered per frame
  32788. */
  32789. getActiveIndices(): number;
  32790. /**
  32791. * Gets the performance counter for active indices
  32792. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32793. */
  32794. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32795. /**
  32796. * Gets the total number of active particles rendered per frame
  32797. * @returns the total number of active particles rendered per frame
  32798. */
  32799. getActiveParticles(): number;
  32800. /**
  32801. * Gets the performance counter for active particles
  32802. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32803. */
  32804. readonly activeParticlesPerfCounter: PerfCounter;
  32805. /**
  32806. * Gets the total number of active bones rendered per frame
  32807. * @returns the total number of active bones rendered per frame
  32808. */
  32809. getActiveBones(): number;
  32810. /**
  32811. * Gets the performance counter for active bones
  32812. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32813. */
  32814. readonly activeBonesPerfCounter: PerfCounter;
  32815. /**
  32816. * Gets the array of active meshes
  32817. * @returns an array of AbstractMesh
  32818. */
  32819. getActiveMeshes(): SmartArray<AbstractMesh>;
  32820. /**
  32821. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32822. * @returns a number
  32823. */
  32824. getAnimationRatio(): number;
  32825. /**
  32826. * Gets an unique Id for the current render phase
  32827. * @returns a number
  32828. */
  32829. getRenderId(): number;
  32830. /**
  32831. * Gets an unique Id for the current frame
  32832. * @returns a number
  32833. */
  32834. getFrameId(): number;
  32835. /** Call this function if you want to manually increment the render Id*/
  32836. incrementRenderId(): void;
  32837. private _createUbo;
  32838. /**
  32839. * Use this method to simulate a pointer move on a mesh
  32840. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32841. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32842. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32843. * @returns the current scene
  32844. */
  32845. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32846. /**
  32847. * Use this method to simulate a pointer down on a mesh
  32848. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32849. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32850. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32851. * @returns the current scene
  32852. */
  32853. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32854. /**
  32855. * Use this method to simulate a pointer up on a mesh
  32856. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32857. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32858. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32859. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32860. * @returns the current scene
  32861. */
  32862. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32863. /**
  32864. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32865. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32866. * @returns true if the pointer was captured
  32867. */
  32868. isPointerCaptured(pointerId?: number): boolean;
  32869. /**
  32870. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32871. * @param attachUp defines if you want to attach events to pointerup
  32872. * @param attachDown defines if you want to attach events to pointerdown
  32873. * @param attachMove defines if you want to attach events to pointermove
  32874. */
  32875. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32876. /** Detaches all event handlers*/
  32877. detachControl(): void;
  32878. /**
  32879. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32880. * Delay loaded resources are not taking in account
  32881. * @return true if all required resources are ready
  32882. */
  32883. isReady(): boolean;
  32884. /** Resets all cached information relative to material (including effect and visibility) */
  32885. resetCachedMaterial(): void;
  32886. /**
  32887. * Registers a function to be called before every frame render
  32888. * @param func defines the function to register
  32889. */
  32890. registerBeforeRender(func: () => void): void;
  32891. /**
  32892. * Unregisters a function called before every frame render
  32893. * @param func defines the function to unregister
  32894. */
  32895. unregisterBeforeRender(func: () => void): void;
  32896. /**
  32897. * Registers a function to be called after every frame render
  32898. * @param func defines the function to register
  32899. */
  32900. registerAfterRender(func: () => void): void;
  32901. /**
  32902. * Unregisters a function called after every frame render
  32903. * @param func defines the function to unregister
  32904. */
  32905. unregisterAfterRender(func: () => void): void;
  32906. private _executeOnceBeforeRender;
  32907. /**
  32908. * The provided function will run before render once and will be disposed afterwards.
  32909. * A timeout delay can be provided so that the function will be executed in N ms.
  32910. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32911. * @param func The function to be executed.
  32912. * @param timeout optional delay in ms
  32913. */
  32914. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32915. /** @hidden */
  32916. _addPendingData(data: any): void;
  32917. /** @hidden */
  32918. _removePendingData(data: any): void;
  32919. /**
  32920. * Returns the number of items waiting to be loaded
  32921. * @returns the number of items waiting to be loaded
  32922. */
  32923. getWaitingItemsCount(): number;
  32924. /**
  32925. * Returns a boolean indicating if the scene is still loading data
  32926. */
  32927. readonly isLoading: boolean;
  32928. /**
  32929. * Registers a function to be executed when the scene is ready
  32930. * @param {Function} func - the function to be executed
  32931. */
  32932. executeWhenReady(func: () => void): void;
  32933. /**
  32934. * Returns a promise that resolves when the scene is ready
  32935. * @returns A promise that resolves when the scene is ready
  32936. */
  32937. whenReadyAsync(): Promise<void>;
  32938. /** @hidden */
  32939. _checkIsReady(): void;
  32940. /**
  32941. * Gets all animatable attached to the scene
  32942. */
  32943. readonly animatables: Animatable[];
  32944. /**
  32945. * Resets the last animation time frame.
  32946. * Useful to override when animations start running when loading a scene for the first time.
  32947. */
  32948. resetLastAnimationTimeFrame(): void;
  32949. /**
  32950. * Gets the current view matrix
  32951. * @returns a Matrix
  32952. */
  32953. getViewMatrix(): Matrix;
  32954. /**
  32955. * Gets the current projection matrix
  32956. * @returns a Matrix
  32957. */
  32958. getProjectionMatrix(): Matrix;
  32959. /**
  32960. * Gets the current transform matrix
  32961. * @returns a Matrix made of View * Projection
  32962. */
  32963. getTransformMatrix(): Matrix;
  32964. /**
  32965. * Sets the current transform matrix
  32966. * @param viewL defines the View matrix to use
  32967. * @param projectionL defines the Projection matrix to use
  32968. * @param viewR defines the right View matrix to use (if provided)
  32969. * @param projectionR defines the right Projection matrix to use (if provided)
  32970. */
  32971. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32972. /**
  32973. * Gets the uniform buffer used to store scene data
  32974. * @returns a UniformBuffer
  32975. */
  32976. getSceneUniformBuffer(): UniformBuffer;
  32977. /**
  32978. * Gets an unique (relatively to the current scene) Id
  32979. * @returns an unique number for the scene
  32980. */
  32981. getUniqueId(): number;
  32982. /**
  32983. * Add a mesh to the list of scene's meshes
  32984. * @param newMesh defines the mesh to add
  32985. * @param recursive if all child meshes should also be added to the scene
  32986. */
  32987. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32988. /**
  32989. * Remove a mesh for the list of scene's meshes
  32990. * @param toRemove defines the mesh to remove
  32991. * @param recursive if all child meshes should also be removed from the scene
  32992. * @returns the index where the mesh was in the mesh list
  32993. */
  32994. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32995. /**
  32996. * Add a transform node to the list of scene's transform nodes
  32997. * @param newTransformNode defines the transform node to add
  32998. */
  32999. addTransformNode(newTransformNode: TransformNode): void;
  33000. /**
  33001. * Remove a transform node for the list of scene's transform nodes
  33002. * @param toRemove defines the transform node to remove
  33003. * @returns the index where the transform node was in the transform node list
  33004. */
  33005. removeTransformNode(toRemove: TransformNode): number;
  33006. /**
  33007. * Remove a skeleton for the list of scene's skeletons
  33008. * @param toRemove defines the skeleton to remove
  33009. * @returns the index where the skeleton was in the skeleton list
  33010. */
  33011. removeSkeleton(toRemove: Skeleton): number;
  33012. /**
  33013. * Remove a morph target for the list of scene's morph targets
  33014. * @param toRemove defines the morph target to remove
  33015. * @returns the index where the morph target was in the morph target list
  33016. */
  33017. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33018. /**
  33019. * Remove a light for the list of scene's lights
  33020. * @param toRemove defines the light to remove
  33021. * @returns the index where the light was in the light list
  33022. */
  33023. removeLight(toRemove: Light): number;
  33024. /**
  33025. * Remove a camera for the list of scene's cameras
  33026. * @param toRemove defines the camera to remove
  33027. * @returns the index where the camera was in the camera list
  33028. */
  33029. removeCamera(toRemove: Camera): number;
  33030. /**
  33031. * Remove a particle system for the list of scene's particle systems
  33032. * @param toRemove defines the particle system to remove
  33033. * @returns the index where the particle system was in the particle system list
  33034. */
  33035. removeParticleSystem(toRemove: IParticleSystem): number;
  33036. /**
  33037. * Remove a animation for the list of scene's animations
  33038. * @param toRemove defines the animation to remove
  33039. * @returns the index where the animation was in the animation list
  33040. */
  33041. removeAnimation(toRemove: Animation): number;
  33042. /**
  33043. * Will stop the animation of the given target
  33044. * @param target - the target
  33045. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33046. * @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)
  33047. */
  33048. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33049. /**
  33050. * Removes the given animation group from this scene.
  33051. * @param toRemove The animation group to remove
  33052. * @returns The index of the removed animation group
  33053. */
  33054. removeAnimationGroup(toRemove: AnimationGroup): number;
  33055. /**
  33056. * Removes the given multi-material from this scene.
  33057. * @param toRemove The multi-material to remove
  33058. * @returns The index of the removed multi-material
  33059. */
  33060. removeMultiMaterial(toRemove: MultiMaterial): number;
  33061. /**
  33062. * Removes the given material from this scene.
  33063. * @param toRemove The material to remove
  33064. * @returns The index of the removed material
  33065. */
  33066. removeMaterial(toRemove: Material): number;
  33067. /**
  33068. * Removes the given action manager from this scene.
  33069. * @param toRemove The action manager to remove
  33070. * @returns The index of the removed action manager
  33071. */
  33072. removeActionManager(toRemove: AbstractActionManager): number;
  33073. /**
  33074. * Removes the given texture from this scene.
  33075. * @param toRemove The texture to remove
  33076. * @returns The index of the removed texture
  33077. */
  33078. removeTexture(toRemove: BaseTexture): number;
  33079. /**
  33080. * Adds the given light to this scene
  33081. * @param newLight The light to add
  33082. */
  33083. addLight(newLight: Light): void;
  33084. /**
  33085. * Sorts the list list based on light priorities
  33086. */
  33087. sortLightsByPriority(): void;
  33088. /**
  33089. * Adds the given camera to this scene
  33090. * @param newCamera The camera to add
  33091. */
  33092. addCamera(newCamera: Camera): void;
  33093. /**
  33094. * Adds the given skeleton to this scene
  33095. * @param newSkeleton The skeleton to add
  33096. */
  33097. addSkeleton(newSkeleton: Skeleton): void;
  33098. /**
  33099. * Adds the given particle system to this scene
  33100. * @param newParticleSystem The particle system to add
  33101. */
  33102. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33103. /**
  33104. * Adds the given animation to this scene
  33105. * @param newAnimation The animation to add
  33106. */
  33107. addAnimation(newAnimation: Animation): void;
  33108. /**
  33109. * Adds the given animation group to this scene.
  33110. * @param newAnimationGroup The animation group to add
  33111. */
  33112. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33113. /**
  33114. * Adds the given multi-material to this scene
  33115. * @param newMultiMaterial The multi-material to add
  33116. */
  33117. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33118. /**
  33119. * Adds the given material to this scene
  33120. * @param newMaterial The material to add
  33121. */
  33122. addMaterial(newMaterial: Material): void;
  33123. /**
  33124. * Adds the given morph target to this scene
  33125. * @param newMorphTargetManager The morph target to add
  33126. */
  33127. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33128. /**
  33129. * Adds the given geometry to this scene
  33130. * @param newGeometry The geometry to add
  33131. */
  33132. addGeometry(newGeometry: Geometry): void;
  33133. /**
  33134. * Adds the given action manager to this scene
  33135. * @param newActionManager The action manager to add
  33136. */
  33137. addActionManager(newActionManager: AbstractActionManager): void;
  33138. /**
  33139. * Adds the given texture to this scene.
  33140. * @param newTexture The texture to add
  33141. */
  33142. addTexture(newTexture: BaseTexture): void;
  33143. /**
  33144. * Switch active camera
  33145. * @param newCamera defines the new active camera
  33146. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33147. */
  33148. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33149. /**
  33150. * sets the active camera of the scene using its ID
  33151. * @param id defines the camera's ID
  33152. * @return the new active camera or null if none found.
  33153. */
  33154. setActiveCameraByID(id: string): Nullable<Camera>;
  33155. /**
  33156. * sets the active camera of the scene using its name
  33157. * @param name defines the camera's name
  33158. * @returns the new active camera or null if none found.
  33159. */
  33160. setActiveCameraByName(name: string): Nullable<Camera>;
  33161. /**
  33162. * get an animation group using its name
  33163. * @param name defines the material's name
  33164. * @return the animation group or null if none found.
  33165. */
  33166. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33167. /**
  33168. * Get a material using its unique id
  33169. * @param uniqueId defines the material's unique id
  33170. * @return the material or null if none found.
  33171. */
  33172. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33173. /**
  33174. * get a material using its id
  33175. * @param id defines the material's ID
  33176. * @return the material or null if none found.
  33177. */
  33178. getMaterialByID(id: string): Nullable<Material>;
  33179. /**
  33180. * Gets a material using its name
  33181. * @param name defines the material's name
  33182. * @return the material or null if none found.
  33183. */
  33184. getMaterialByName(name: string): Nullable<Material>;
  33185. /**
  33186. * Gets a camera using its id
  33187. * @param id defines the id to look for
  33188. * @returns the camera or null if not found
  33189. */
  33190. getCameraByID(id: string): Nullable<Camera>;
  33191. /**
  33192. * Gets a camera using its unique id
  33193. * @param uniqueId defines the unique id to look for
  33194. * @returns the camera or null if not found
  33195. */
  33196. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33197. /**
  33198. * Gets a camera using its name
  33199. * @param name defines the camera's name
  33200. * @return the camera or null if none found.
  33201. */
  33202. getCameraByName(name: string): Nullable<Camera>;
  33203. /**
  33204. * Gets a bone using its id
  33205. * @param id defines the bone's id
  33206. * @return the bone or null if not found
  33207. */
  33208. getBoneByID(id: string): Nullable<Bone>;
  33209. /**
  33210. * Gets a bone using its id
  33211. * @param name defines the bone's name
  33212. * @return the bone or null if not found
  33213. */
  33214. getBoneByName(name: string): Nullable<Bone>;
  33215. /**
  33216. * Gets a light node using its name
  33217. * @param name defines the the light's name
  33218. * @return the light or null if none found.
  33219. */
  33220. getLightByName(name: string): Nullable<Light>;
  33221. /**
  33222. * Gets a light node using its id
  33223. * @param id defines the light's id
  33224. * @return the light or null if none found.
  33225. */
  33226. getLightByID(id: string): Nullable<Light>;
  33227. /**
  33228. * Gets a light node using its scene-generated unique ID
  33229. * @param uniqueId defines the light's unique id
  33230. * @return the light or null if none found.
  33231. */
  33232. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33233. /**
  33234. * Gets a particle system by id
  33235. * @param id defines the particle system id
  33236. * @return the corresponding system or null if none found
  33237. */
  33238. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33239. /**
  33240. * Gets a geometry using its ID
  33241. * @param id defines the geometry's id
  33242. * @return the geometry or null if none found.
  33243. */
  33244. getGeometryByID(id: string): Nullable<Geometry>;
  33245. private _getGeometryByUniqueID;
  33246. /**
  33247. * Add a new geometry to this scene
  33248. * @param geometry defines the geometry to be added to the scene.
  33249. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33250. * @return a boolean defining if the geometry was added or not
  33251. */
  33252. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33253. /**
  33254. * Removes an existing geometry
  33255. * @param geometry defines the geometry to be removed from the scene
  33256. * @return a boolean defining if the geometry was removed or not
  33257. */
  33258. removeGeometry(geometry: Geometry): boolean;
  33259. /**
  33260. * Gets the list of geometries attached to the scene
  33261. * @returns an array of Geometry
  33262. */
  33263. getGeometries(): Geometry[];
  33264. /**
  33265. * Gets the first added mesh found of a given ID
  33266. * @param id defines the id to search for
  33267. * @return the mesh found or null if not found at all
  33268. */
  33269. getMeshByID(id: string): Nullable<AbstractMesh>;
  33270. /**
  33271. * Gets a list of meshes using their id
  33272. * @param id defines the id to search for
  33273. * @returns a list of meshes
  33274. */
  33275. getMeshesByID(id: string): Array<AbstractMesh>;
  33276. /**
  33277. * Gets the first added transform node found of a given ID
  33278. * @param id defines the id to search for
  33279. * @return the found transform node or null if not found at all.
  33280. */
  33281. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33282. /**
  33283. * Gets a transform node with its auto-generated unique id
  33284. * @param uniqueId efines the unique id to search for
  33285. * @return the found transform node or null if not found at all.
  33286. */
  33287. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33288. /**
  33289. * Gets a list of transform nodes using their id
  33290. * @param id defines the id to search for
  33291. * @returns a list of transform nodes
  33292. */
  33293. getTransformNodesByID(id: string): Array<TransformNode>;
  33294. /**
  33295. * Gets a mesh with its auto-generated unique id
  33296. * @param uniqueId defines the unique id to search for
  33297. * @return the found mesh or null if not found at all.
  33298. */
  33299. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33300. /**
  33301. * Gets a the last added mesh using a given id
  33302. * @param id defines the id to search for
  33303. * @return the found mesh or null if not found at all.
  33304. */
  33305. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33306. /**
  33307. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33308. * @param id defines the id to search for
  33309. * @return the found node or null if not found at all
  33310. */
  33311. getLastEntryByID(id: string): Nullable<Node>;
  33312. /**
  33313. * Gets a node (Mesh, Camera, Light) using a given id
  33314. * @param id defines the id to search for
  33315. * @return the found node or null if not found at all
  33316. */
  33317. getNodeByID(id: string): Nullable<Node>;
  33318. /**
  33319. * Gets a node (Mesh, Camera, Light) using a given name
  33320. * @param name defines the name to search for
  33321. * @return the found node or null if not found at all.
  33322. */
  33323. getNodeByName(name: string): Nullable<Node>;
  33324. /**
  33325. * Gets a mesh using a given name
  33326. * @param name defines the name to search for
  33327. * @return the found mesh or null if not found at all.
  33328. */
  33329. getMeshByName(name: string): Nullable<AbstractMesh>;
  33330. /**
  33331. * Gets a transform node using a given name
  33332. * @param name defines the name to search for
  33333. * @return the found transform node or null if not found at all.
  33334. */
  33335. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33336. /**
  33337. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33338. * @param id defines the id to search for
  33339. * @return the found skeleton or null if not found at all.
  33340. */
  33341. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33342. /**
  33343. * Gets a skeleton using a given auto generated unique id
  33344. * @param uniqueId defines the unique id to search for
  33345. * @return the found skeleton or null if not found at all.
  33346. */
  33347. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33348. /**
  33349. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33350. * @param id defines the id to search for
  33351. * @return the found skeleton or null if not found at all.
  33352. */
  33353. getSkeletonById(id: string): Nullable<Skeleton>;
  33354. /**
  33355. * Gets a skeleton using a given name
  33356. * @param name defines the name to search for
  33357. * @return the found skeleton or null if not found at all.
  33358. */
  33359. getSkeletonByName(name: string): Nullable<Skeleton>;
  33360. /**
  33361. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33362. * @param id defines the id to search for
  33363. * @return the found morph target manager or null if not found at all.
  33364. */
  33365. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33366. /**
  33367. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33368. * @param id defines the id to search for
  33369. * @return the found morph target or null if not found at all.
  33370. */
  33371. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33372. /**
  33373. * Gets a boolean indicating if the given mesh is active
  33374. * @param mesh defines the mesh to look for
  33375. * @returns true if the mesh is in the active list
  33376. */
  33377. isActiveMesh(mesh: AbstractMesh): boolean;
  33378. /**
  33379. * Return a unique id as a string which can serve as an identifier for the scene
  33380. */
  33381. readonly uid: string;
  33382. /**
  33383. * Add an externaly attached data from its key.
  33384. * This method call will fail and return false, if such key already exists.
  33385. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33386. * @param key the unique key that identifies the data
  33387. * @param data the data object to associate to the key for this Engine instance
  33388. * @return true if no such key were already present and the data was added successfully, false otherwise
  33389. */
  33390. addExternalData<T>(key: string, data: T): boolean;
  33391. /**
  33392. * Get an externaly attached data from its key
  33393. * @param key the unique key that identifies the data
  33394. * @return the associated data, if present (can be null), or undefined if not present
  33395. */
  33396. getExternalData<T>(key: string): Nullable<T>;
  33397. /**
  33398. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33399. * @param key the unique key that identifies the data
  33400. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33401. * @return the associated data, can be null if the factory returned null.
  33402. */
  33403. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33404. /**
  33405. * Remove an externaly attached data from the Engine instance
  33406. * @param key the unique key that identifies the data
  33407. * @return true if the data was successfully removed, false if it doesn't exist
  33408. */
  33409. removeExternalData(key: string): boolean;
  33410. private _evaluateSubMesh;
  33411. /**
  33412. * Clear the processed materials smart array preventing retention point in material dispose.
  33413. */
  33414. freeProcessedMaterials(): void;
  33415. private _preventFreeActiveMeshesAndRenderingGroups;
  33416. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33417. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33418. * when disposing several meshes in a row or a hierarchy of meshes.
  33419. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33420. */
  33421. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33422. /**
  33423. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33424. */
  33425. freeActiveMeshes(): void;
  33426. /**
  33427. * Clear the info related to rendering groups preventing retention points during dispose.
  33428. */
  33429. freeRenderingGroups(): void;
  33430. /** @hidden */
  33431. _isInIntermediateRendering(): boolean;
  33432. /**
  33433. * Lambda returning the list of potentially active meshes.
  33434. */
  33435. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33436. /**
  33437. * Lambda returning the list of potentially active sub meshes.
  33438. */
  33439. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33440. /**
  33441. * Lambda returning the list of potentially intersecting sub meshes.
  33442. */
  33443. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33444. /**
  33445. * Lambda returning the list of potentially colliding sub meshes.
  33446. */
  33447. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33448. private _activeMeshesFrozen;
  33449. /**
  33450. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33451. * @returns the current scene
  33452. */
  33453. freezeActiveMeshes(): Scene;
  33454. /**
  33455. * Use this function to restart evaluating active meshes on every frame
  33456. * @returns the current scene
  33457. */
  33458. unfreezeActiveMeshes(): Scene;
  33459. private _evaluateActiveMeshes;
  33460. private _activeMesh;
  33461. /**
  33462. * Update the transform matrix to update from the current active camera
  33463. * @param force defines a boolean used to force the update even if cache is up to date
  33464. */
  33465. updateTransformMatrix(force?: boolean): void;
  33466. private _bindFrameBuffer;
  33467. /** @hidden */
  33468. _allowPostProcessClearColor: boolean;
  33469. /** @hidden */
  33470. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33471. private _processSubCameras;
  33472. private _checkIntersections;
  33473. /** @hidden */
  33474. _advancePhysicsEngineStep(step: number): void;
  33475. /**
  33476. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33477. */
  33478. getDeterministicFrameTime: () => number;
  33479. /** @hidden */
  33480. _animate(): void;
  33481. /** Execute all animations (for a frame) */
  33482. animate(): void;
  33483. /**
  33484. * Render the scene
  33485. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33486. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33487. */
  33488. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33489. /**
  33490. * Freeze all materials
  33491. * A frozen material will not be updatable but should be faster to render
  33492. */
  33493. freezeMaterials(): void;
  33494. /**
  33495. * Unfreeze all materials
  33496. * A frozen material will not be updatable but should be faster to render
  33497. */
  33498. unfreezeMaterials(): void;
  33499. /**
  33500. * Releases all held ressources
  33501. */
  33502. dispose(): void;
  33503. /**
  33504. * Gets if the scene is already disposed
  33505. */
  33506. readonly isDisposed: boolean;
  33507. /**
  33508. * Call this function to reduce memory footprint of the scene.
  33509. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33510. */
  33511. clearCachedVertexData(): void;
  33512. /**
  33513. * This function will remove the local cached buffer data from texture.
  33514. * It will save memory but will prevent the texture from being rebuilt
  33515. */
  33516. cleanCachedTextureBuffer(): void;
  33517. /**
  33518. * Get the world extend vectors with an optional filter
  33519. *
  33520. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33521. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33522. */
  33523. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33524. min: Vector3;
  33525. max: Vector3;
  33526. };
  33527. /**
  33528. * Creates a ray that can be used to pick in the scene
  33529. * @param x defines the x coordinate of the origin (on-screen)
  33530. * @param y defines the y coordinate of the origin (on-screen)
  33531. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33532. * @param camera defines the camera to use for the picking
  33533. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33534. * @returns a Ray
  33535. */
  33536. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33537. /**
  33538. * Creates a ray that can be used to pick in the scene
  33539. * @param x defines the x coordinate of the origin (on-screen)
  33540. * @param y defines the y coordinate of the origin (on-screen)
  33541. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33542. * @param result defines the ray where to store the picking ray
  33543. * @param camera defines the camera to use for the picking
  33544. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33545. * @returns the current scene
  33546. */
  33547. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33548. /**
  33549. * Creates a ray that can be used to pick in the scene
  33550. * @param x defines the x coordinate of the origin (on-screen)
  33551. * @param y defines the y coordinate of the origin (on-screen)
  33552. * @param camera defines the camera to use for the picking
  33553. * @returns a Ray
  33554. */
  33555. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33556. /**
  33557. * Creates a ray that can be used to pick in the scene
  33558. * @param x defines the x coordinate of the origin (on-screen)
  33559. * @param y defines the y coordinate of the origin (on-screen)
  33560. * @param result defines the ray where to store the picking ray
  33561. * @param camera defines the camera to use for the picking
  33562. * @returns the current scene
  33563. */
  33564. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33565. /** Launch a ray to try to pick a mesh in the scene
  33566. * @param x position on screen
  33567. * @param y position on screen
  33568. * @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
  33569. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33570. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33571. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33572. * @returns a PickingInfo
  33573. */
  33574. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33575. /** Use the given ray to pick a mesh in the scene
  33576. * @param ray The ray to use to pick meshes
  33577. * @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
  33578. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33579. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33580. * @returns a PickingInfo
  33581. */
  33582. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33583. /**
  33584. * Launch a ray to try to pick a mesh in the scene
  33585. * @param x X position on screen
  33586. * @param y Y position on screen
  33587. * @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
  33588. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33589. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33590. * @returns an array of PickingInfo
  33591. */
  33592. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33593. /**
  33594. * Launch a ray to try to pick a mesh in the scene
  33595. * @param ray Ray to use
  33596. * @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
  33597. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33598. * @returns an array of PickingInfo
  33599. */
  33600. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33601. /**
  33602. * Force the value of meshUnderPointer
  33603. * @param mesh defines the mesh to use
  33604. */
  33605. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33606. /**
  33607. * Gets the mesh under the pointer
  33608. * @returns a Mesh or null if no mesh is under the pointer
  33609. */
  33610. getPointerOverMesh(): Nullable<AbstractMesh>;
  33611. /** @hidden */
  33612. _rebuildGeometries(): void;
  33613. /** @hidden */
  33614. _rebuildTextures(): void;
  33615. private _getByTags;
  33616. /**
  33617. * Get a list of meshes by tags
  33618. * @param tagsQuery defines the tags query to use
  33619. * @param forEach defines a predicate used to filter results
  33620. * @returns an array of Mesh
  33621. */
  33622. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33623. /**
  33624. * Get a list of cameras by tags
  33625. * @param tagsQuery defines the tags query to use
  33626. * @param forEach defines a predicate used to filter results
  33627. * @returns an array of Camera
  33628. */
  33629. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33630. /**
  33631. * Get a list of lights by tags
  33632. * @param tagsQuery defines the tags query to use
  33633. * @param forEach defines a predicate used to filter results
  33634. * @returns an array of Light
  33635. */
  33636. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33637. /**
  33638. * Get a list of materials by tags
  33639. * @param tagsQuery defines the tags query to use
  33640. * @param forEach defines a predicate used to filter results
  33641. * @returns an array of Material
  33642. */
  33643. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33644. /**
  33645. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33646. * This allowed control for front to back rendering or reversly depending of the special needs.
  33647. *
  33648. * @param renderingGroupId The rendering group id corresponding to its index
  33649. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33650. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33651. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33652. */
  33653. 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;
  33654. /**
  33655. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33656. *
  33657. * @param renderingGroupId The rendering group id corresponding to its index
  33658. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33659. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33660. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33661. */
  33662. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33663. /**
  33664. * Gets the current auto clear configuration for one rendering group of the rendering
  33665. * manager.
  33666. * @param index the rendering group index to get the information for
  33667. * @returns The auto clear setup for the requested rendering group
  33668. */
  33669. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33670. private _blockMaterialDirtyMechanism;
  33671. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33672. blockMaterialDirtyMechanism: boolean;
  33673. /**
  33674. * Will flag all materials as dirty to trigger new shader compilation
  33675. * @param flag defines the flag used to specify which material part must be marked as dirty
  33676. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33677. */
  33678. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33679. /** @hidden */
  33680. _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;
  33681. /** @hidden */
  33682. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33683. }
  33684. }
  33685. declare module BABYLON {
  33686. /**
  33687. * Set of assets to keep when moving a scene into an asset container.
  33688. */
  33689. export class KeepAssets extends AbstractScene {
  33690. }
  33691. /**
  33692. * Container with a set of assets that can be added or removed from a scene.
  33693. */
  33694. export class AssetContainer extends AbstractScene {
  33695. /**
  33696. * The scene the AssetContainer belongs to.
  33697. */
  33698. scene: Scene;
  33699. /**
  33700. * Instantiates an AssetContainer.
  33701. * @param scene The scene the AssetContainer belongs to.
  33702. */
  33703. constructor(scene: Scene);
  33704. /**
  33705. * Adds all the assets from the container to the scene.
  33706. */
  33707. addAllToScene(): void;
  33708. /**
  33709. * Removes all the assets in the container from the scene
  33710. */
  33711. removeAllFromScene(): void;
  33712. /**
  33713. * Disposes all the assets in the container
  33714. */
  33715. dispose(): void;
  33716. private _moveAssets;
  33717. /**
  33718. * Removes all the assets contained in the scene and adds them to the container.
  33719. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33720. */
  33721. moveAllFromScene(keepAssets?: KeepAssets): void;
  33722. /**
  33723. * 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.
  33724. * @returns the root mesh
  33725. */
  33726. createRootMesh(): Mesh;
  33727. }
  33728. }
  33729. declare module BABYLON {
  33730. /**
  33731. * Defines how the parser contract is defined.
  33732. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33733. */
  33734. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33735. /**
  33736. * Defines how the individual parser contract is defined.
  33737. * These parser can parse an individual asset
  33738. */
  33739. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33740. /**
  33741. * Base class of the scene acting as a container for the different elements composing a scene.
  33742. * This class is dynamically extended by the different components of the scene increasing
  33743. * flexibility and reducing coupling
  33744. */
  33745. export abstract class AbstractScene {
  33746. /**
  33747. * Stores the list of available parsers in the application.
  33748. */
  33749. private static _BabylonFileParsers;
  33750. /**
  33751. * Stores the list of available individual parsers in the application.
  33752. */
  33753. private static _IndividualBabylonFileParsers;
  33754. /**
  33755. * Adds a parser in the list of available ones
  33756. * @param name Defines the name of the parser
  33757. * @param parser Defines the parser to add
  33758. */
  33759. static AddParser(name: string, parser: BabylonFileParser): void;
  33760. /**
  33761. * Gets a general parser from the list of avaialble ones
  33762. * @param name Defines the name of the parser
  33763. * @returns the requested parser or null
  33764. */
  33765. static GetParser(name: string): Nullable<BabylonFileParser>;
  33766. /**
  33767. * Adds n individual parser in the list of available ones
  33768. * @param name Defines the name of the parser
  33769. * @param parser Defines the parser to add
  33770. */
  33771. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33772. /**
  33773. * Gets an individual parser from the list of avaialble ones
  33774. * @param name Defines the name of the parser
  33775. * @returns the requested parser or null
  33776. */
  33777. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33778. /**
  33779. * Parser json data and populate both a scene and its associated container object
  33780. * @param jsonData Defines the data to parse
  33781. * @param scene Defines the scene to parse the data for
  33782. * @param container Defines the container attached to the parsing sequence
  33783. * @param rootUrl Defines the root url of the data
  33784. */
  33785. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33786. /**
  33787. * Gets the list of root nodes (ie. nodes with no parent)
  33788. */
  33789. rootNodes: Node[];
  33790. /** All of the cameras added to this scene
  33791. * @see http://doc.babylonjs.com/babylon101/cameras
  33792. */
  33793. cameras: Camera[];
  33794. /**
  33795. * All of the lights added to this scene
  33796. * @see http://doc.babylonjs.com/babylon101/lights
  33797. */
  33798. lights: Light[];
  33799. /**
  33800. * All of the (abstract) meshes added to this scene
  33801. */
  33802. meshes: AbstractMesh[];
  33803. /**
  33804. * The list of skeletons added to the scene
  33805. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33806. */
  33807. skeletons: Skeleton[];
  33808. /**
  33809. * All of the particle systems added to this scene
  33810. * @see http://doc.babylonjs.com/babylon101/particles
  33811. */
  33812. particleSystems: IParticleSystem[];
  33813. /**
  33814. * Gets a list of Animations associated with the scene
  33815. */
  33816. animations: Animation[];
  33817. /**
  33818. * All of the animation groups added to this scene
  33819. * @see http://doc.babylonjs.com/how_to/group
  33820. */
  33821. animationGroups: AnimationGroup[];
  33822. /**
  33823. * All of the multi-materials added to this scene
  33824. * @see http://doc.babylonjs.com/how_to/multi_materials
  33825. */
  33826. multiMaterials: MultiMaterial[];
  33827. /**
  33828. * All of the materials added to this scene
  33829. * In the context of a Scene, it is not supposed to be modified manually.
  33830. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33831. * Note also that the order of the Material wihin the array is not significant and might change.
  33832. * @see http://doc.babylonjs.com/babylon101/materials
  33833. */
  33834. materials: Material[];
  33835. /**
  33836. * The list of morph target managers added to the scene
  33837. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33838. */
  33839. morphTargetManagers: MorphTargetManager[];
  33840. /**
  33841. * The list of geometries used in the scene.
  33842. */
  33843. geometries: Geometry[];
  33844. /**
  33845. * All of the tranform nodes added to this scene
  33846. * In the context of a Scene, it is not supposed to be modified manually.
  33847. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33848. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33849. * @see http://doc.babylonjs.com/how_to/transformnode
  33850. */
  33851. transformNodes: TransformNode[];
  33852. /**
  33853. * ActionManagers available on the scene.
  33854. */
  33855. actionManagers: AbstractActionManager[];
  33856. /**
  33857. * Textures to keep.
  33858. */
  33859. textures: BaseTexture[];
  33860. /**
  33861. * Environment texture for the scene
  33862. */
  33863. environmentTexture: Nullable<BaseTexture>;
  33864. }
  33865. }
  33866. declare module BABYLON {
  33867. /**
  33868. * Defines a sound that can be played in the application.
  33869. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33871. */
  33872. export class Sound {
  33873. /**
  33874. * The name of the sound in the scene.
  33875. */
  33876. name: string;
  33877. /**
  33878. * Does the sound autoplay once loaded.
  33879. */
  33880. autoplay: boolean;
  33881. /**
  33882. * Does the sound loop after it finishes playing once.
  33883. */
  33884. loop: boolean;
  33885. /**
  33886. * Does the sound use a custom attenuation curve to simulate the falloff
  33887. * happening when the source gets further away from the camera.
  33888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33889. */
  33890. useCustomAttenuation: boolean;
  33891. /**
  33892. * The sound track id this sound belongs to.
  33893. */
  33894. soundTrackId: number;
  33895. /**
  33896. * Is this sound currently played.
  33897. */
  33898. isPlaying: boolean;
  33899. /**
  33900. * Is this sound currently paused.
  33901. */
  33902. isPaused: boolean;
  33903. /**
  33904. * Does this sound enables spatial sound.
  33905. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33906. */
  33907. spatialSound: boolean;
  33908. /**
  33909. * Define the reference distance the sound should be heard perfectly.
  33910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33911. */
  33912. refDistance: number;
  33913. /**
  33914. * Define the roll off factor of spatial sounds.
  33915. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33916. */
  33917. rolloffFactor: number;
  33918. /**
  33919. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33920. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33921. */
  33922. maxDistance: number;
  33923. /**
  33924. * Define the distance attenuation model the sound will follow.
  33925. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33926. */
  33927. distanceModel: string;
  33928. /**
  33929. * @hidden
  33930. * Back Compat
  33931. **/
  33932. onended: () => any;
  33933. /**
  33934. * Observable event when the current playing sound finishes.
  33935. */
  33936. onEndedObservable: Observable<Sound>;
  33937. private _panningModel;
  33938. private _playbackRate;
  33939. private _streaming;
  33940. private _startTime;
  33941. private _startOffset;
  33942. private _position;
  33943. /** @hidden */
  33944. _positionInEmitterSpace: boolean;
  33945. private _localDirection;
  33946. private _volume;
  33947. private _isReadyToPlay;
  33948. private _isDirectional;
  33949. private _readyToPlayCallback;
  33950. private _audioBuffer;
  33951. private _soundSource;
  33952. private _streamingSource;
  33953. private _soundPanner;
  33954. private _soundGain;
  33955. private _inputAudioNode;
  33956. private _outputAudioNode;
  33957. private _coneInnerAngle;
  33958. private _coneOuterAngle;
  33959. private _coneOuterGain;
  33960. private _scene;
  33961. private _connectedTransformNode;
  33962. private _customAttenuationFunction;
  33963. private _registerFunc;
  33964. private _isOutputConnected;
  33965. private _htmlAudioElement;
  33966. private _urlType;
  33967. /** @hidden */
  33968. static _SceneComponentInitialization: (scene: Scene) => void;
  33969. /**
  33970. * Create a sound and attach it to a scene
  33971. * @param name Name of your sound
  33972. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33973. * @param scene defines the scene the sound belongs to
  33974. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33975. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33976. */
  33977. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33978. /**
  33979. * Release the sound and its associated resources
  33980. */
  33981. dispose(): void;
  33982. /**
  33983. * Gets if the sounds is ready to be played or not.
  33984. * @returns true if ready, otherwise false
  33985. */
  33986. isReady(): boolean;
  33987. private _soundLoaded;
  33988. /**
  33989. * Sets the data of the sound from an audiobuffer
  33990. * @param audioBuffer The audioBuffer containing the data
  33991. */
  33992. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33993. /**
  33994. * Updates the current sounds options such as maxdistance, loop...
  33995. * @param options A JSON object containing values named as the object properties
  33996. */
  33997. updateOptions(options: any): void;
  33998. private _createSpatialParameters;
  33999. private _updateSpatialParameters;
  34000. /**
  34001. * Switch the panning model to HRTF:
  34002. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34004. */
  34005. switchPanningModelToHRTF(): void;
  34006. /**
  34007. * Switch the panning model to Equal Power:
  34008. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34009. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34010. */
  34011. switchPanningModelToEqualPower(): void;
  34012. private _switchPanningModel;
  34013. /**
  34014. * Connect this sound to a sound track audio node like gain...
  34015. * @param soundTrackAudioNode the sound track audio node to connect to
  34016. */
  34017. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34018. /**
  34019. * Transform this sound into a directional source
  34020. * @param coneInnerAngle Size of the inner cone in degree
  34021. * @param coneOuterAngle Size of the outer cone in degree
  34022. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34023. */
  34024. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34025. /**
  34026. * Gets or sets the inner angle for the directional cone.
  34027. */
  34028. /**
  34029. * Gets or sets the inner angle for the directional cone.
  34030. */
  34031. directionalConeInnerAngle: number;
  34032. /**
  34033. * Gets or sets the outer angle for the directional cone.
  34034. */
  34035. /**
  34036. * Gets or sets the outer angle for the directional cone.
  34037. */
  34038. directionalConeOuterAngle: number;
  34039. /**
  34040. * Sets the position of the emitter if spatial sound is enabled
  34041. * @param newPosition Defines the new posisiton
  34042. */
  34043. setPosition(newPosition: Vector3): void;
  34044. /**
  34045. * Sets the local direction of the emitter if spatial sound is enabled
  34046. * @param newLocalDirection Defines the new local direction
  34047. */
  34048. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34049. private _updateDirection;
  34050. /** @hidden */
  34051. updateDistanceFromListener(): void;
  34052. /**
  34053. * Sets a new custom attenuation function for the sound.
  34054. * @param callback Defines the function used for the attenuation
  34055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34056. */
  34057. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34058. /**
  34059. * Play the sound
  34060. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34061. * @param offset (optional) Start the sound setting it at a specific time
  34062. */
  34063. play(time?: number, offset?: number): void;
  34064. private _onended;
  34065. /**
  34066. * Stop the sound
  34067. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34068. */
  34069. stop(time?: number): void;
  34070. /**
  34071. * Put the sound in pause
  34072. */
  34073. pause(): void;
  34074. /**
  34075. * Sets a dedicated volume for this sounds
  34076. * @param newVolume Define the new volume of the sound
  34077. * @param time Define in how long the sound should be at this value
  34078. */
  34079. setVolume(newVolume: number, time?: number): void;
  34080. /**
  34081. * Set the sound play back rate
  34082. * @param newPlaybackRate Define the playback rate the sound should be played at
  34083. */
  34084. setPlaybackRate(newPlaybackRate: number): void;
  34085. /**
  34086. * Gets the volume of the sound.
  34087. * @returns the volume of the sound
  34088. */
  34089. getVolume(): number;
  34090. /**
  34091. * Attach the sound to a dedicated mesh
  34092. * @param transformNode The transform node to connect the sound with
  34093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34094. */
  34095. attachToMesh(transformNode: TransformNode): void;
  34096. /**
  34097. * Detach the sound from the previously attached mesh
  34098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34099. */
  34100. detachFromMesh(): void;
  34101. private _onRegisterAfterWorldMatrixUpdate;
  34102. /**
  34103. * Clone the current sound in the scene.
  34104. * @returns the new sound clone
  34105. */
  34106. clone(): Nullable<Sound>;
  34107. /**
  34108. * Gets the current underlying audio buffer containing the data
  34109. * @returns the audio buffer
  34110. */
  34111. getAudioBuffer(): Nullable<AudioBuffer>;
  34112. /**
  34113. * Serializes the Sound in a JSON representation
  34114. * @returns the JSON representation of the sound
  34115. */
  34116. serialize(): any;
  34117. /**
  34118. * Parse a JSON representation of a sound to innstantiate in a given scene
  34119. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34120. * @param scene Define the scene the new parsed sound should be created in
  34121. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34122. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34123. * @returns the newly parsed sound
  34124. */
  34125. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34126. }
  34127. }
  34128. declare module BABYLON {
  34129. /**
  34130. * This defines an action helpful to play a defined sound on a triggered action.
  34131. */
  34132. export class PlaySoundAction extends Action {
  34133. private _sound;
  34134. /**
  34135. * Instantiate the action
  34136. * @param triggerOptions defines the trigger options
  34137. * @param sound defines the sound to play
  34138. * @param condition defines the trigger related conditions
  34139. */
  34140. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34141. /** @hidden */
  34142. _prepare(): void;
  34143. /**
  34144. * Execute the action and play the sound.
  34145. */
  34146. execute(): void;
  34147. /**
  34148. * Serializes the actions and its related information.
  34149. * @param parent defines the object to serialize in
  34150. * @returns the serialized object
  34151. */
  34152. serialize(parent: any): any;
  34153. }
  34154. /**
  34155. * This defines an action helpful to stop a defined sound on a triggered action.
  34156. */
  34157. export class StopSoundAction extends Action {
  34158. private _sound;
  34159. /**
  34160. * Instantiate the action
  34161. * @param triggerOptions defines the trigger options
  34162. * @param sound defines the sound to stop
  34163. * @param condition defines the trigger related conditions
  34164. */
  34165. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34166. /** @hidden */
  34167. _prepare(): void;
  34168. /**
  34169. * Execute the action and stop the sound.
  34170. */
  34171. execute(): void;
  34172. /**
  34173. * Serializes the actions and its related information.
  34174. * @param parent defines the object to serialize in
  34175. * @returns the serialized object
  34176. */
  34177. serialize(parent: any): any;
  34178. }
  34179. }
  34180. declare module BABYLON {
  34181. /**
  34182. * This defines an action responsible to change the value of a property
  34183. * by interpolating between its current value and the newly set one once triggered.
  34184. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34185. */
  34186. export class InterpolateValueAction extends Action {
  34187. /**
  34188. * Defines the path of the property where the value should be interpolated
  34189. */
  34190. propertyPath: string;
  34191. /**
  34192. * Defines the target value at the end of the interpolation.
  34193. */
  34194. value: any;
  34195. /**
  34196. * Defines the time it will take for the property to interpolate to the value.
  34197. */
  34198. duration: number;
  34199. /**
  34200. * Defines if the other scene animations should be stopped when the action has been triggered
  34201. */
  34202. stopOtherAnimations?: boolean;
  34203. /**
  34204. * Defines a callback raised once the interpolation animation has been done.
  34205. */
  34206. onInterpolationDone?: () => void;
  34207. /**
  34208. * Observable triggered once the interpolation animation has been done.
  34209. */
  34210. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34211. private _target;
  34212. private _effectiveTarget;
  34213. private _property;
  34214. /**
  34215. * Instantiate the action
  34216. * @param triggerOptions defines the trigger options
  34217. * @param target defines the object containing the value to interpolate
  34218. * @param propertyPath defines the path to the property in the target object
  34219. * @param value defines the target value at the end of the interpolation
  34220. * @param duration deines the time it will take for the property to interpolate to the value.
  34221. * @param condition defines the trigger related conditions
  34222. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34223. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34224. */
  34225. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34226. /** @hidden */
  34227. _prepare(): void;
  34228. /**
  34229. * Execute the action starts the value interpolation.
  34230. */
  34231. execute(): void;
  34232. /**
  34233. * Serializes the actions and its related information.
  34234. * @param parent defines the object to serialize in
  34235. * @returns the serialized object
  34236. */
  34237. serialize(parent: any): any;
  34238. }
  34239. }
  34240. declare module BABYLON {
  34241. /**
  34242. * Options allowed during the creation of a sound track.
  34243. */
  34244. export interface ISoundTrackOptions {
  34245. /**
  34246. * The volume the sound track should take during creation
  34247. */
  34248. volume?: number;
  34249. /**
  34250. * Define if the sound track is the main sound track of the scene
  34251. */
  34252. mainTrack?: boolean;
  34253. }
  34254. /**
  34255. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34256. * It will be also used in a future release to apply effects on a specific track.
  34257. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34258. */
  34259. export class SoundTrack {
  34260. /**
  34261. * The unique identifier of the sound track in the scene.
  34262. */
  34263. id: number;
  34264. /**
  34265. * The list of sounds included in the sound track.
  34266. */
  34267. soundCollection: Array<Sound>;
  34268. private _outputAudioNode;
  34269. private _scene;
  34270. private _isMainTrack;
  34271. private _connectedAnalyser;
  34272. private _options;
  34273. private _isInitialized;
  34274. /**
  34275. * Creates a new sound track.
  34276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34277. * @param scene Define the scene the sound track belongs to
  34278. * @param options
  34279. */
  34280. constructor(scene: Scene, options?: ISoundTrackOptions);
  34281. private _initializeSoundTrackAudioGraph;
  34282. /**
  34283. * Release the sound track and its associated resources
  34284. */
  34285. dispose(): void;
  34286. /**
  34287. * Adds a sound to this sound track
  34288. * @param sound define the cound to add
  34289. * @ignoreNaming
  34290. */
  34291. AddSound(sound: Sound): void;
  34292. /**
  34293. * Removes a sound to this sound track
  34294. * @param sound define the cound to remove
  34295. * @ignoreNaming
  34296. */
  34297. RemoveSound(sound: Sound): void;
  34298. /**
  34299. * Set a global volume for the full sound track.
  34300. * @param newVolume Define the new volume of the sound track
  34301. */
  34302. setVolume(newVolume: number): void;
  34303. /**
  34304. * Switch the panning model to HRTF:
  34305. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34306. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34307. */
  34308. switchPanningModelToHRTF(): void;
  34309. /**
  34310. * Switch the panning model to Equal Power:
  34311. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34313. */
  34314. switchPanningModelToEqualPower(): void;
  34315. /**
  34316. * Connect the sound track to an audio analyser allowing some amazing
  34317. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34318. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34319. * @param analyser The analyser to connect to the engine
  34320. */
  34321. connectToAnalyser(analyser: Analyser): void;
  34322. }
  34323. }
  34324. declare module BABYLON {
  34325. interface AbstractScene {
  34326. /**
  34327. * The list of sounds used in the scene.
  34328. */
  34329. sounds: Nullable<Array<Sound>>;
  34330. }
  34331. interface Scene {
  34332. /**
  34333. * @hidden
  34334. * Backing field
  34335. */
  34336. _mainSoundTrack: SoundTrack;
  34337. /**
  34338. * The main sound track played by the scene.
  34339. * It cotains your primary collection of sounds.
  34340. */
  34341. mainSoundTrack: SoundTrack;
  34342. /**
  34343. * The list of sound tracks added to the scene
  34344. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34345. */
  34346. soundTracks: Nullable<Array<SoundTrack>>;
  34347. /**
  34348. * Gets a sound using a given name
  34349. * @param name defines the name to search for
  34350. * @return the found sound or null if not found at all.
  34351. */
  34352. getSoundByName(name: string): Nullable<Sound>;
  34353. /**
  34354. * Gets or sets if audio support is enabled
  34355. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34356. */
  34357. audioEnabled: boolean;
  34358. /**
  34359. * Gets or sets if audio will be output to headphones
  34360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34361. */
  34362. headphone: boolean;
  34363. }
  34364. /**
  34365. * Defines the sound scene component responsible to manage any sounds
  34366. * in a given scene.
  34367. */
  34368. export class AudioSceneComponent implements ISceneSerializableComponent {
  34369. /**
  34370. * The component name helpfull to identify the component in the list of scene components.
  34371. */
  34372. readonly name: string;
  34373. /**
  34374. * The scene the component belongs to.
  34375. */
  34376. scene: Scene;
  34377. private _audioEnabled;
  34378. /**
  34379. * Gets whether audio is enabled or not.
  34380. * Please use related enable/disable method to switch state.
  34381. */
  34382. readonly audioEnabled: boolean;
  34383. private _headphone;
  34384. /**
  34385. * Gets whether audio is outputing to headphone or not.
  34386. * Please use the according Switch methods to change output.
  34387. */
  34388. readonly headphone: boolean;
  34389. /**
  34390. * Creates a new instance of the component for the given scene
  34391. * @param scene Defines the scene to register the component in
  34392. */
  34393. constructor(scene: Scene);
  34394. /**
  34395. * Registers the component in a given scene
  34396. */
  34397. register(): void;
  34398. /**
  34399. * Rebuilds the elements related to this component in case of
  34400. * context lost for instance.
  34401. */
  34402. rebuild(): void;
  34403. /**
  34404. * Serializes the component data to the specified json object
  34405. * @param serializationObject The object to serialize to
  34406. */
  34407. serialize(serializationObject: any): void;
  34408. /**
  34409. * Adds all the element from the container to the scene
  34410. * @param container the container holding the elements
  34411. */
  34412. addFromContainer(container: AbstractScene): void;
  34413. /**
  34414. * Removes all the elements in the container from the scene
  34415. * @param container contains the elements to remove
  34416. * @param dispose if the removed element should be disposed (default: false)
  34417. */
  34418. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34419. /**
  34420. * Disposes the component and the associated ressources.
  34421. */
  34422. dispose(): void;
  34423. /**
  34424. * Disables audio in the associated scene.
  34425. */
  34426. disableAudio(): void;
  34427. /**
  34428. * Enables audio in the associated scene.
  34429. */
  34430. enableAudio(): void;
  34431. /**
  34432. * Switch audio to headphone output.
  34433. */
  34434. switchAudioModeForHeadphones(): void;
  34435. /**
  34436. * Switch audio to normal speakers.
  34437. */
  34438. switchAudioModeForNormalSpeakers(): void;
  34439. private _afterRender;
  34440. }
  34441. }
  34442. declare module BABYLON {
  34443. /**
  34444. * Wraps one or more Sound objects and selects one with random weight for playback.
  34445. */
  34446. export class WeightedSound {
  34447. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34448. loop: boolean;
  34449. private _coneInnerAngle;
  34450. private _coneOuterAngle;
  34451. private _volume;
  34452. /** A Sound is currently playing. */
  34453. isPlaying: boolean;
  34454. /** A Sound is currently paused. */
  34455. isPaused: boolean;
  34456. private _sounds;
  34457. private _weights;
  34458. private _currentIndex?;
  34459. /**
  34460. * Creates a new WeightedSound from the list of sounds given.
  34461. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34462. * @param sounds Array of Sounds that will be selected from.
  34463. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34464. */
  34465. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34466. /**
  34467. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34468. */
  34469. /**
  34470. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34471. */
  34472. directionalConeInnerAngle: number;
  34473. /**
  34474. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34475. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34476. */
  34477. /**
  34478. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34479. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34480. */
  34481. directionalConeOuterAngle: number;
  34482. /**
  34483. * Playback volume.
  34484. */
  34485. /**
  34486. * Playback volume.
  34487. */
  34488. volume: number;
  34489. private _onended;
  34490. /**
  34491. * Suspend playback
  34492. */
  34493. pause(): void;
  34494. /**
  34495. * Stop playback
  34496. */
  34497. stop(): void;
  34498. /**
  34499. * Start playback.
  34500. * @param startOffset Position the clip head at a specific time in seconds.
  34501. */
  34502. play(startOffset?: number): void;
  34503. }
  34504. }
  34505. declare module BABYLON {
  34506. /**
  34507. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34508. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34509. */
  34510. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34511. /**
  34512. * Gets the name of the behavior.
  34513. */
  34514. readonly name: string;
  34515. /**
  34516. * The easing function used by animations
  34517. */
  34518. static EasingFunction: BackEase;
  34519. /**
  34520. * The easing mode used by animations
  34521. */
  34522. static EasingMode: number;
  34523. /**
  34524. * The duration of the animation, in milliseconds
  34525. */
  34526. transitionDuration: number;
  34527. /**
  34528. * Length of the distance animated by the transition when lower radius is reached
  34529. */
  34530. lowerRadiusTransitionRange: number;
  34531. /**
  34532. * Length of the distance animated by the transition when upper radius is reached
  34533. */
  34534. upperRadiusTransitionRange: number;
  34535. private _autoTransitionRange;
  34536. /**
  34537. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34538. */
  34539. /**
  34540. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34541. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34542. */
  34543. autoTransitionRange: boolean;
  34544. private _attachedCamera;
  34545. private _onAfterCheckInputsObserver;
  34546. private _onMeshTargetChangedObserver;
  34547. /**
  34548. * Initializes the behavior.
  34549. */
  34550. init(): void;
  34551. /**
  34552. * Attaches the behavior to its arc rotate camera.
  34553. * @param camera Defines the camera to attach the behavior to
  34554. */
  34555. attach(camera: ArcRotateCamera): void;
  34556. /**
  34557. * Detaches the behavior from its current arc rotate camera.
  34558. */
  34559. detach(): void;
  34560. private _radiusIsAnimating;
  34561. private _radiusBounceTransition;
  34562. private _animatables;
  34563. private _cachedWheelPrecision;
  34564. /**
  34565. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34566. * @param radiusLimit The limit to check against.
  34567. * @return Bool to indicate if at limit.
  34568. */
  34569. private _isRadiusAtLimit;
  34570. /**
  34571. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34572. * @param radiusDelta The delta by which to animate to. Can be negative.
  34573. */
  34574. private _applyBoundRadiusAnimation;
  34575. /**
  34576. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34577. */
  34578. protected _clearAnimationLocks(): void;
  34579. /**
  34580. * Stops and removes all animations that have been applied to the camera
  34581. */
  34582. stopAllAnimations(): void;
  34583. }
  34584. }
  34585. declare module BABYLON {
  34586. /**
  34587. * 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.
  34588. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34589. */
  34590. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34591. /**
  34592. * Gets the name of the behavior.
  34593. */
  34594. readonly name: string;
  34595. private _mode;
  34596. private _radiusScale;
  34597. private _positionScale;
  34598. private _defaultElevation;
  34599. private _elevationReturnTime;
  34600. private _elevationReturnWaitTime;
  34601. private _zoomStopsAnimation;
  34602. private _framingTime;
  34603. /**
  34604. * The easing function used by animations
  34605. */
  34606. static EasingFunction: ExponentialEase;
  34607. /**
  34608. * The easing mode used by animations
  34609. */
  34610. static EasingMode: number;
  34611. /**
  34612. * Sets the current mode used by the behavior
  34613. */
  34614. /**
  34615. * Gets current mode used by the behavior.
  34616. */
  34617. mode: number;
  34618. /**
  34619. * Sets the scale applied to the radius (1 by default)
  34620. */
  34621. /**
  34622. * Gets the scale applied to the radius
  34623. */
  34624. radiusScale: number;
  34625. /**
  34626. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34627. */
  34628. /**
  34629. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34630. */
  34631. positionScale: number;
  34632. /**
  34633. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34634. * behaviour is triggered, in radians.
  34635. */
  34636. /**
  34637. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34638. * behaviour is triggered, in radians.
  34639. */
  34640. defaultElevation: number;
  34641. /**
  34642. * Sets the time (in milliseconds) taken to return to the default beta position.
  34643. * Negative value indicates camera should not return to default.
  34644. */
  34645. /**
  34646. * Gets the time (in milliseconds) taken to return to the default beta position.
  34647. * Negative value indicates camera should not return to default.
  34648. */
  34649. elevationReturnTime: number;
  34650. /**
  34651. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34652. */
  34653. /**
  34654. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34655. */
  34656. elevationReturnWaitTime: number;
  34657. /**
  34658. * Sets the flag that indicates if user zooming should stop animation.
  34659. */
  34660. /**
  34661. * Gets the flag that indicates if user zooming should stop animation.
  34662. */
  34663. zoomStopsAnimation: boolean;
  34664. /**
  34665. * Sets the transition time when framing the mesh, in milliseconds
  34666. */
  34667. /**
  34668. * Gets the transition time when framing the mesh, in milliseconds
  34669. */
  34670. framingTime: number;
  34671. /**
  34672. * Define if the behavior should automatically change the configured
  34673. * camera limits and sensibilities.
  34674. */
  34675. autoCorrectCameraLimitsAndSensibility: boolean;
  34676. private _onPrePointerObservableObserver;
  34677. private _onAfterCheckInputsObserver;
  34678. private _onMeshTargetChangedObserver;
  34679. private _attachedCamera;
  34680. private _isPointerDown;
  34681. private _lastInteractionTime;
  34682. /**
  34683. * Initializes the behavior.
  34684. */
  34685. init(): void;
  34686. /**
  34687. * Attaches the behavior to its arc rotate camera.
  34688. * @param camera Defines the camera to attach the behavior to
  34689. */
  34690. attach(camera: ArcRotateCamera): void;
  34691. /**
  34692. * Detaches the behavior from its current arc rotate camera.
  34693. */
  34694. detach(): void;
  34695. private _animatables;
  34696. private _betaIsAnimating;
  34697. private _betaTransition;
  34698. private _radiusTransition;
  34699. private _vectorTransition;
  34700. /**
  34701. * Targets the given mesh and updates zoom level accordingly.
  34702. * @param mesh The mesh to target.
  34703. * @param radius Optional. If a cached radius position already exists, overrides default.
  34704. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34705. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34706. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34707. */
  34708. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34709. /**
  34710. * Targets the given mesh with its children and updates zoom level accordingly.
  34711. * @param mesh The mesh to target.
  34712. * @param radius Optional. If a cached radius position already exists, overrides default.
  34713. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34714. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34715. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34716. */
  34717. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34718. /**
  34719. * Targets the given meshes with their children and updates zoom level accordingly.
  34720. * @param meshes The mesh to target.
  34721. * @param radius Optional. If a cached radius position already exists, overrides default.
  34722. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34723. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34724. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34725. */
  34726. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34727. /**
  34728. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34729. * @param minimumWorld Determines the smaller position of the bounding box extend
  34730. * @param maximumWorld Determines the bigger position of the bounding box extend
  34731. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34732. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34733. */
  34734. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34735. /**
  34736. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34737. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34738. * frustum width.
  34739. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34740. * to fully enclose the mesh in the viewing frustum.
  34741. */
  34742. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34743. /**
  34744. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34745. * is automatically returned to its default position (expected to be above ground plane).
  34746. */
  34747. private _maintainCameraAboveGround;
  34748. /**
  34749. * Returns the frustum slope based on the canvas ratio and camera FOV
  34750. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34751. */
  34752. private _getFrustumSlope;
  34753. /**
  34754. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34755. */
  34756. private _clearAnimationLocks;
  34757. /**
  34758. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34759. */
  34760. private _applyUserInteraction;
  34761. /**
  34762. * Stops and removes all animations that have been applied to the camera
  34763. */
  34764. stopAllAnimations(): void;
  34765. /**
  34766. * Gets a value indicating if the user is moving the camera
  34767. */
  34768. readonly isUserIsMoving: boolean;
  34769. /**
  34770. * The camera can move all the way towards the mesh.
  34771. */
  34772. static IgnoreBoundsSizeMode: number;
  34773. /**
  34774. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34775. */
  34776. static FitFrustumSidesMode: number;
  34777. }
  34778. }
  34779. declare module BABYLON {
  34780. /**
  34781. * Base class for Camera Pointer Inputs.
  34782. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34783. * for example usage.
  34784. */
  34785. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34786. /**
  34787. * Defines the camera the input is attached to.
  34788. */
  34789. abstract camera: Camera;
  34790. /**
  34791. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34792. */
  34793. protected _altKey: boolean;
  34794. protected _ctrlKey: boolean;
  34795. protected _metaKey: boolean;
  34796. protected _shiftKey: boolean;
  34797. /**
  34798. * Which mouse buttons were pressed at time of last mouse event.
  34799. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34800. */
  34801. protected _buttonsPressed: number;
  34802. /**
  34803. * Defines the buttons associated with the input to handle camera move.
  34804. */
  34805. buttons: number[];
  34806. /**
  34807. * Attach the input controls to a specific dom element to get the input from.
  34808. * @param element Defines the element the controls should be listened from
  34809. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34810. */
  34811. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34812. /**
  34813. * Detach the current controls from the specified dom element.
  34814. * @param element Defines the element to stop listening the inputs from
  34815. */
  34816. detachControl(element: Nullable<HTMLElement>): void;
  34817. /**
  34818. * Gets the class name of the current input.
  34819. * @returns the class name
  34820. */
  34821. getClassName(): string;
  34822. /**
  34823. * Get the friendly name associated with the input class.
  34824. * @returns the input friendly name
  34825. */
  34826. getSimpleName(): string;
  34827. /**
  34828. * Called on pointer POINTERDOUBLETAP event.
  34829. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34830. */
  34831. protected onDoubleTap(type: string): void;
  34832. /**
  34833. * Called on pointer POINTERMOVE event if only a single touch is active.
  34834. * Override this method to provide functionality.
  34835. */
  34836. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34837. /**
  34838. * Called on pointer POINTERMOVE event if multiple touches are active.
  34839. * Override this method to provide functionality.
  34840. */
  34841. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34842. /**
  34843. * Called on JS contextmenu event.
  34844. * Override this method to provide functionality.
  34845. */
  34846. protected onContextMenu(evt: PointerEvent): void;
  34847. /**
  34848. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34849. * press.
  34850. * Override this method to provide functionality.
  34851. */
  34852. protected onButtonDown(evt: PointerEvent): void;
  34853. /**
  34854. * Called each time a new POINTERUP event occurs. Ie, for each button
  34855. * release.
  34856. * Override this method to provide functionality.
  34857. */
  34858. protected onButtonUp(evt: PointerEvent): void;
  34859. /**
  34860. * Called when window becomes inactive.
  34861. * Override this method to provide functionality.
  34862. */
  34863. protected onLostFocus(): void;
  34864. private _pointerInput;
  34865. private _observer;
  34866. private _onLostFocus;
  34867. private pointA;
  34868. private pointB;
  34869. }
  34870. }
  34871. declare module BABYLON {
  34872. /**
  34873. * Manage the pointers inputs to control an arc rotate camera.
  34874. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34875. */
  34876. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34877. /**
  34878. * Defines the camera the input is attached to.
  34879. */
  34880. camera: ArcRotateCamera;
  34881. /**
  34882. * Gets the class name of the current input.
  34883. * @returns the class name
  34884. */
  34885. getClassName(): string;
  34886. /**
  34887. * Defines the buttons associated with the input to handle camera move.
  34888. */
  34889. buttons: number[];
  34890. /**
  34891. * Defines the pointer angular sensibility along the X axis or how fast is
  34892. * the camera rotating.
  34893. */
  34894. angularSensibilityX: number;
  34895. /**
  34896. * Defines the pointer angular sensibility along the Y axis or how fast is
  34897. * the camera rotating.
  34898. */
  34899. angularSensibilityY: number;
  34900. /**
  34901. * Defines the pointer pinch precision or how fast is the camera zooming.
  34902. */
  34903. pinchPrecision: number;
  34904. /**
  34905. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34906. * from 0.
  34907. * It defines the percentage of current camera.radius to use as delta when
  34908. * pinch zoom is used.
  34909. */
  34910. pinchDeltaPercentage: number;
  34911. /**
  34912. * Defines the pointer panning sensibility or how fast is the camera moving.
  34913. */
  34914. panningSensibility: number;
  34915. /**
  34916. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34917. */
  34918. multiTouchPanning: boolean;
  34919. /**
  34920. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34921. * zoom (pinch) through multitouch.
  34922. */
  34923. multiTouchPanAndZoom: boolean;
  34924. /**
  34925. * Revers pinch action direction.
  34926. */
  34927. pinchInwards: boolean;
  34928. private _isPanClick;
  34929. private _twoFingerActivityCount;
  34930. private _isPinching;
  34931. /**
  34932. * Called on pointer POINTERMOVE event if only a single touch is active.
  34933. */
  34934. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34935. /**
  34936. * Called on pointer POINTERDOUBLETAP event.
  34937. */
  34938. protected onDoubleTap(type: string): void;
  34939. /**
  34940. * Called on pointer POINTERMOVE event if multiple touches are active.
  34941. */
  34942. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34943. /**
  34944. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34945. * press.
  34946. */
  34947. protected onButtonDown(evt: PointerEvent): void;
  34948. /**
  34949. * Called each time a new POINTERUP event occurs. Ie, for each button
  34950. * release.
  34951. */
  34952. protected onButtonUp(evt: PointerEvent): void;
  34953. /**
  34954. * Called when window becomes inactive.
  34955. */
  34956. protected onLostFocus(): void;
  34957. }
  34958. }
  34959. declare module BABYLON {
  34960. /**
  34961. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34962. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34963. */
  34964. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34965. /**
  34966. * Defines the camera the input is attached to.
  34967. */
  34968. camera: ArcRotateCamera;
  34969. /**
  34970. * Defines the list of key codes associated with the up action (increase alpha)
  34971. */
  34972. keysUp: number[];
  34973. /**
  34974. * Defines the list of key codes associated with the down action (decrease alpha)
  34975. */
  34976. keysDown: number[];
  34977. /**
  34978. * Defines the list of key codes associated with the left action (increase beta)
  34979. */
  34980. keysLeft: number[];
  34981. /**
  34982. * Defines the list of key codes associated with the right action (decrease beta)
  34983. */
  34984. keysRight: number[];
  34985. /**
  34986. * Defines the list of key codes associated with the reset action.
  34987. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34988. */
  34989. keysReset: number[];
  34990. /**
  34991. * Defines the panning sensibility of the inputs.
  34992. * (How fast is the camera paning)
  34993. */
  34994. panningSensibility: number;
  34995. /**
  34996. * Defines the zooming sensibility of the inputs.
  34997. * (How fast is the camera zooming)
  34998. */
  34999. zoomingSensibility: number;
  35000. /**
  35001. * Defines wether maintaining the alt key down switch the movement mode from
  35002. * orientation to zoom.
  35003. */
  35004. useAltToZoom: boolean;
  35005. /**
  35006. * Rotation speed of the camera
  35007. */
  35008. angularSpeed: number;
  35009. private _keys;
  35010. private _ctrlPressed;
  35011. private _altPressed;
  35012. private _onCanvasBlurObserver;
  35013. private _onKeyboardObserver;
  35014. private _engine;
  35015. private _scene;
  35016. /**
  35017. * Attach the input controls to a specific dom element to get the input from.
  35018. * @param element Defines the element the controls should be listened from
  35019. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35020. */
  35021. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35022. /**
  35023. * Detach the current controls from the specified dom element.
  35024. * @param element Defines the element to stop listening the inputs from
  35025. */
  35026. detachControl(element: Nullable<HTMLElement>): void;
  35027. /**
  35028. * Update the current camera state depending on the inputs that have been used this frame.
  35029. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35030. */
  35031. checkInputs(): void;
  35032. /**
  35033. * Gets the class name of the current intput.
  35034. * @returns the class name
  35035. */
  35036. getClassName(): string;
  35037. /**
  35038. * Get the friendly name associated with the input class.
  35039. * @returns the input friendly name
  35040. */
  35041. getSimpleName(): string;
  35042. }
  35043. }
  35044. declare module BABYLON {
  35045. /**
  35046. * Manage the mouse wheel inputs to control an arc rotate camera.
  35047. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35048. */
  35049. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35050. /**
  35051. * Defines the camera the input is attached to.
  35052. */
  35053. camera: ArcRotateCamera;
  35054. /**
  35055. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35056. */
  35057. wheelPrecision: number;
  35058. /**
  35059. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35060. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35061. */
  35062. wheelDeltaPercentage: number;
  35063. private _wheel;
  35064. private _observer;
  35065. private computeDeltaFromMouseWheelLegacyEvent;
  35066. /**
  35067. * Attach the input controls to a specific dom element to get the input from.
  35068. * @param element Defines the element the controls should be listened from
  35069. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35070. */
  35071. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35072. /**
  35073. * Detach the current controls from the specified dom element.
  35074. * @param element Defines the element to stop listening the inputs from
  35075. */
  35076. detachControl(element: Nullable<HTMLElement>): void;
  35077. /**
  35078. * Gets the class name of the current intput.
  35079. * @returns the class name
  35080. */
  35081. getClassName(): string;
  35082. /**
  35083. * Get the friendly name associated with the input class.
  35084. * @returns the input friendly name
  35085. */
  35086. getSimpleName(): string;
  35087. }
  35088. }
  35089. declare module BABYLON {
  35090. /**
  35091. * Default Inputs manager for the ArcRotateCamera.
  35092. * It groups all the default supported inputs for ease of use.
  35093. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35094. */
  35095. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35096. /**
  35097. * Instantiates a new ArcRotateCameraInputsManager.
  35098. * @param camera Defines the camera the inputs belong to
  35099. */
  35100. constructor(camera: ArcRotateCamera);
  35101. /**
  35102. * Add mouse wheel input support to the input manager.
  35103. * @returns the current input manager
  35104. */
  35105. addMouseWheel(): ArcRotateCameraInputsManager;
  35106. /**
  35107. * Add pointers input support to the input manager.
  35108. * @returns the current input manager
  35109. */
  35110. addPointers(): ArcRotateCameraInputsManager;
  35111. /**
  35112. * Add keyboard input support to the input manager.
  35113. * @returns the current input manager
  35114. */
  35115. addKeyboard(): ArcRotateCameraInputsManager;
  35116. }
  35117. }
  35118. declare module BABYLON {
  35119. /**
  35120. * This represents an orbital type of camera.
  35121. *
  35122. * 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.
  35123. * 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.
  35124. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35125. */
  35126. export class ArcRotateCamera extends TargetCamera {
  35127. /**
  35128. * Defines the rotation angle of the camera along the longitudinal axis.
  35129. */
  35130. alpha: number;
  35131. /**
  35132. * Defines the rotation angle of the camera along the latitudinal axis.
  35133. */
  35134. beta: number;
  35135. /**
  35136. * Defines the radius of the camera from it s target point.
  35137. */
  35138. radius: number;
  35139. protected _target: Vector3;
  35140. protected _targetHost: Nullable<AbstractMesh>;
  35141. /**
  35142. * Defines the target point of the camera.
  35143. * The camera looks towards it form the radius distance.
  35144. */
  35145. target: Vector3;
  35146. /**
  35147. * Define the current local position of the camera in the scene
  35148. */
  35149. position: Vector3;
  35150. protected _upVector: Vector3;
  35151. protected _upToYMatrix: Matrix;
  35152. protected _YToUpMatrix: Matrix;
  35153. /**
  35154. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35155. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35156. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35157. */
  35158. upVector: Vector3;
  35159. /**
  35160. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35161. */
  35162. setMatUp(): void;
  35163. /**
  35164. * Current inertia value on the longitudinal axis.
  35165. * The bigger this number the longer it will take for the camera to stop.
  35166. */
  35167. inertialAlphaOffset: number;
  35168. /**
  35169. * Current inertia value on the latitudinal axis.
  35170. * The bigger this number the longer it will take for the camera to stop.
  35171. */
  35172. inertialBetaOffset: number;
  35173. /**
  35174. * Current inertia value on the radius axis.
  35175. * The bigger this number the longer it will take for the camera to stop.
  35176. */
  35177. inertialRadiusOffset: number;
  35178. /**
  35179. * Minimum allowed angle on the longitudinal axis.
  35180. * This can help limiting how the Camera is able to move in the scene.
  35181. */
  35182. lowerAlphaLimit: Nullable<number>;
  35183. /**
  35184. * Maximum allowed angle on the longitudinal axis.
  35185. * This can help limiting how the Camera is able to move in the scene.
  35186. */
  35187. upperAlphaLimit: Nullable<number>;
  35188. /**
  35189. * Minimum allowed angle on the latitudinal axis.
  35190. * This can help limiting how the Camera is able to move in the scene.
  35191. */
  35192. lowerBetaLimit: number;
  35193. /**
  35194. * Maximum allowed angle on the latitudinal axis.
  35195. * This can help limiting how the Camera is able to move in the scene.
  35196. */
  35197. upperBetaLimit: number;
  35198. /**
  35199. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35200. * This can help limiting how the Camera is able to move in the scene.
  35201. */
  35202. lowerRadiusLimit: Nullable<number>;
  35203. /**
  35204. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35205. * This can help limiting how the Camera is able to move in the scene.
  35206. */
  35207. upperRadiusLimit: Nullable<number>;
  35208. /**
  35209. * Defines the current inertia value used during panning of the camera along the X axis.
  35210. */
  35211. inertialPanningX: number;
  35212. /**
  35213. * Defines the current inertia value used during panning of the camera along the Y axis.
  35214. */
  35215. inertialPanningY: number;
  35216. /**
  35217. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35218. * Basically if your fingers moves away from more than this distance you will be considered
  35219. * in pinch mode.
  35220. */
  35221. pinchToPanMaxDistance: number;
  35222. /**
  35223. * Defines the maximum distance the camera can pan.
  35224. * This could help keeping the cammera always in your scene.
  35225. */
  35226. panningDistanceLimit: Nullable<number>;
  35227. /**
  35228. * Defines the target of the camera before paning.
  35229. */
  35230. panningOriginTarget: Vector3;
  35231. /**
  35232. * Defines the value of the inertia used during panning.
  35233. * 0 would mean stop inertia and one would mean no decelleration at all.
  35234. */
  35235. panningInertia: number;
  35236. /**
  35237. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35238. */
  35239. angularSensibilityX: number;
  35240. /**
  35241. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35242. */
  35243. angularSensibilityY: number;
  35244. /**
  35245. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35246. */
  35247. pinchPrecision: number;
  35248. /**
  35249. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35250. * It will be used instead of pinchDeltaPrecision if different from 0.
  35251. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35252. */
  35253. pinchDeltaPercentage: number;
  35254. /**
  35255. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35256. */
  35257. panningSensibility: number;
  35258. /**
  35259. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35260. */
  35261. keysUp: number[];
  35262. /**
  35263. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35264. */
  35265. keysDown: number[];
  35266. /**
  35267. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35268. */
  35269. keysLeft: number[];
  35270. /**
  35271. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35272. */
  35273. keysRight: number[];
  35274. /**
  35275. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35276. */
  35277. wheelPrecision: number;
  35278. /**
  35279. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35280. * It will be used instead of pinchDeltaPrecision if different from 0.
  35281. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35282. */
  35283. wheelDeltaPercentage: number;
  35284. /**
  35285. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35286. */
  35287. zoomOnFactor: number;
  35288. /**
  35289. * Defines a screen offset for the camera position.
  35290. */
  35291. targetScreenOffset: Vector2;
  35292. /**
  35293. * Allows the camera to be completely reversed.
  35294. * If false the camera can not arrive upside down.
  35295. */
  35296. allowUpsideDown: boolean;
  35297. /**
  35298. * Define if double tap/click is used to restore the previously saved state of the camera.
  35299. */
  35300. useInputToRestoreState: boolean;
  35301. /** @hidden */
  35302. _viewMatrix: Matrix;
  35303. /** @hidden */
  35304. _useCtrlForPanning: boolean;
  35305. /** @hidden */
  35306. _panningMouseButton: number;
  35307. /**
  35308. * Defines the input associated to the camera.
  35309. */
  35310. inputs: ArcRotateCameraInputsManager;
  35311. /** @hidden */
  35312. _reset: () => void;
  35313. /**
  35314. * Defines the allowed panning axis.
  35315. */
  35316. panningAxis: Vector3;
  35317. protected _localDirection: Vector3;
  35318. protected _transformedDirection: Vector3;
  35319. private _bouncingBehavior;
  35320. /**
  35321. * Gets the bouncing behavior of the camera if it has been enabled.
  35322. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35323. */
  35324. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35325. /**
  35326. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35327. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35328. */
  35329. useBouncingBehavior: boolean;
  35330. private _framingBehavior;
  35331. /**
  35332. * Gets the framing behavior of the camera if it has been enabled.
  35333. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35334. */
  35335. readonly framingBehavior: Nullable<FramingBehavior>;
  35336. /**
  35337. * Defines if the framing behavior of the camera is enabled on the camera.
  35338. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35339. */
  35340. useFramingBehavior: boolean;
  35341. private _autoRotationBehavior;
  35342. /**
  35343. * Gets the auto rotation behavior of the camera if it has been enabled.
  35344. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35345. */
  35346. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35347. /**
  35348. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35349. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35350. */
  35351. useAutoRotationBehavior: boolean;
  35352. /**
  35353. * Observable triggered when the mesh target has been changed on the camera.
  35354. */
  35355. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35356. /**
  35357. * Event raised when the camera is colliding with a mesh.
  35358. */
  35359. onCollide: (collidedMesh: AbstractMesh) => void;
  35360. /**
  35361. * Defines whether the camera should check collision with the objects oh the scene.
  35362. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35363. */
  35364. checkCollisions: boolean;
  35365. /**
  35366. * Defines the collision radius of the camera.
  35367. * This simulates a sphere around the camera.
  35368. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35369. */
  35370. collisionRadius: Vector3;
  35371. protected _collider: Collider;
  35372. protected _previousPosition: Vector3;
  35373. protected _collisionVelocity: Vector3;
  35374. protected _newPosition: Vector3;
  35375. protected _previousAlpha: number;
  35376. protected _previousBeta: number;
  35377. protected _previousRadius: number;
  35378. protected _collisionTriggered: boolean;
  35379. protected _targetBoundingCenter: Nullable<Vector3>;
  35380. private _computationVector;
  35381. /**
  35382. * Instantiates a new ArcRotateCamera in a given scene
  35383. * @param name Defines the name of the camera
  35384. * @param alpha Defines the camera rotation along the logitudinal axis
  35385. * @param beta Defines the camera rotation along the latitudinal axis
  35386. * @param radius Defines the camera distance from its target
  35387. * @param target Defines the camera target
  35388. * @param scene Defines the scene the camera belongs to
  35389. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35390. */
  35391. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35392. /** @hidden */
  35393. _initCache(): void;
  35394. /** @hidden */
  35395. _updateCache(ignoreParentClass?: boolean): void;
  35396. protected _getTargetPosition(): Vector3;
  35397. private _storedAlpha;
  35398. private _storedBeta;
  35399. private _storedRadius;
  35400. private _storedTarget;
  35401. /**
  35402. * Stores the current state of the camera (alpha, beta, radius and target)
  35403. * @returns the camera itself
  35404. */
  35405. storeState(): Camera;
  35406. /**
  35407. * @hidden
  35408. * Restored camera state. You must call storeState() first
  35409. */
  35410. _restoreStateValues(): boolean;
  35411. /** @hidden */
  35412. _isSynchronizedViewMatrix(): boolean;
  35413. /**
  35414. * Attached controls to the current camera.
  35415. * @param element Defines the element the controls should be listened from
  35416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35417. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35418. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35419. */
  35420. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35421. /**
  35422. * Detach the current controls from the camera.
  35423. * The camera will stop reacting to inputs.
  35424. * @param element Defines the element to stop listening the inputs from
  35425. */
  35426. detachControl(element: HTMLElement): void;
  35427. /** @hidden */
  35428. _checkInputs(): void;
  35429. protected _checkLimits(): void;
  35430. /**
  35431. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35432. */
  35433. rebuildAnglesAndRadius(): void;
  35434. /**
  35435. * Use a position to define the current camera related information like aplha, beta and radius
  35436. * @param position Defines the position to set the camera at
  35437. */
  35438. setPosition(position: Vector3): void;
  35439. /**
  35440. * Defines the target the camera should look at.
  35441. * This will automatically adapt alpha beta and radius to fit within the new target.
  35442. * @param target Defines the new target as a Vector or a mesh
  35443. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35444. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35445. */
  35446. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35447. /** @hidden */
  35448. _getViewMatrix(): Matrix;
  35449. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35450. /**
  35451. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35452. * @param meshes Defines the mesh to zoom on
  35453. * @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)
  35454. */
  35455. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35456. /**
  35457. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35458. * The target will be changed but the radius
  35459. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35460. * @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)
  35461. */
  35462. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35463. min: Vector3;
  35464. max: Vector3;
  35465. distance: number;
  35466. }, doNotUpdateMaxZ?: boolean): void;
  35467. /**
  35468. * @override
  35469. * Override Camera.createRigCamera
  35470. */
  35471. createRigCamera(name: string, cameraIndex: number): Camera;
  35472. /**
  35473. * @hidden
  35474. * @override
  35475. * Override Camera._updateRigCameras
  35476. */
  35477. _updateRigCameras(): void;
  35478. /**
  35479. * Destroy the camera and release the current resources hold by it.
  35480. */
  35481. dispose(): void;
  35482. /**
  35483. * Gets the current object class name.
  35484. * @return the class name
  35485. */
  35486. getClassName(): string;
  35487. }
  35488. }
  35489. declare module BABYLON {
  35490. /**
  35491. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35492. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35493. */
  35494. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35495. /**
  35496. * Gets the name of the behavior.
  35497. */
  35498. readonly name: string;
  35499. private _zoomStopsAnimation;
  35500. private _idleRotationSpeed;
  35501. private _idleRotationWaitTime;
  35502. private _idleRotationSpinupTime;
  35503. /**
  35504. * Sets the flag that indicates if user zooming should stop animation.
  35505. */
  35506. /**
  35507. * Gets the flag that indicates if user zooming should stop animation.
  35508. */
  35509. zoomStopsAnimation: boolean;
  35510. /**
  35511. * Sets the default speed at which the camera rotates around the model.
  35512. */
  35513. /**
  35514. * Gets the default speed at which the camera rotates around the model.
  35515. */
  35516. idleRotationSpeed: number;
  35517. /**
  35518. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35519. */
  35520. /**
  35521. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35522. */
  35523. idleRotationWaitTime: number;
  35524. /**
  35525. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35526. */
  35527. /**
  35528. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35529. */
  35530. idleRotationSpinupTime: number;
  35531. /**
  35532. * Gets a value indicating if the camera is currently rotating because of this behavior
  35533. */
  35534. readonly rotationInProgress: boolean;
  35535. private _onPrePointerObservableObserver;
  35536. private _onAfterCheckInputsObserver;
  35537. private _attachedCamera;
  35538. private _isPointerDown;
  35539. private _lastFrameTime;
  35540. private _lastInteractionTime;
  35541. private _cameraRotationSpeed;
  35542. /**
  35543. * Initializes the behavior.
  35544. */
  35545. init(): void;
  35546. /**
  35547. * Attaches the behavior to its arc rotate camera.
  35548. * @param camera Defines the camera to attach the behavior to
  35549. */
  35550. attach(camera: ArcRotateCamera): void;
  35551. /**
  35552. * Detaches the behavior from its current arc rotate camera.
  35553. */
  35554. detach(): void;
  35555. /**
  35556. * Returns true if user is scrolling.
  35557. * @return true if user is scrolling.
  35558. */
  35559. private _userIsZooming;
  35560. private _lastFrameRadius;
  35561. private _shouldAnimationStopForInteraction;
  35562. /**
  35563. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35564. */
  35565. private _applyUserInteraction;
  35566. private _userIsMoving;
  35567. }
  35568. }
  35569. declare module BABYLON {
  35570. /**
  35571. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35572. */
  35573. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35574. private ui;
  35575. /**
  35576. * The name of the behavior
  35577. */
  35578. name: string;
  35579. /**
  35580. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35581. */
  35582. distanceAwayFromFace: number;
  35583. /**
  35584. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35585. */
  35586. distanceAwayFromBottomOfFace: number;
  35587. private _faceVectors;
  35588. private _target;
  35589. private _scene;
  35590. private _onRenderObserver;
  35591. private _tmpMatrix;
  35592. private _tmpVector;
  35593. /**
  35594. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35595. * @param ui The transform node that should be attched to the mesh
  35596. */
  35597. constructor(ui: TransformNode);
  35598. /**
  35599. * Initializes the behavior
  35600. */
  35601. init(): void;
  35602. private _closestFace;
  35603. private _zeroVector;
  35604. private _lookAtTmpMatrix;
  35605. private _lookAtToRef;
  35606. /**
  35607. * Attaches the AttachToBoxBehavior to the passed in mesh
  35608. * @param target The mesh that the specified node will be attached to
  35609. */
  35610. attach(target: Mesh): void;
  35611. /**
  35612. * Detaches the behavior from the mesh
  35613. */
  35614. detach(): void;
  35615. }
  35616. }
  35617. declare module BABYLON {
  35618. /**
  35619. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35620. */
  35621. export class FadeInOutBehavior implements Behavior<Mesh> {
  35622. /**
  35623. * Time in milliseconds to delay before fading in (Default: 0)
  35624. */
  35625. delay: number;
  35626. /**
  35627. * Time in milliseconds for the mesh to fade in (Default: 300)
  35628. */
  35629. fadeInTime: number;
  35630. private _millisecondsPerFrame;
  35631. private _hovered;
  35632. private _hoverValue;
  35633. private _ownerNode;
  35634. /**
  35635. * Instatiates the FadeInOutBehavior
  35636. */
  35637. constructor();
  35638. /**
  35639. * The name of the behavior
  35640. */
  35641. readonly name: string;
  35642. /**
  35643. * Initializes the behavior
  35644. */
  35645. init(): void;
  35646. /**
  35647. * Attaches the fade behavior on the passed in mesh
  35648. * @param ownerNode The mesh that will be faded in/out once attached
  35649. */
  35650. attach(ownerNode: Mesh): void;
  35651. /**
  35652. * Detaches the behavior from the mesh
  35653. */
  35654. detach(): void;
  35655. /**
  35656. * Triggers the mesh to begin fading in or out
  35657. * @param value if the object should fade in or out (true to fade in)
  35658. */
  35659. fadeIn(value: boolean): void;
  35660. private _update;
  35661. private _setAllVisibility;
  35662. }
  35663. }
  35664. declare module BABYLON {
  35665. /**
  35666. * Class containing a set of static utilities functions for managing Pivots
  35667. * @hidden
  35668. */
  35669. export class PivotTools {
  35670. private static _PivotCached;
  35671. private static _OldPivotPoint;
  35672. private static _PivotTranslation;
  35673. private static _PivotTmpVector;
  35674. /** @hidden */
  35675. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35676. /** @hidden */
  35677. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35678. }
  35679. }
  35680. declare module BABYLON {
  35681. /**
  35682. * Class containing static functions to help procedurally build meshes
  35683. */
  35684. export class PlaneBuilder {
  35685. /**
  35686. * Creates a plane mesh
  35687. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35688. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35689. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35691. * * 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
  35692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35693. * @param name defines the name of the mesh
  35694. * @param options defines the options used to create the mesh
  35695. * @param scene defines the hosting scene
  35696. * @returns the plane mesh
  35697. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35698. */
  35699. static CreatePlane(name: string, options: {
  35700. size?: number;
  35701. width?: number;
  35702. height?: number;
  35703. sideOrientation?: number;
  35704. frontUVs?: Vector4;
  35705. backUVs?: Vector4;
  35706. updatable?: boolean;
  35707. sourcePlane?: Plane;
  35708. }, scene?: Nullable<Scene>): Mesh;
  35709. }
  35710. }
  35711. declare module BABYLON {
  35712. /**
  35713. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35714. */
  35715. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35716. private static _AnyMouseID;
  35717. private _attachedNode;
  35718. private _dragPlane;
  35719. private _scene;
  35720. private _pointerObserver;
  35721. private _beforeRenderObserver;
  35722. private static _planeScene;
  35723. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35724. /**
  35725. * 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)
  35726. */
  35727. maxDragAngle: number;
  35728. /**
  35729. * @hidden
  35730. */
  35731. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35732. /**
  35733. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35734. */
  35735. currentDraggingPointerID: number;
  35736. /**
  35737. * The last position where the pointer hit the drag plane in world space
  35738. */
  35739. lastDragPosition: Vector3;
  35740. /**
  35741. * If the behavior is currently in a dragging state
  35742. */
  35743. dragging: boolean;
  35744. /**
  35745. * 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)
  35746. */
  35747. dragDeltaRatio: number;
  35748. /**
  35749. * If the drag plane orientation should be updated during the dragging (Default: true)
  35750. */
  35751. updateDragPlane: boolean;
  35752. private _debugMode;
  35753. private _moving;
  35754. /**
  35755. * Fires each time the attached mesh is dragged with the pointer
  35756. * * delta between last drag position and current drag position in world space
  35757. * * dragDistance along the drag axis
  35758. * * dragPlaneNormal normal of the current drag plane used during the drag
  35759. * * dragPlanePoint in world space where the drag intersects the drag plane
  35760. */
  35761. onDragObservable: Observable<{
  35762. delta: Vector3;
  35763. dragPlanePoint: Vector3;
  35764. dragPlaneNormal: Vector3;
  35765. dragDistance: number;
  35766. pointerId: number;
  35767. }>;
  35768. /**
  35769. * Fires each time a drag begins (eg. mouse down on mesh)
  35770. */
  35771. onDragStartObservable: Observable<{
  35772. dragPlanePoint: Vector3;
  35773. pointerId: number;
  35774. }>;
  35775. /**
  35776. * Fires each time a drag ends (eg. mouse release after drag)
  35777. */
  35778. onDragEndObservable: Observable<{
  35779. dragPlanePoint: Vector3;
  35780. pointerId: number;
  35781. }>;
  35782. /**
  35783. * If the attached mesh should be moved when dragged
  35784. */
  35785. moveAttached: boolean;
  35786. /**
  35787. * If the drag behavior will react to drag events (Default: true)
  35788. */
  35789. enabled: boolean;
  35790. /**
  35791. * If camera controls should be detached during the drag
  35792. */
  35793. detachCameraControls: boolean;
  35794. /**
  35795. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35796. */
  35797. useObjectOrienationForDragging: boolean;
  35798. private _options;
  35799. /**
  35800. * Creates a pointer drag behavior that can be attached to a mesh
  35801. * @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)
  35802. */
  35803. constructor(options?: {
  35804. dragAxis?: Vector3;
  35805. dragPlaneNormal?: Vector3;
  35806. });
  35807. /**
  35808. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35809. */
  35810. validateDrag: (targetPosition: Vector3) => boolean;
  35811. /**
  35812. * The name of the behavior
  35813. */
  35814. readonly name: string;
  35815. /**
  35816. * Initializes the behavior
  35817. */
  35818. init(): void;
  35819. private _tmpVector;
  35820. private _alternatePickedPoint;
  35821. private _worldDragAxis;
  35822. private _targetPosition;
  35823. private _attachedElement;
  35824. /**
  35825. * Attaches the drag behavior the passed in mesh
  35826. * @param ownerNode The mesh that will be dragged around once attached
  35827. */
  35828. attach(ownerNode: AbstractMesh): void;
  35829. /**
  35830. * Force relase the drag action by code.
  35831. */
  35832. releaseDrag(): void;
  35833. private _startDragRay;
  35834. private _lastPointerRay;
  35835. /**
  35836. * Simulates the start of a pointer drag event on the behavior
  35837. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35838. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35839. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35840. */
  35841. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35842. private _startDrag;
  35843. private _dragDelta;
  35844. private _moveDrag;
  35845. private _pickWithRayOnDragPlane;
  35846. private _pointA;
  35847. private _pointB;
  35848. private _pointC;
  35849. private _lineA;
  35850. private _lineB;
  35851. private _localAxis;
  35852. private _lookAt;
  35853. private _updateDragPlanePosition;
  35854. /**
  35855. * Detaches the behavior from the mesh
  35856. */
  35857. detach(): void;
  35858. }
  35859. }
  35860. declare module BABYLON {
  35861. /**
  35862. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35863. */
  35864. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35865. private _dragBehaviorA;
  35866. private _dragBehaviorB;
  35867. private _startDistance;
  35868. private _initialScale;
  35869. private _targetScale;
  35870. private _ownerNode;
  35871. private _sceneRenderObserver;
  35872. /**
  35873. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35874. */
  35875. constructor();
  35876. /**
  35877. * The name of the behavior
  35878. */
  35879. readonly name: string;
  35880. /**
  35881. * Initializes the behavior
  35882. */
  35883. init(): void;
  35884. private _getCurrentDistance;
  35885. /**
  35886. * Attaches the scale behavior the passed in mesh
  35887. * @param ownerNode The mesh that will be scaled around once attached
  35888. */
  35889. attach(ownerNode: Mesh): void;
  35890. /**
  35891. * Detaches the behavior from the mesh
  35892. */
  35893. detach(): void;
  35894. }
  35895. }
  35896. declare module BABYLON {
  35897. /**
  35898. * 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
  35899. */
  35900. export class SixDofDragBehavior implements Behavior<Mesh> {
  35901. private static _virtualScene;
  35902. private _ownerNode;
  35903. private _sceneRenderObserver;
  35904. private _scene;
  35905. private _targetPosition;
  35906. private _virtualOriginMesh;
  35907. private _virtualDragMesh;
  35908. private _pointerObserver;
  35909. private _moving;
  35910. private _startingOrientation;
  35911. /**
  35912. * 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)
  35913. */
  35914. private zDragFactor;
  35915. /**
  35916. * If the object should rotate to face the drag origin
  35917. */
  35918. rotateDraggedObject: boolean;
  35919. /**
  35920. * If the behavior is currently in a dragging state
  35921. */
  35922. dragging: boolean;
  35923. /**
  35924. * 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)
  35925. */
  35926. dragDeltaRatio: number;
  35927. /**
  35928. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35929. */
  35930. currentDraggingPointerID: number;
  35931. /**
  35932. * If camera controls should be detached during the drag
  35933. */
  35934. detachCameraControls: boolean;
  35935. /**
  35936. * Fires each time a drag starts
  35937. */
  35938. onDragStartObservable: Observable<{}>;
  35939. /**
  35940. * Fires each time a drag ends (eg. mouse release after drag)
  35941. */
  35942. onDragEndObservable: Observable<{}>;
  35943. /**
  35944. * 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
  35945. */
  35946. constructor();
  35947. /**
  35948. * The name of the behavior
  35949. */
  35950. readonly name: string;
  35951. /**
  35952. * Initializes the behavior
  35953. */
  35954. init(): void;
  35955. /**
  35956. * Attaches the scale behavior the passed in mesh
  35957. * @param ownerNode The mesh that will be scaled around once attached
  35958. */
  35959. attach(ownerNode: Mesh): void;
  35960. /**
  35961. * Detaches the behavior from the mesh
  35962. */
  35963. detach(): void;
  35964. }
  35965. }
  35966. declare module BABYLON {
  35967. /**
  35968. * Class used to apply inverse kinematics to bones
  35969. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35970. */
  35971. export class BoneIKController {
  35972. private static _tmpVecs;
  35973. private static _tmpQuat;
  35974. private static _tmpMats;
  35975. /**
  35976. * Gets or sets the target mesh
  35977. */
  35978. targetMesh: AbstractMesh;
  35979. /** Gets or sets the mesh used as pole */
  35980. poleTargetMesh: AbstractMesh;
  35981. /**
  35982. * Gets or sets the bone used as pole
  35983. */
  35984. poleTargetBone: Nullable<Bone>;
  35985. /**
  35986. * Gets or sets the target position
  35987. */
  35988. targetPosition: Vector3;
  35989. /**
  35990. * Gets or sets the pole target position
  35991. */
  35992. poleTargetPosition: Vector3;
  35993. /**
  35994. * Gets or sets the pole target local offset
  35995. */
  35996. poleTargetLocalOffset: Vector3;
  35997. /**
  35998. * Gets or sets the pole angle
  35999. */
  36000. poleAngle: number;
  36001. /**
  36002. * Gets or sets the mesh associated with the controller
  36003. */
  36004. mesh: AbstractMesh;
  36005. /**
  36006. * 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)
  36007. */
  36008. slerpAmount: number;
  36009. private _bone1Quat;
  36010. private _bone1Mat;
  36011. private _bone2Ang;
  36012. private _bone1;
  36013. private _bone2;
  36014. private _bone1Length;
  36015. private _bone2Length;
  36016. private _maxAngle;
  36017. private _maxReach;
  36018. private _rightHandedSystem;
  36019. private _bendAxis;
  36020. private _slerping;
  36021. private _adjustRoll;
  36022. /**
  36023. * Gets or sets maximum allowed angle
  36024. */
  36025. maxAngle: number;
  36026. /**
  36027. * Creates a new BoneIKController
  36028. * @param mesh defines the mesh to control
  36029. * @param bone defines the bone to control
  36030. * @param options defines options to set up the controller
  36031. */
  36032. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36033. targetMesh?: AbstractMesh;
  36034. poleTargetMesh?: AbstractMesh;
  36035. poleTargetBone?: Bone;
  36036. poleTargetLocalOffset?: Vector3;
  36037. poleAngle?: number;
  36038. bendAxis?: Vector3;
  36039. maxAngle?: number;
  36040. slerpAmount?: number;
  36041. });
  36042. private _setMaxAngle;
  36043. /**
  36044. * Force the controller to update the bones
  36045. */
  36046. update(): void;
  36047. }
  36048. }
  36049. declare module BABYLON {
  36050. /**
  36051. * Class used to make a bone look toward a point in space
  36052. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36053. */
  36054. export class BoneLookController {
  36055. private static _tmpVecs;
  36056. private static _tmpQuat;
  36057. private static _tmpMats;
  36058. /**
  36059. * The target Vector3 that the bone will look at
  36060. */
  36061. target: Vector3;
  36062. /**
  36063. * The mesh that the bone is attached to
  36064. */
  36065. mesh: AbstractMesh;
  36066. /**
  36067. * The bone that will be looking to the target
  36068. */
  36069. bone: Bone;
  36070. /**
  36071. * The up axis of the coordinate system that is used when the bone is rotated
  36072. */
  36073. upAxis: Vector3;
  36074. /**
  36075. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36076. */
  36077. upAxisSpace: Space;
  36078. /**
  36079. * Used to make an adjustment to the yaw of the bone
  36080. */
  36081. adjustYaw: number;
  36082. /**
  36083. * Used to make an adjustment to the pitch of the bone
  36084. */
  36085. adjustPitch: number;
  36086. /**
  36087. * Used to make an adjustment to the roll of the bone
  36088. */
  36089. adjustRoll: number;
  36090. /**
  36091. * 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)
  36092. */
  36093. slerpAmount: number;
  36094. private _minYaw;
  36095. private _maxYaw;
  36096. private _minPitch;
  36097. private _maxPitch;
  36098. private _minYawSin;
  36099. private _minYawCos;
  36100. private _maxYawSin;
  36101. private _maxYawCos;
  36102. private _midYawConstraint;
  36103. private _minPitchTan;
  36104. private _maxPitchTan;
  36105. private _boneQuat;
  36106. private _slerping;
  36107. private _transformYawPitch;
  36108. private _transformYawPitchInv;
  36109. private _firstFrameSkipped;
  36110. private _yawRange;
  36111. private _fowardAxis;
  36112. /**
  36113. * Gets or sets the minimum yaw angle that the bone can look to
  36114. */
  36115. minYaw: number;
  36116. /**
  36117. * Gets or sets the maximum yaw angle that the bone can look to
  36118. */
  36119. maxYaw: number;
  36120. /**
  36121. * Gets or sets the minimum pitch angle that the bone can look to
  36122. */
  36123. minPitch: number;
  36124. /**
  36125. * Gets or sets the maximum pitch angle that the bone can look to
  36126. */
  36127. maxPitch: number;
  36128. /**
  36129. * Create a BoneLookController
  36130. * @param mesh the mesh that the bone belongs to
  36131. * @param bone the bone that will be looking to the target
  36132. * @param target the target Vector3 to look at
  36133. * @param options optional settings:
  36134. * * maxYaw: the maximum angle the bone will yaw to
  36135. * * minYaw: the minimum angle the bone will yaw to
  36136. * * maxPitch: the maximum angle the bone will pitch to
  36137. * * minPitch: the minimum angle the bone will yaw to
  36138. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36139. * * upAxis: the up axis of the coordinate system
  36140. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36141. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36142. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36143. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36144. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36145. * * adjustRoll: used to make an adjustment to the roll of the bone
  36146. **/
  36147. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36148. maxYaw?: number;
  36149. minYaw?: number;
  36150. maxPitch?: number;
  36151. minPitch?: number;
  36152. slerpAmount?: number;
  36153. upAxis?: Vector3;
  36154. upAxisSpace?: Space;
  36155. yawAxis?: Vector3;
  36156. pitchAxis?: Vector3;
  36157. adjustYaw?: number;
  36158. adjustPitch?: number;
  36159. adjustRoll?: number;
  36160. });
  36161. /**
  36162. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36163. */
  36164. update(): void;
  36165. private _getAngleDiff;
  36166. private _getAngleBetween;
  36167. private _isAngleBetween;
  36168. }
  36169. }
  36170. declare module BABYLON {
  36171. /**
  36172. * Manage the gamepad inputs to control an arc rotate camera.
  36173. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36174. */
  36175. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36176. /**
  36177. * Defines the camera the input is attached to.
  36178. */
  36179. camera: ArcRotateCamera;
  36180. /**
  36181. * Defines the gamepad the input is gathering event from.
  36182. */
  36183. gamepad: Nullable<Gamepad>;
  36184. /**
  36185. * Defines the gamepad rotation sensiblity.
  36186. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36187. */
  36188. gamepadRotationSensibility: number;
  36189. /**
  36190. * Defines the gamepad move sensiblity.
  36191. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36192. */
  36193. gamepadMoveSensibility: number;
  36194. private _onGamepadConnectedObserver;
  36195. private _onGamepadDisconnectedObserver;
  36196. /**
  36197. * Attach the input controls to a specific dom element to get the input from.
  36198. * @param element Defines the element the controls should be listened from
  36199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36200. */
  36201. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36202. /**
  36203. * Detach the current controls from the specified dom element.
  36204. * @param element Defines the element to stop listening the inputs from
  36205. */
  36206. detachControl(element: Nullable<HTMLElement>): void;
  36207. /**
  36208. * Update the current camera state depending on the inputs that have been used this frame.
  36209. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36210. */
  36211. checkInputs(): void;
  36212. /**
  36213. * Gets the class name of the current intput.
  36214. * @returns the class name
  36215. */
  36216. getClassName(): string;
  36217. /**
  36218. * Get the friendly name associated with the input class.
  36219. * @returns the input friendly name
  36220. */
  36221. getSimpleName(): string;
  36222. }
  36223. }
  36224. declare module BABYLON {
  36225. interface ArcRotateCameraInputsManager {
  36226. /**
  36227. * Add orientation input support to the input manager.
  36228. * @returns the current input manager
  36229. */
  36230. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36231. }
  36232. /**
  36233. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36234. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36235. */
  36236. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36237. /**
  36238. * Defines the camera the input is attached to.
  36239. */
  36240. camera: ArcRotateCamera;
  36241. /**
  36242. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36243. */
  36244. alphaCorrection: number;
  36245. /**
  36246. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36247. */
  36248. gammaCorrection: number;
  36249. private _alpha;
  36250. private _gamma;
  36251. private _dirty;
  36252. private _deviceOrientationHandler;
  36253. /**
  36254. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36255. */
  36256. constructor();
  36257. /**
  36258. * Attach the input controls to a specific dom element to get the input from.
  36259. * @param element Defines the element the controls should be listened from
  36260. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36261. */
  36262. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36263. /** @hidden */
  36264. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36265. /**
  36266. * Update the current camera state depending on the inputs that have been used this frame.
  36267. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36268. */
  36269. checkInputs(): void;
  36270. /**
  36271. * Detach the current controls from the specified dom element.
  36272. * @param element Defines the element to stop listening the inputs from
  36273. */
  36274. detachControl(element: Nullable<HTMLElement>): void;
  36275. /**
  36276. * Gets the class name of the current intput.
  36277. * @returns the class name
  36278. */
  36279. getClassName(): string;
  36280. /**
  36281. * Get the friendly name associated with the input class.
  36282. * @returns the input friendly name
  36283. */
  36284. getSimpleName(): string;
  36285. }
  36286. }
  36287. declare module BABYLON {
  36288. /**
  36289. * Listen to mouse events to control the camera.
  36290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36291. */
  36292. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36293. /**
  36294. * Defines the camera the input is attached to.
  36295. */
  36296. camera: FlyCamera;
  36297. /**
  36298. * Defines if touch is enabled. (Default is true.)
  36299. */
  36300. touchEnabled: boolean;
  36301. /**
  36302. * Defines the buttons associated with the input to handle camera rotation.
  36303. */
  36304. buttons: number[];
  36305. /**
  36306. * Assign buttons for Yaw control.
  36307. */
  36308. buttonsYaw: number[];
  36309. /**
  36310. * Assign buttons for Pitch control.
  36311. */
  36312. buttonsPitch: number[];
  36313. /**
  36314. * Assign buttons for Roll control.
  36315. */
  36316. buttonsRoll: number[];
  36317. /**
  36318. * Detect if any button is being pressed while mouse is moved.
  36319. * -1 = Mouse locked.
  36320. * 0 = Left button.
  36321. * 1 = Middle Button.
  36322. * 2 = Right Button.
  36323. */
  36324. activeButton: number;
  36325. /**
  36326. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36327. * Higher values reduce its sensitivity.
  36328. */
  36329. angularSensibility: number;
  36330. private _mousemoveCallback;
  36331. private _observer;
  36332. private _rollObserver;
  36333. private previousPosition;
  36334. private noPreventDefault;
  36335. private element;
  36336. /**
  36337. * Listen to mouse events to control the camera.
  36338. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36339. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36340. */
  36341. constructor(touchEnabled?: boolean);
  36342. /**
  36343. * Attach the mouse control to the HTML DOM element.
  36344. * @param element Defines the element that listens to the input events.
  36345. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36346. */
  36347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36348. /**
  36349. * Detach the current controls from the specified dom element.
  36350. * @param element Defines the element to stop listening the inputs from
  36351. */
  36352. detachControl(element: Nullable<HTMLElement>): void;
  36353. /**
  36354. * Gets the class name of the current input.
  36355. * @returns the class name.
  36356. */
  36357. getClassName(): string;
  36358. /**
  36359. * Get the friendly name associated with the input class.
  36360. * @returns the input's friendly name.
  36361. */
  36362. getSimpleName(): string;
  36363. private _pointerInput;
  36364. private _onMouseMove;
  36365. /**
  36366. * Rotate camera by mouse offset.
  36367. */
  36368. private rotateCamera;
  36369. }
  36370. }
  36371. declare module BABYLON {
  36372. /**
  36373. * Default Inputs manager for the FlyCamera.
  36374. * It groups all the default supported inputs for ease of use.
  36375. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36376. */
  36377. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36378. /**
  36379. * Instantiates a new FlyCameraInputsManager.
  36380. * @param camera Defines the camera the inputs belong to.
  36381. */
  36382. constructor(camera: FlyCamera);
  36383. /**
  36384. * Add keyboard input support to the input manager.
  36385. * @returns the new FlyCameraKeyboardMoveInput().
  36386. */
  36387. addKeyboard(): FlyCameraInputsManager;
  36388. /**
  36389. * Add mouse input support to the input manager.
  36390. * @param touchEnabled Enable touch screen support.
  36391. * @returns the new FlyCameraMouseInput().
  36392. */
  36393. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36394. }
  36395. }
  36396. declare module BABYLON {
  36397. /**
  36398. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36399. * such as in a 3D Space Shooter or a Flight Simulator.
  36400. */
  36401. export class FlyCamera extends TargetCamera {
  36402. /**
  36403. * Define the collision ellipsoid of the camera.
  36404. * This is helpful for simulating a camera body, like a player's body.
  36405. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36406. */
  36407. ellipsoid: Vector3;
  36408. /**
  36409. * Define an offset for the position of the ellipsoid around the camera.
  36410. * This can be helpful if the camera is attached away from the player's body center,
  36411. * such as at its head.
  36412. */
  36413. ellipsoidOffset: Vector3;
  36414. /**
  36415. * Enable or disable collisions of the camera with the rest of the scene objects.
  36416. */
  36417. checkCollisions: boolean;
  36418. /**
  36419. * Enable or disable gravity on the camera.
  36420. */
  36421. applyGravity: boolean;
  36422. /**
  36423. * Define the current direction the camera is moving to.
  36424. */
  36425. cameraDirection: Vector3;
  36426. /**
  36427. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36428. * This overrides and empties cameraRotation.
  36429. */
  36430. rotationQuaternion: Quaternion;
  36431. /**
  36432. * Track Roll to maintain the wanted Rolling when looking around.
  36433. */
  36434. _trackRoll: number;
  36435. /**
  36436. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36437. */
  36438. rollCorrect: number;
  36439. /**
  36440. * Mimic a banked turn, Rolling the camera when Yawing.
  36441. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36442. */
  36443. bankedTurn: boolean;
  36444. /**
  36445. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36446. */
  36447. bankedTurnLimit: number;
  36448. /**
  36449. * Value of 0 disables the banked Roll.
  36450. * Value of 1 is equal to the Yaw angle in radians.
  36451. */
  36452. bankedTurnMultiplier: number;
  36453. /**
  36454. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36455. */
  36456. inputs: FlyCameraInputsManager;
  36457. /**
  36458. * Gets the input sensibility for mouse input.
  36459. * Higher values reduce sensitivity.
  36460. */
  36461. /**
  36462. * Sets the input sensibility for a mouse input.
  36463. * Higher values reduce sensitivity.
  36464. */
  36465. angularSensibility: number;
  36466. /**
  36467. * Get the keys for camera movement forward.
  36468. */
  36469. /**
  36470. * Set the keys for camera movement forward.
  36471. */
  36472. keysForward: number[];
  36473. /**
  36474. * Get the keys for camera movement backward.
  36475. */
  36476. keysBackward: number[];
  36477. /**
  36478. * Get the keys for camera movement up.
  36479. */
  36480. /**
  36481. * Set the keys for camera movement up.
  36482. */
  36483. keysUp: number[];
  36484. /**
  36485. * Get the keys for camera movement down.
  36486. */
  36487. /**
  36488. * Set the keys for camera movement down.
  36489. */
  36490. keysDown: number[];
  36491. /**
  36492. * Get the keys for camera movement left.
  36493. */
  36494. /**
  36495. * Set the keys for camera movement left.
  36496. */
  36497. keysLeft: number[];
  36498. /**
  36499. * Set the keys for camera movement right.
  36500. */
  36501. /**
  36502. * Set the keys for camera movement right.
  36503. */
  36504. keysRight: number[];
  36505. /**
  36506. * Event raised when the camera collides with a mesh in the scene.
  36507. */
  36508. onCollide: (collidedMesh: AbstractMesh) => void;
  36509. private _collider;
  36510. private _needMoveForGravity;
  36511. private _oldPosition;
  36512. private _diffPosition;
  36513. private _newPosition;
  36514. /** @hidden */
  36515. _localDirection: Vector3;
  36516. /** @hidden */
  36517. _transformedDirection: Vector3;
  36518. /**
  36519. * Instantiates a FlyCamera.
  36520. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36521. * such as in a 3D Space Shooter or a Flight Simulator.
  36522. * @param name Define the name of the camera in the scene.
  36523. * @param position Define the starting position of the camera in the scene.
  36524. * @param scene Define the scene the camera belongs to.
  36525. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36526. */
  36527. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36528. /**
  36529. * Attach a control to the HTML DOM element.
  36530. * @param element Defines the element that listens to the input events.
  36531. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36532. */
  36533. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36534. /**
  36535. * Detach a control from the HTML DOM element.
  36536. * The camera will stop reacting to that input.
  36537. * @param element Defines the element that listens to the input events.
  36538. */
  36539. detachControl(element: HTMLElement): void;
  36540. private _collisionMask;
  36541. /**
  36542. * Get the mask that the camera ignores in collision events.
  36543. */
  36544. /**
  36545. * Set the mask that the camera ignores in collision events.
  36546. */
  36547. collisionMask: number;
  36548. /** @hidden */
  36549. _collideWithWorld(displacement: Vector3): void;
  36550. /** @hidden */
  36551. private _onCollisionPositionChange;
  36552. /** @hidden */
  36553. _checkInputs(): void;
  36554. /** @hidden */
  36555. _decideIfNeedsToMove(): boolean;
  36556. /** @hidden */
  36557. _updatePosition(): void;
  36558. /**
  36559. * Restore the Roll to its target value at the rate specified.
  36560. * @param rate - Higher means slower restoring.
  36561. * @hidden
  36562. */
  36563. restoreRoll(rate: number): void;
  36564. /**
  36565. * Destroy the camera and release the current resources held by it.
  36566. */
  36567. dispose(): void;
  36568. /**
  36569. * Get the current object class name.
  36570. * @returns the class name.
  36571. */
  36572. getClassName(): string;
  36573. }
  36574. }
  36575. declare module BABYLON {
  36576. /**
  36577. * Listen to keyboard events to control the camera.
  36578. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36579. */
  36580. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36581. /**
  36582. * Defines the camera the input is attached to.
  36583. */
  36584. camera: FlyCamera;
  36585. /**
  36586. * The list of keyboard keys used to control the forward move of the camera.
  36587. */
  36588. keysForward: number[];
  36589. /**
  36590. * The list of keyboard keys used to control the backward move of the camera.
  36591. */
  36592. keysBackward: number[];
  36593. /**
  36594. * The list of keyboard keys used to control the forward move of the camera.
  36595. */
  36596. keysUp: number[];
  36597. /**
  36598. * The list of keyboard keys used to control the backward move of the camera.
  36599. */
  36600. keysDown: number[];
  36601. /**
  36602. * The list of keyboard keys used to control the right strafe move of the camera.
  36603. */
  36604. keysRight: number[];
  36605. /**
  36606. * The list of keyboard keys used to control the left strafe move of the camera.
  36607. */
  36608. keysLeft: number[];
  36609. private _keys;
  36610. private _onCanvasBlurObserver;
  36611. private _onKeyboardObserver;
  36612. private _engine;
  36613. private _scene;
  36614. /**
  36615. * Attach the input controls to a specific dom element to get the input from.
  36616. * @param element Defines the element the controls should be listened from
  36617. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36618. */
  36619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36620. /**
  36621. * Detach the current controls from the specified dom element.
  36622. * @param element Defines the element to stop listening the inputs from
  36623. */
  36624. detachControl(element: Nullable<HTMLElement>): void;
  36625. /**
  36626. * Gets the class name of the current intput.
  36627. * @returns the class name
  36628. */
  36629. getClassName(): string;
  36630. /** @hidden */
  36631. _onLostFocus(e: FocusEvent): void;
  36632. /**
  36633. * Get the friendly name associated with the input class.
  36634. * @returns the input friendly name
  36635. */
  36636. getSimpleName(): string;
  36637. /**
  36638. * Update the current camera state depending on the inputs that have been used this frame.
  36639. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36640. */
  36641. checkInputs(): void;
  36642. }
  36643. }
  36644. declare module BABYLON {
  36645. /**
  36646. * Manage the mouse wheel inputs to control a follow camera.
  36647. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36648. */
  36649. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36650. /**
  36651. * Defines the camera the input is attached to.
  36652. */
  36653. camera: FollowCamera;
  36654. /**
  36655. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36656. */
  36657. axisControlRadius: boolean;
  36658. /**
  36659. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36660. */
  36661. axisControlHeight: boolean;
  36662. /**
  36663. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36664. */
  36665. axisControlRotation: boolean;
  36666. /**
  36667. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36668. * relation to mouseWheel events.
  36669. */
  36670. wheelPrecision: number;
  36671. /**
  36672. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36673. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36674. */
  36675. wheelDeltaPercentage: number;
  36676. private _wheel;
  36677. private _observer;
  36678. /**
  36679. * Attach the input controls to a specific dom element to get the input from.
  36680. * @param element Defines the element the controls should be listened from
  36681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36682. */
  36683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36684. /**
  36685. * Detach the current controls from the specified dom element.
  36686. * @param element Defines the element to stop listening the inputs from
  36687. */
  36688. detachControl(element: Nullable<HTMLElement>): void;
  36689. /**
  36690. * Gets the class name of the current intput.
  36691. * @returns the class name
  36692. */
  36693. getClassName(): string;
  36694. /**
  36695. * Get the friendly name associated with the input class.
  36696. * @returns the input friendly name
  36697. */
  36698. getSimpleName(): string;
  36699. }
  36700. }
  36701. declare module BABYLON {
  36702. /**
  36703. * Manage the pointers inputs to control an follow camera.
  36704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36705. */
  36706. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36707. /**
  36708. * Defines the camera the input is attached to.
  36709. */
  36710. camera: FollowCamera;
  36711. /**
  36712. * Gets the class name of the current input.
  36713. * @returns the class name
  36714. */
  36715. getClassName(): string;
  36716. /**
  36717. * Defines the pointer angular sensibility along the X axis or how fast is
  36718. * the camera rotating.
  36719. * A negative number will reverse the axis direction.
  36720. */
  36721. angularSensibilityX: number;
  36722. /**
  36723. * Defines the pointer angular sensibility along the Y axis or how fast is
  36724. * the camera rotating.
  36725. * A negative number will reverse the axis direction.
  36726. */
  36727. angularSensibilityY: number;
  36728. /**
  36729. * Defines the pointer pinch precision or how fast is the camera zooming.
  36730. * A negative number will reverse the axis direction.
  36731. */
  36732. pinchPrecision: number;
  36733. /**
  36734. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36735. * from 0.
  36736. * It defines the percentage of current camera.radius to use as delta when
  36737. * pinch zoom is used.
  36738. */
  36739. pinchDeltaPercentage: number;
  36740. /**
  36741. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36742. */
  36743. axisXControlRadius: boolean;
  36744. /**
  36745. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36746. */
  36747. axisXControlHeight: boolean;
  36748. /**
  36749. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36750. */
  36751. axisXControlRotation: boolean;
  36752. /**
  36753. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36754. */
  36755. axisYControlRadius: boolean;
  36756. /**
  36757. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36758. */
  36759. axisYControlHeight: boolean;
  36760. /**
  36761. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36762. */
  36763. axisYControlRotation: boolean;
  36764. /**
  36765. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36766. */
  36767. axisPinchControlRadius: boolean;
  36768. /**
  36769. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36770. */
  36771. axisPinchControlHeight: boolean;
  36772. /**
  36773. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36774. */
  36775. axisPinchControlRotation: boolean;
  36776. /**
  36777. * Log error messages if basic misconfiguration has occurred.
  36778. */
  36779. warningEnable: boolean;
  36780. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36781. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36782. private _warningCounter;
  36783. private _warning;
  36784. }
  36785. }
  36786. declare module BABYLON {
  36787. /**
  36788. * Default Inputs manager for the FollowCamera.
  36789. * It groups all the default supported inputs for ease of use.
  36790. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36791. */
  36792. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36793. /**
  36794. * Instantiates a new FollowCameraInputsManager.
  36795. * @param camera Defines the camera the inputs belong to
  36796. */
  36797. constructor(camera: FollowCamera);
  36798. /**
  36799. * Add keyboard input support to the input manager.
  36800. * @returns the current input manager
  36801. */
  36802. addKeyboard(): FollowCameraInputsManager;
  36803. /**
  36804. * Add mouse wheel input support to the input manager.
  36805. * @returns the current input manager
  36806. */
  36807. addMouseWheel(): FollowCameraInputsManager;
  36808. /**
  36809. * Add pointers input support to the input manager.
  36810. * @returns the current input manager
  36811. */
  36812. addPointers(): FollowCameraInputsManager;
  36813. /**
  36814. * Add orientation input support to the input manager.
  36815. * @returns the current input manager
  36816. */
  36817. addVRDeviceOrientation(): FollowCameraInputsManager;
  36818. }
  36819. }
  36820. declare module BABYLON {
  36821. /**
  36822. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36823. * an arc rotate version arcFollowCamera are available.
  36824. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36825. */
  36826. export class FollowCamera extends TargetCamera {
  36827. /**
  36828. * Distance the follow camera should follow an object at
  36829. */
  36830. radius: number;
  36831. /**
  36832. * Minimum allowed distance of the camera to the axis of rotation
  36833. * (The camera can not get closer).
  36834. * This can help limiting how the Camera is able to move in the scene.
  36835. */
  36836. lowerRadiusLimit: Nullable<number>;
  36837. /**
  36838. * Maximum allowed distance of the camera to the axis of rotation
  36839. * (The camera can not get further).
  36840. * This can help limiting how the Camera is able to move in the scene.
  36841. */
  36842. upperRadiusLimit: Nullable<number>;
  36843. /**
  36844. * Define a rotation offset between the camera and the object it follows
  36845. */
  36846. rotationOffset: number;
  36847. /**
  36848. * Minimum allowed angle to camera position relative to target object.
  36849. * This can help limiting how the Camera is able to move in the scene.
  36850. */
  36851. lowerRotationOffsetLimit: Nullable<number>;
  36852. /**
  36853. * Maximum allowed angle to camera position relative to target object.
  36854. * This can help limiting how the Camera is able to move in the scene.
  36855. */
  36856. upperRotationOffsetLimit: Nullable<number>;
  36857. /**
  36858. * Define a height offset between the camera and the object it follows.
  36859. * It can help following an object from the top (like a car chaing a plane)
  36860. */
  36861. heightOffset: number;
  36862. /**
  36863. * Minimum allowed height of camera position relative to target object.
  36864. * This can help limiting how the Camera is able to move in the scene.
  36865. */
  36866. lowerHeightOffsetLimit: Nullable<number>;
  36867. /**
  36868. * Maximum allowed height of camera position relative to target object.
  36869. * This can help limiting how the Camera is able to move in the scene.
  36870. */
  36871. upperHeightOffsetLimit: Nullable<number>;
  36872. /**
  36873. * Define how fast the camera can accelerate to follow it s target.
  36874. */
  36875. cameraAcceleration: number;
  36876. /**
  36877. * Define the speed limit of the camera following an object.
  36878. */
  36879. maxCameraSpeed: number;
  36880. /**
  36881. * Define the target of the camera.
  36882. */
  36883. lockedTarget: Nullable<AbstractMesh>;
  36884. /**
  36885. * Defines the input associated with the camera.
  36886. */
  36887. inputs: FollowCameraInputsManager;
  36888. /**
  36889. * Instantiates the follow camera.
  36890. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36891. * @param name Define the name of the camera in the scene
  36892. * @param position Define the position of the camera
  36893. * @param scene Define the scene the camera belong to
  36894. * @param lockedTarget Define the target of the camera
  36895. */
  36896. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36897. private _follow;
  36898. /**
  36899. * Attached controls to the current camera.
  36900. * @param element Defines the element the controls should be listened from
  36901. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36902. */
  36903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36904. /**
  36905. * Detach the current controls from the camera.
  36906. * The camera will stop reacting to inputs.
  36907. * @param element Defines the element to stop listening the inputs from
  36908. */
  36909. detachControl(element: HTMLElement): void;
  36910. /** @hidden */
  36911. _checkInputs(): void;
  36912. private _checkLimits;
  36913. /**
  36914. * Gets the camera class name.
  36915. * @returns the class name
  36916. */
  36917. getClassName(): string;
  36918. }
  36919. /**
  36920. * Arc Rotate version of the follow camera.
  36921. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36922. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36923. */
  36924. export class ArcFollowCamera extends TargetCamera {
  36925. /** The longitudinal angle of the camera */
  36926. alpha: number;
  36927. /** The latitudinal angle of the camera */
  36928. beta: number;
  36929. /** The radius of the camera from its target */
  36930. radius: number;
  36931. /** Define the camera target (the messh it should follow) */
  36932. target: Nullable<AbstractMesh>;
  36933. private _cartesianCoordinates;
  36934. /**
  36935. * Instantiates a new ArcFollowCamera
  36936. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36937. * @param name Define the name of the camera
  36938. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36939. * @param beta Define the rotation angle of the camera around the elevation axis
  36940. * @param radius Define the radius of the camera from its target point
  36941. * @param target Define the target of the camera
  36942. * @param scene Define the scene the camera belongs to
  36943. */
  36944. constructor(name: string,
  36945. /** The longitudinal angle of the camera */
  36946. alpha: number,
  36947. /** The latitudinal angle of the camera */
  36948. beta: number,
  36949. /** The radius of the camera from its target */
  36950. radius: number,
  36951. /** Define the camera target (the messh it should follow) */
  36952. target: Nullable<AbstractMesh>, scene: Scene);
  36953. private _follow;
  36954. /** @hidden */
  36955. _checkInputs(): void;
  36956. /**
  36957. * Returns the class name of the object.
  36958. * It is mostly used internally for serialization purposes.
  36959. */
  36960. getClassName(): string;
  36961. }
  36962. }
  36963. declare module BABYLON {
  36964. /**
  36965. * Manage the keyboard inputs to control the movement of a follow camera.
  36966. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36967. */
  36968. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36969. /**
  36970. * Defines the camera the input is attached to.
  36971. */
  36972. camera: FollowCamera;
  36973. /**
  36974. * Defines the list of key codes associated with the up action (increase heightOffset)
  36975. */
  36976. keysHeightOffsetIncr: number[];
  36977. /**
  36978. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36979. */
  36980. keysHeightOffsetDecr: number[];
  36981. /**
  36982. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36983. */
  36984. keysHeightOffsetModifierAlt: boolean;
  36985. /**
  36986. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36987. */
  36988. keysHeightOffsetModifierCtrl: boolean;
  36989. /**
  36990. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36991. */
  36992. keysHeightOffsetModifierShift: boolean;
  36993. /**
  36994. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36995. */
  36996. keysRotationOffsetIncr: number[];
  36997. /**
  36998. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36999. */
  37000. keysRotationOffsetDecr: number[];
  37001. /**
  37002. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37003. */
  37004. keysRotationOffsetModifierAlt: boolean;
  37005. /**
  37006. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37007. */
  37008. keysRotationOffsetModifierCtrl: boolean;
  37009. /**
  37010. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37011. */
  37012. keysRotationOffsetModifierShift: boolean;
  37013. /**
  37014. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37015. */
  37016. keysRadiusIncr: number[];
  37017. /**
  37018. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37019. */
  37020. keysRadiusDecr: number[];
  37021. /**
  37022. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37023. */
  37024. keysRadiusModifierAlt: boolean;
  37025. /**
  37026. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37027. */
  37028. keysRadiusModifierCtrl: boolean;
  37029. /**
  37030. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37031. */
  37032. keysRadiusModifierShift: boolean;
  37033. /**
  37034. * Defines the rate of change of heightOffset.
  37035. */
  37036. heightSensibility: number;
  37037. /**
  37038. * Defines the rate of change of rotationOffset.
  37039. */
  37040. rotationSensibility: number;
  37041. /**
  37042. * Defines the rate of change of radius.
  37043. */
  37044. radiusSensibility: number;
  37045. private _keys;
  37046. private _ctrlPressed;
  37047. private _altPressed;
  37048. private _shiftPressed;
  37049. private _onCanvasBlurObserver;
  37050. private _onKeyboardObserver;
  37051. private _engine;
  37052. private _scene;
  37053. /**
  37054. * Attach the input controls to a specific dom element to get the input from.
  37055. * @param element Defines the element the controls should be listened from
  37056. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37057. */
  37058. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37059. /**
  37060. * Detach the current controls from the specified dom element.
  37061. * @param element Defines the element to stop listening the inputs from
  37062. */
  37063. detachControl(element: Nullable<HTMLElement>): void;
  37064. /**
  37065. * Update the current camera state depending on the inputs that have been used this frame.
  37066. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37067. */
  37068. checkInputs(): void;
  37069. /**
  37070. * Gets the class name of the current input.
  37071. * @returns the class name
  37072. */
  37073. getClassName(): string;
  37074. /**
  37075. * Get the friendly name associated with the input class.
  37076. * @returns the input friendly name
  37077. */
  37078. getSimpleName(): string;
  37079. /**
  37080. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37081. * allow modification of the heightOffset value.
  37082. */
  37083. private _modifierHeightOffset;
  37084. /**
  37085. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37086. * allow modification of the rotationOffset value.
  37087. */
  37088. private _modifierRotationOffset;
  37089. /**
  37090. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37091. * allow modification of the radius value.
  37092. */
  37093. private _modifierRadius;
  37094. }
  37095. }
  37096. declare module BABYLON {
  37097. interface FreeCameraInputsManager {
  37098. /**
  37099. * @hidden
  37100. */
  37101. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37102. /**
  37103. * Add orientation input support to the input manager.
  37104. * @returns the current input manager
  37105. */
  37106. addDeviceOrientation(): FreeCameraInputsManager;
  37107. }
  37108. /**
  37109. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37110. * Screen rotation is taken into account.
  37111. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37112. */
  37113. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37114. private _camera;
  37115. private _screenOrientationAngle;
  37116. private _constantTranform;
  37117. private _screenQuaternion;
  37118. private _alpha;
  37119. private _beta;
  37120. private _gamma;
  37121. /**
  37122. * @hidden
  37123. */
  37124. _onDeviceOrientationChangedObservable: Observable<void>;
  37125. /**
  37126. * Instantiates a new input
  37127. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37128. */
  37129. constructor();
  37130. /**
  37131. * Define the camera controlled by the input.
  37132. */
  37133. camera: FreeCamera;
  37134. /**
  37135. * Attach the input controls to a specific dom element to get the input from.
  37136. * @param element Defines the element the controls should be listened from
  37137. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37138. */
  37139. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37140. private _orientationChanged;
  37141. private _deviceOrientation;
  37142. /**
  37143. * Detach the current controls from the specified dom element.
  37144. * @param element Defines the element to stop listening the inputs from
  37145. */
  37146. detachControl(element: Nullable<HTMLElement>): void;
  37147. /**
  37148. * Update the current camera state depending on the inputs that have been used this frame.
  37149. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37150. */
  37151. checkInputs(): void;
  37152. /**
  37153. * Gets the class name of the current intput.
  37154. * @returns the class name
  37155. */
  37156. getClassName(): string;
  37157. /**
  37158. * Get the friendly name associated with the input class.
  37159. * @returns the input friendly name
  37160. */
  37161. getSimpleName(): string;
  37162. }
  37163. }
  37164. declare module BABYLON {
  37165. /**
  37166. * Manage the gamepad inputs to control a free camera.
  37167. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37168. */
  37169. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37170. /**
  37171. * Define the camera the input is attached to.
  37172. */
  37173. camera: FreeCamera;
  37174. /**
  37175. * Define the Gamepad controlling the input
  37176. */
  37177. gamepad: Nullable<Gamepad>;
  37178. /**
  37179. * Defines the gamepad rotation sensiblity.
  37180. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37181. */
  37182. gamepadAngularSensibility: number;
  37183. /**
  37184. * Defines the gamepad move sensiblity.
  37185. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37186. */
  37187. gamepadMoveSensibility: number;
  37188. private _onGamepadConnectedObserver;
  37189. private _onGamepadDisconnectedObserver;
  37190. private _cameraTransform;
  37191. private _deltaTransform;
  37192. private _vector3;
  37193. private _vector2;
  37194. /**
  37195. * Attach the input controls to a specific dom element to get the input from.
  37196. * @param element Defines the element the controls should be listened from
  37197. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37198. */
  37199. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37200. /**
  37201. * Detach the current controls from the specified dom element.
  37202. * @param element Defines the element to stop listening the inputs from
  37203. */
  37204. detachControl(element: Nullable<HTMLElement>): void;
  37205. /**
  37206. * Update the current camera state depending on the inputs that have been used this frame.
  37207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37208. */
  37209. checkInputs(): void;
  37210. /**
  37211. * Gets the class name of the current intput.
  37212. * @returns the class name
  37213. */
  37214. getClassName(): string;
  37215. /**
  37216. * Get the friendly name associated with the input class.
  37217. * @returns the input friendly name
  37218. */
  37219. getSimpleName(): string;
  37220. }
  37221. }
  37222. declare module BABYLON {
  37223. /**
  37224. * Defines the potential axis of a Joystick
  37225. */
  37226. export enum JoystickAxis {
  37227. /** X axis */
  37228. X = 0,
  37229. /** Y axis */
  37230. Y = 1,
  37231. /** Z axis */
  37232. Z = 2
  37233. }
  37234. /**
  37235. * Class used to define virtual joystick (used in touch mode)
  37236. */
  37237. export class VirtualJoystick {
  37238. /**
  37239. * Gets or sets a boolean indicating that left and right values must be inverted
  37240. */
  37241. reverseLeftRight: boolean;
  37242. /**
  37243. * Gets or sets a boolean indicating that up and down values must be inverted
  37244. */
  37245. reverseUpDown: boolean;
  37246. /**
  37247. * Gets the offset value for the position (ie. the change of the position value)
  37248. */
  37249. deltaPosition: Vector3;
  37250. /**
  37251. * Gets a boolean indicating if the virtual joystick was pressed
  37252. */
  37253. pressed: boolean;
  37254. /**
  37255. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37256. */
  37257. static Canvas: Nullable<HTMLCanvasElement>;
  37258. private static _globalJoystickIndex;
  37259. private static vjCanvasContext;
  37260. private static vjCanvasWidth;
  37261. private static vjCanvasHeight;
  37262. private static halfWidth;
  37263. private _action;
  37264. private _axisTargetedByLeftAndRight;
  37265. private _axisTargetedByUpAndDown;
  37266. private _joystickSensibility;
  37267. private _inversedSensibility;
  37268. private _joystickPointerID;
  37269. private _joystickColor;
  37270. private _joystickPointerPos;
  37271. private _joystickPreviousPointerPos;
  37272. private _joystickPointerStartPos;
  37273. private _deltaJoystickVector;
  37274. private _leftJoystick;
  37275. private _touches;
  37276. private _onPointerDownHandlerRef;
  37277. private _onPointerMoveHandlerRef;
  37278. private _onPointerUpHandlerRef;
  37279. private _onResize;
  37280. /**
  37281. * Creates a new virtual joystick
  37282. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37283. */
  37284. constructor(leftJoystick?: boolean);
  37285. /**
  37286. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37287. * @param newJoystickSensibility defines the new sensibility
  37288. */
  37289. setJoystickSensibility(newJoystickSensibility: number): void;
  37290. private _onPointerDown;
  37291. private _onPointerMove;
  37292. private _onPointerUp;
  37293. /**
  37294. * Change the color of the virtual joystick
  37295. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37296. */
  37297. setJoystickColor(newColor: string): void;
  37298. /**
  37299. * Defines a callback to call when the joystick is touched
  37300. * @param action defines the callback
  37301. */
  37302. setActionOnTouch(action: () => any): void;
  37303. /**
  37304. * Defines which axis you'd like to control for left & right
  37305. * @param axis defines the axis to use
  37306. */
  37307. setAxisForLeftRight(axis: JoystickAxis): void;
  37308. /**
  37309. * Defines which axis you'd like to control for up & down
  37310. * @param axis defines the axis to use
  37311. */
  37312. setAxisForUpDown(axis: JoystickAxis): void;
  37313. private _drawVirtualJoystick;
  37314. /**
  37315. * Release internal HTML canvas
  37316. */
  37317. releaseCanvas(): void;
  37318. }
  37319. }
  37320. declare module BABYLON {
  37321. interface FreeCameraInputsManager {
  37322. /**
  37323. * Add virtual joystick input support to the input manager.
  37324. * @returns the current input manager
  37325. */
  37326. addVirtualJoystick(): FreeCameraInputsManager;
  37327. }
  37328. /**
  37329. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37330. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37331. */
  37332. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37333. /**
  37334. * Defines the camera the input is attached to.
  37335. */
  37336. camera: FreeCamera;
  37337. private _leftjoystick;
  37338. private _rightjoystick;
  37339. /**
  37340. * Gets the left stick of the virtual joystick.
  37341. * @returns The virtual Joystick
  37342. */
  37343. getLeftJoystick(): VirtualJoystick;
  37344. /**
  37345. * Gets the right stick of the virtual joystick.
  37346. * @returns The virtual Joystick
  37347. */
  37348. getRightJoystick(): VirtualJoystick;
  37349. /**
  37350. * Update the current camera state depending on the inputs that have been used this frame.
  37351. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37352. */
  37353. checkInputs(): void;
  37354. /**
  37355. * Attach the input controls to a specific dom element to get the input from.
  37356. * @param element Defines the element the controls should be listened from
  37357. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37358. */
  37359. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37360. /**
  37361. * Detach the current controls from the specified dom element.
  37362. * @param element Defines the element to stop listening the inputs from
  37363. */
  37364. detachControl(element: Nullable<HTMLElement>): void;
  37365. /**
  37366. * Gets the class name of the current intput.
  37367. * @returns the class name
  37368. */
  37369. getClassName(): string;
  37370. /**
  37371. * Get the friendly name associated with the input class.
  37372. * @returns the input friendly name
  37373. */
  37374. getSimpleName(): string;
  37375. }
  37376. }
  37377. declare module BABYLON {
  37378. /**
  37379. * This represents a FPS type of camera controlled by touch.
  37380. * This is like a universal camera minus the Gamepad controls.
  37381. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37382. */
  37383. export class TouchCamera extends FreeCamera {
  37384. /**
  37385. * Defines the touch sensibility for rotation.
  37386. * The higher the faster.
  37387. */
  37388. touchAngularSensibility: number;
  37389. /**
  37390. * Defines the touch sensibility for move.
  37391. * The higher the faster.
  37392. */
  37393. touchMoveSensibility: number;
  37394. /**
  37395. * Instantiates a new touch camera.
  37396. * This represents a FPS type of camera controlled by touch.
  37397. * This is like a universal camera minus the Gamepad controls.
  37398. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37399. * @param name Define the name of the camera in the scene
  37400. * @param position Define the start position of the camera in the scene
  37401. * @param scene Define the scene the camera belongs to
  37402. */
  37403. constructor(name: string, position: Vector3, scene: Scene);
  37404. /**
  37405. * Gets the current object class name.
  37406. * @return the class name
  37407. */
  37408. getClassName(): string;
  37409. /** @hidden */
  37410. _setupInputs(): void;
  37411. }
  37412. }
  37413. declare module BABYLON {
  37414. /**
  37415. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37416. * being tilted forward or back and left or right.
  37417. */
  37418. export class DeviceOrientationCamera extends FreeCamera {
  37419. private _initialQuaternion;
  37420. private _quaternionCache;
  37421. private _tmpDragQuaternion;
  37422. /**
  37423. * Creates a new device orientation camera
  37424. * @param name The name of the camera
  37425. * @param position The start position camera
  37426. * @param scene The scene the camera belongs to
  37427. */
  37428. constructor(name: string, position: Vector3, scene: Scene);
  37429. /**
  37430. * @hidden
  37431. * Disabled pointer input on first orientation sensor update (Default: true)
  37432. */
  37433. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37434. private _dragFactor;
  37435. /**
  37436. * Enabled turning on the y axis when the orientation sensor is active
  37437. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37438. */
  37439. enableHorizontalDragging(dragFactor?: number): void;
  37440. /**
  37441. * Gets the current instance class name ("DeviceOrientationCamera").
  37442. * This helps avoiding instanceof at run time.
  37443. * @returns the class name
  37444. */
  37445. getClassName(): string;
  37446. /**
  37447. * @hidden
  37448. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37449. */
  37450. _checkInputs(): void;
  37451. /**
  37452. * Reset the camera to its default orientation on the specified axis only.
  37453. * @param axis The axis to reset
  37454. */
  37455. resetToCurrentRotation(axis?: Axis): void;
  37456. }
  37457. }
  37458. declare module BABYLON {
  37459. /**
  37460. * Defines supported buttons for XBox360 compatible gamepads
  37461. */
  37462. export enum Xbox360Button {
  37463. /** A */
  37464. A = 0,
  37465. /** B */
  37466. B = 1,
  37467. /** X */
  37468. X = 2,
  37469. /** Y */
  37470. Y = 3,
  37471. /** Start */
  37472. Start = 4,
  37473. /** Back */
  37474. Back = 5,
  37475. /** Left button */
  37476. LB = 6,
  37477. /** Right button */
  37478. RB = 7,
  37479. /** Left stick */
  37480. LeftStick = 8,
  37481. /** Right stick */
  37482. RightStick = 9
  37483. }
  37484. /** Defines values for XBox360 DPad */
  37485. export enum Xbox360Dpad {
  37486. /** Up */
  37487. Up = 0,
  37488. /** Down */
  37489. Down = 1,
  37490. /** Left */
  37491. Left = 2,
  37492. /** Right */
  37493. Right = 3
  37494. }
  37495. /**
  37496. * Defines a XBox360 gamepad
  37497. */
  37498. export class Xbox360Pad extends Gamepad {
  37499. private _leftTrigger;
  37500. private _rightTrigger;
  37501. private _onlefttriggerchanged;
  37502. private _onrighttriggerchanged;
  37503. private _onbuttondown;
  37504. private _onbuttonup;
  37505. private _ondpaddown;
  37506. private _ondpadup;
  37507. /** Observable raised when a button is pressed */
  37508. onButtonDownObservable: Observable<Xbox360Button>;
  37509. /** Observable raised when a button is released */
  37510. onButtonUpObservable: Observable<Xbox360Button>;
  37511. /** Observable raised when a pad is pressed */
  37512. onPadDownObservable: Observable<Xbox360Dpad>;
  37513. /** Observable raised when a pad is released */
  37514. onPadUpObservable: Observable<Xbox360Dpad>;
  37515. private _buttonA;
  37516. private _buttonB;
  37517. private _buttonX;
  37518. private _buttonY;
  37519. private _buttonBack;
  37520. private _buttonStart;
  37521. private _buttonLB;
  37522. private _buttonRB;
  37523. private _buttonLeftStick;
  37524. private _buttonRightStick;
  37525. private _dPadUp;
  37526. private _dPadDown;
  37527. private _dPadLeft;
  37528. private _dPadRight;
  37529. private _isXboxOnePad;
  37530. /**
  37531. * Creates a new XBox360 gamepad object
  37532. * @param id defines the id of this gamepad
  37533. * @param index defines its index
  37534. * @param gamepad defines the internal HTML gamepad object
  37535. * @param xboxOne defines if it is a XBox One gamepad
  37536. */
  37537. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37538. /**
  37539. * Defines the callback to call when left trigger is pressed
  37540. * @param callback defines the callback to use
  37541. */
  37542. onlefttriggerchanged(callback: (value: number) => void): void;
  37543. /**
  37544. * Defines the callback to call when right trigger is pressed
  37545. * @param callback defines the callback to use
  37546. */
  37547. onrighttriggerchanged(callback: (value: number) => void): void;
  37548. /**
  37549. * Gets the left trigger value
  37550. */
  37551. /**
  37552. * Sets the left trigger value
  37553. */
  37554. leftTrigger: number;
  37555. /**
  37556. * Gets the right trigger value
  37557. */
  37558. /**
  37559. * Sets the right trigger value
  37560. */
  37561. rightTrigger: number;
  37562. /**
  37563. * Defines the callback to call when a button is pressed
  37564. * @param callback defines the callback to use
  37565. */
  37566. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37567. /**
  37568. * Defines the callback to call when a button is released
  37569. * @param callback defines the callback to use
  37570. */
  37571. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37572. /**
  37573. * Defines the callback to call when a pad is pressed
  37574. * @param callback defines the callback to use
  37575. */
  37576. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37577. /**
  37578. * Defines the callback to call when a pad is released
  37579. * @param callback defines the callback to use
  37580. */
  37581. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37582. private _setButtonValue;
  37583. private _setDPadValue;
  37584. /**
  37585. * Gets the value of the `A` button
  37586. */
  37587. /**
  37588. * Sets the value of the `A` button
  37589. */
  37590. buttonA: number;
  37591. /**
  37592. * Gets the value of the `B` button
  37593. */
  37594. /**
  37595. * Sets the value of the `B` button
  37596. */
  37597. buttonB: number;
  37598. /**
  37599. * Gets the value of the `X` button
  37600. */
  37601. /**
  37602. * Sets the value of the `X` button
  37603. */
  37604. buttonX: number;
  37605. /**
  37606. * Gets the value of the `Y` button
  37607. */
  37608. /**
  37609. * Sets the value of the `Y` button
  37610. */
  37611. buttonY: number;
  37612. /**
  37613. * Gets the value of the `Start` button
  37614. */
  37615. /**
  37616. * Sets the value of the `Start` button
  37617. */
  37618. buttonStart: number;
  37619. /**
  37620. * Gets the value of the `Back` button
  37621. */
  37622. /**
  37623. * Sets the value of the `Back` button
  37624. */
  37625. buttonBack: number;
  37626. /**
  37627. * Gets the value of the `Left` button
  37628. */
  37629. /**
  37630. * Sets the value of the `Left` button
  37631. */
  37632. buttonLB: number;
  37633. /**
  37634. * Gets the value of the `Right` button
  37635. */
  37636. /**
  37637. * Sets the value of the `Right` button
  37638. */
  37639. buttonRB: number;
  37640. /**
  37641. * Gets the value of the Left joystick
  37642. */
  37643. /**
  37644. * Sets the value of the Left joystick
  37645. */
  37646. buttonLeftStick: number;
  37647. /**
  37648. * Gets the value of the Right joystick
  37649. */
  37650. /**
  37651. * Sets the value of the Right joystick
  37652. */
  37653. buttonRightStick: number;
  37654. /**
  37655. * Gets the value of D-pad up
  37656. */
  37657. /**
  37658. * Sets the value of D-pad up
  37659. */
  37660. dPadUp: number;
  37661. /**
  37662. * Gets the value of D-pad down
  37663. */
  37664. /**
  37665. * Sets the value of D-pad down
  37666. */
  37667. dPadDown: number;
  37668. /**
  37669. * Gets the value of D-pad left
  37670. */
  37671. /**
  37672. * Sets the value of D-pad left
  37673. */
  37674. dPadLeft: number;
  37675. /**
  37676. * Gets the value of D-pad right
  37677. */
  37678. /**
  37679. * Sets the value of D-pad right
  37680. */
  37681. dPadRight: number;
  37682. /**
  37683. * Force the gamepad to synchronize with device values
  37684. */
  37685. update(): void;
  37686. /**
  37687. * Disposes the gamepad
  37688. */
  37689. dispose(): void;
  37690. }
  37691. }
  37692. declare module BABYLON {
  37693. /**
  37694. * Manager for handling gamepads
  37695. */
  37696. export class GamepadManager {
  37697. private _scene?;
  37698. private _babylonGamepads;
  37699. private _oneGamepadConnected;
  37700. /** @hidden */
  37701. _isMonitoring: boolean;
  37702. private _gamepadEventSupported;
  37703. private _gamepadSupport;
  37704. /**
  37705. * observable to be triggered when the gamepad controller has been connected
  37706. */
  37707. onGamepadConnectedObservable: Observable<Gamepad>;
  37708. /**
  37709. * observable to be triggered when the gamepad controller has been disconnected
  37710. */
  37711. onGamepadDisconnectedObservable: Observable<Gamepad>;
  37712. private _onGamepadConnectedEvent;
  37713. private _onGamepadDisconnectedEvent;
  37714. /**
  37715. * Initializes the gamepad manager
  37716. * @param _scene BabylonJS scene
  37717. */
  37718. constructor(_scene?: Scene | undefined);
  37719. /**
  37720. * The gamepads in the game pad manager
  37721. */
  37722. readonly gamepads: Gamepad[];
  37723. /**
  37724. * Get the gamepad controllers based on type
  37725. * @param type The type of gamepad controller
  37726. * @returns Nullable gamepad
  37727. */
  37728. getGamepadByType(type?: number): Nullable<Gamepad>;
  37729. /**
  37730. * Disposes the gamepad manager
  37731. */
  37732. dispose(): void;
  37733. private _addNewGamepad;
  37734. private _startMonitoringGamepads;
  37735. private _stopMonitoringGamepads;
  37736. /** @hidden */
  37737. _checkGamepadsStatus(): void;
  37738. private _updateGamepadObjects;
  37739. }
  37740. }
  37741. declare module BABYLON {
  37742. interface Scene {
  37743. /** @hidden */
  37744. _gamepadManager: Nullable<GamepadManager>;
  37745. /**
  37746. * Gets the gamepad manager associated with the scene
  37747. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  37748. */
  37749. gamepadManager: GamepadManager;
  37750. }
  37751. /**
  37752. * Interface representing a free camera inputs manager
  37753. */
  37754. interface FreeCameraInputsManager {
  37755. /**
  37756. * Adds gamepad input support to the FreeCameraInputsManager.
  37757. * @returns the FreeCameraInputsManager
  37758. */
  37759. addGamepad(): FreeCameraInputsManager;
  37760. }
  37761. /**
  37762. * Interface representing an arc rotate camera inputs manager
  37763. */
  37764. interface ArcRotateCameraInputsManager {
  37765. /**
  37766. * Adds gamepad input support to the ArcRotateCamera InputManager.
  37767. * @returns the camera inputs manager
  37768. */
  37769. addGamepad(): ArcRotateCameraInputsManager;
  37770. }
  37771. /**
  37772. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37773. */
  37774. export class GamepadSystemSceneComponent implements ISceneComponent {
  37775. /**
  37776. * The component name helpfull to identify the component in the list of scene components.
  37777. */
  37778. readonly name: string;
  37779. /**
  37780. * The scene the component belongs to.
  37781. */
  37782. scene: Scene;
  37783. /**
  37784. * Creates a new instance of the component for the given scene
  37785. * @param scene Defines the scene to register the component in
  37786. */
  37787. constructor(scene: Scene);
  37788. /**
  37789. * Registers the component in a given scene
  37790. */
  37791. register(): void;
  37792. /**
  37793. * Rebuilds the elements related to this component in case of
  37794. * context lost for instance.
  37795. */
  37796. rebuild(): void;
  37797. /**
  37798. * Disposes the component and the associated ressources
  37799. */
  37800. dispose(): void;
  37801. private _beforeCameraUpdate;
  37802. }
  37803. }
  37804. declare module BABYLON {
  37805. /**
  37806. * 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,
  37807. * which still works and will still be found in many Playgrounds.
  37808. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37809. */
  37810. export class UniversalCamera extends TouchCamera {
  37811. /**
  37812. * Defines the gamepad rotation sensiblity.
  37813. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37814. */
  37815. gamepadAngularSensibility: number;
  37816. /**
  37817. * Defines the gamepad move sensiblity.
  37818. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37819. */
  37820. gamepadMoveSensibility: number;
  37821. /**
  37822. * 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,
  37823. * which still works and will still be found in many Playgrounds.
  37824. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37825. * @param name Define the name of the camera in the scene
  37826. * @param position Define the start position of the camera in the scene
  37827. * @param scene Define the scene the camera belongs to
  37828. */
  37829. constructor(name: string, position: Vector3, scene: Scene);
  37830. /**
  37831. * Gets the current object class name.
  37832. * @return the class name
  37833. */
  37834. getClassName(): string;
  37835. }
  37836. }
  37837. declare module BABYLON {
  37838. /**
  37839. * This represents a FPS type of camera. This is only here for back compat purpose.
  37840. * Please use the UniversalCamera instead as both are identical.
  37841. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37842. */
  37843. export class GamepadCamera extends UniversalCamera {
  37844. /**
  37845. * Instantiates a new Gamepad Camera
  37846. * This represents a FPS type of camera. This is only here for back compat purpose.
  37847. * Please use the UniversalCamera instead as both are identical.
  37848. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37849. * @param name Define the name of the camera in the scene
  37850. * @param position Define the start position of the camera in the scene
  37851. * @param scene Define the scene the camera belongs to
  37852. */
  37853. constructor(name: string, position: Vector3, scene: Scene);
  37854. /**
  37855. * Gets the current object class name.
  37856. * @return the class name
  37857. */
  37858. getClassName(): string;
  37859. }
  37860. }
  37861. declare module BABYLON {
  37862. /** @hidden */
  37863. export var passPixelShader: {
  37864. name: string;
  37865. shader: string;
  37866. };
  37867. }
  37868. declare module BABYLON {
  37869. /** @hidden */
  37870. export var passCubePixelShader: {
  37871. name: string;
  37872. shader: string;
  37873. };
  37874. }
  37875. declare module BABYLON {
  37876. /**
  37877. * PassPostProcess which produces an output the same as it's input
  37878. */
  37879. export class PassPostProcess extends PostProcess {
  37880. /**
  37881. * Creates the PassPostProcess
  37882. * @param name The name of the effect.
  37883. * @param options The required width/height ratio to downsize to before computing the render pass.
  37884. * @param camera The camera to apply the render pass to.
  37885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37886. * @param engine The engine which the post process will be applied. (default: current engine)
  37887. * @param reusable If the post process can be reused on the same frame. (default: false)
  37888. * @param textureType The type of texture to be used when performing the post processing.
  37889. * @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)
  37890. */
  37891. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37892. }
  37893. /**
  37894. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37895. */
  37896. export class PassCubePostProcess extends PostProcess {
  37897. private _face;
  37898. /**
  37899. * Gets or sets the cube face to display.
  37900. * * 0 is +X
  37901. * * 1 is -X
  37902. * * 2 is +Y
  37903. * * 3 is -Y
  37904. * * 4 is +Z
  37905. * * 5 is -Z
  37906. */
  37907. face: number;
  37908. /**
  37909. * Creates the PassCubePostProcess
  37910. * @param name The name of the effect.
  37911. * @param options The required width/height ratio to downsize to before computing the render pass.
  37912. * @param camera The camera to apply the render pass to.
  37913. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37914. * @param engine The engine which the post process will be applied. (default: current engine)
  37915. * @param reusable If the post process can be reused on the same frame. (default: false)
  37916. * @param textureType The type of texture to be used when performing the post processing.
  37917. * @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)
  37918. */
  37919. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37920. }
  37921. }
  37922. declare module BABYLON {
  37923. /** @hidden */
  37924. export var anaglyphPixelShader: {
  37925. name: string;
  37926. shader: string;
  37927. };
  37928. }
  37929. declare module BABYLON {
  37930. /**
  37931. * Postprocess used to generate anaglyphic rendering
  37932. */
  37933. export class AnaglyphPostProcess extends PostProcess {
  37934. private _passedProcess;
  37935. /**
  37936. * Creates a new AnaglyphPostProcess
  37937. * @param name defines postprocess name
  37938. * @param options defines creation options or target ratio scale
  37939. * @param rigCameras defines cameras using this postprocess
  37940. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37941. * @param engine defines hosting engine
  37942. * @param reusable defines if the postprocess will be reused multiple times per frame
  37943. */
  37944. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37945. }
  37946. }
  37947. declare module BABYLON {
  37948. /**
  37949. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37950. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37951. */
  37952. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37953. /**
  37954. * Creates a new AnaglyphArcRotateCamera
  37955. * @param name defines camera name
  37956. * @param alpha defines alpha angle (in radians)
  37957. * @param beta defines beta angle (in radians)
  37958. * @param radius defines radius
  37959. * @param target defines camera target
  37960. * @param interaxialDistance defines distance between each color axis
  37961. * @param scene defines the hosting scene
  37962. */
  37963. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37964. /**
  37965. * Gets camera class name
  37966. * @returns AnaglyphArcRotateCamera
  37967. */
  37968. getClassName(): string;
  37969. }
  37970. }
  37971. declare module BABYLON {
  37972. /**
  37973. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37974. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37975. */
  37976. export class AnaglyphFreeCamera extends FreeCamera {
  37977. /**
  37978. * Creates a new AnaglyphFreeCamera
  37979. * @param name defines camera name
  37980. * @param position defines initial position
  37981. * @param interaxialDistance defines distance between each color axis
  37982. * @param scene defines the hosting scene
  37983. */
  37984. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37985. /**
  37986. * Gets camera class name
  37987. * @returns AnaglyphFreeCamera
  37988. */
  37989. getClassName(): string;
  37990. }
  37991. }
  37992. declare module BABYLON {
  37993. /**
  37994. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37995. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37996. */
  37997. export class AnaglyphGamepadCamera extends GamepadCamera {
  37998. /**
  37999. * Creates a new AnaglyphGamepadCamera
  38000. * @param name defines camera name
  38001. * @param position defines initial position
  38002. * @param interaxialDistance defines distance between each color axis
  38003. * @param scene defines the hosting scene
  38004. */
  38005. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38006. /**
  38007. * Gets camera class name
  38008. * @returns AnaglyphGamepadCamera
  38009. */
  38010. getClassName(): string;
  38011. }
  38012. }
  38013. declare module BABYLON {
  38014. /**
  38015. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38016. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38017. */
  38018. export class AnaglyphUniversalCamera extends UniversalCamera {
  38019. /**
  38020. * Creates a new AnaglyphUniversalCamera
  38021. * @param name defines camera name
  38022. * @param position defines initial position
  38023. * @param interaxialDistance defines distance between each color axis
  38024. * @param scene defines the hosting scene
  38025. */
  38026. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38027. /**
  38028. * Gets camera class name
  38029. * @returns AnaglyphUniversalCamera
  38030. */
  38031. getClassName(): string;
  38032. }
  38033. }
  38034. declare module BABYLON {
  38035. /** @hidden */
  38036. export var stereoscopicInterlacePixelShader: {
  38037. name: string;
  38038. shader: string;
  38039. };
  38040. }
  38041. declare module BABYLON {
  38042. /**
  38043. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38044. */
  38045. export class StereoscopicInterlacePostProcess extends PostProcess {
  38046. private _stepSize;
  38047. private _passedProcess;
  38048. /**
  38049. * Initializes a StereoscopicInterlacePostProcess
  38050. * @param name The name of the effect.
  38051. * @param rigCameras The rig cameras to be appled to the post process
  38052. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38053. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38054. * @param engine The engine which the post process will be applied. (default: current engine)
  38055. * @param reusable If the post process can be reused on the same frame. (default: false)
  38056. */
  38057. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38058. }
  38059. }
  38060. declare module BABYLON {
  38061. /**
  38062. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38063. * @see http://doc.babylonjs.com/features/cameras
  38064. */
  38065. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38066. /**
  38067. * Creates a new StereoscopicArcRotateCamera
  38068. * @param name defines camera name
  38069. * @param alpha defines alpha angle (in radians)
  38070. * @param beta defines beta angle (in radians)
  38071. * @param radius defines radius
  38072. * @param target defines camera target
  38073. * @param interaxialDistance defines distance between each color axis
  38074. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38075. * @param scene defines the hosting scene
  38076. */
  38077. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38078. /**
  38079. * Gets camera class name
  38080. * @returns StereoscopicArcRotateCamera
  38081. */
  38082. getClassName(): string;
  38083. }
  38084. }
  38085. declare module BABYLON {
  38086. /**
  38087. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38088. * @see http://doc.babylonjs.com/features/cameras
  38089. */
  38090. export class StereoscopicFreeCamera extends FreeCamera {
  38091. /**
  38092. * Creates a new StereoscopicFreeCamera
  38093. * @param name defines camera name
  38094. * @param position defines initial position
  38095. * @param interaxialDistance defines distance between each color axis
  38096. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38097. * @param scene defines the hosting scene
  38098. */
  38099. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38100. /**
  38101. * Gets camera class name
  38102. * @returns StereoscopicFreeCamera
  38103. */
  38104. getClassName(): string;
  38105. }
  38106. }
  38107. declare module BABYLON {
  38108. /**
  38109. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38110. * @see http://doc.babylonjs.com/features/cameras
  38111. */
  38112. export class StereoscopicGamepadCamera extends GamepadCamera {
  38113. /**
  38114. * Creates a new StereoscopicGamepadCamera
  38115. * @param name defines camera name
  38116. * @param position defines initial position
  38117. * @param interaxialDistance defines distance between each color axis
  38118. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38119. * @param scene defines the hosting scene
  38120. */
  38121. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38122. /**
  38123. * Gets camera class name
  38124. * @returns StereoscopicGamepadCamera
  38125. */
  38126. getClassName(): string;
  38127. }
  38128. }
  38129. declare module BABYLON {
  38130. /**
  38131. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38132. * @see http://doc.babylonjs.com/features/cameras
  38133. */
  38134. export class StereoscopicUniversalCamera extends UniversalCamera {
  38135. /**
  38136. * Creates a new StereoscopicUniversalCamera
  38137. * @param name defines camera name
  38138. * @param position defines initial position
  38139. * @param interaxialDistance defines distance between each color axis
  38140. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38141. * @param scene defines the hosting scene
  38142. */
  38143. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38144. /**
  38145. * Gets camera class name
  38146. * @returns StereoscopicUniversalCamera
  38147. */
  38148. getClassName(): string;
  38149. }
  38150. }
  38151. declare module BABYLON {
  38152. /**
  38153. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38154. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38155. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38156. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38157. */
  38158. export class VirtualJoysticksCamera extends FreeCamera {
  38159. /**
  38160. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38161. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38162. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38163. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38164. * @param name Define the name of the camera in the scene
  38165. * @param position Define the start position of the camera in the scene
  38166. * @param scene Define the scene the camera belongs to
  38167. */
  38168. constructor(name: string, position: Vector3, scene: Scene);
  38169. /**
  38170. * Gets the current object class name.
  38171. * @return the class name
  38172. */
  38173. getClassName(): string;
  38174. }
  38175. }
  38176. declare module BABYLON {
  38177. /**
  38178. * This represents all the required metrics to create a VR camera.
  38179. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38180. */
  38181. export class VRCameraMetrics {
  38182. /**
  38183. * Define the horizontal resolution off the screen.
  38184. */
  38185. hResolution: number;
  38186. /**
  38187. * Define the vertical resolution off the screen.
  38188. */
  38189. vResolution: number;
  38190. /**
  38191. * Define the horizontal screen size.
  38192. */
  38193. hScreenSize: number;
  38194. /**
  38195. * Define the vertical screen size.
  38196. */
  38197. vScreenSize: number;
  38198. /**
  38199. * Define the vertical screen center position.
  38200. */
  38201. vScreenCenter: number;
  38202. /**
  38203. * Define the distance of the eyes to the screen.
  38204. */
  38205. eyeToScreenDistance: number;
  38206. /**
  38207. * Define the distance between both lenses
  38208. */
  38209. lensSeparationDistance: number;
  38210. /**
  38211. * Define the distance between both viewer's eyes.
  38212. */
  38213. interpupillaryDistance: number;
  38214. /**
  38215. * Define the distortion factor of the VR postprocess.
  38216. * Please, touch with care.
  38217. */
  38218. distortionK: number[];
  38219. /**
  38220. * Define the chromatic aberration correction factors for the VR post process.
  38221. */
  38222. chromaAbCorrection: number[];
  38223. /**
  38224. * Define the scale factor of the post process.
  38225. * The smaller the better but the slower.
  38226. */
  38227. postProcessScaleFactor: number;
  38228. /**
  38229. * Define an offset for the lens center.
  38230. */
  38231. lensCenterOffset: number;
  38232. /**
  38233. * Define if the current vr camera should compensate the distortion of the lense or not.
  38234. */
  38235. compensateDistortion: boolean;
  38236. /**
  38237. * Defines if multiview should be enabled when rendering (Default: false)
  38238. */
  38239. multiviewEnabled: boolean;
  38240. /**
  38241. * Gets the rendering aspect ratio based on the provided resolutions.
  38242. */
  38243. readonly aspectRatio: number;
  38244. /**
  38245. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38246. */
  38247. readonly aspectRatioFov: number;
  38248. /**
  38249. * @hidden
  38250. */
  38251. readonly leftHMatrix: Matrix;
  38252. /**
  38253. * @hidden
  38254. */
  38255. readonly rightHMatrix: Matrix;
  38256. /**
  38257. * @hidden
  38258. */
  38259. readonly leftPreViewMatrix: Matrix;
  38260. /**
  38261. * @hidden
  38262. */
  38263. readonly rightPreViewMatrix: Matrix;
  38264. /**
  38265. * Get the default VRMetrics based on the most generic setup.
  38266. * @returns the default vr metrics
  38267. */
  38268. static GetDefault(): VRCameraMetrics;
  38269. }
  38270. }
  38271. declare module BABYLON {
  38272. /** @hidden */
  38273. export var vrDistortionCorrectionPixelShader: {
  38274. name: string;
  38275. shader: string;
  38276. };
  38277. }
  38278. declare module BABYLON {
  38279. /**
  38280. * VRDistortionCorrectionPostProcess used for mobile VR
  38281. */
  38282. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38283. private _isRightEye;
  38284. private _distortionFactors;
  38285. private _postProcessScaleFactor;
  38286. private _lensCenterOffset;
  38287. private _scaleIn;
  38288. private _scaleFactor;
  38289. private _lensCenter;
  38290. /**
  38291. * Initializes the VRDistortionCorrectionPostProcess
  38292. * @param name The name of the effect.
  38293. * @param camera The camera to apply the render pass to.
  38294. * @param isRightEye If this is for the right eye distortion
  38295. * @param vrMetrics All the required metrics for the VR camera
  38296. */
  38297. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38298. }
  38299. }
  38300. declare module BABYLON {
  38301. /**
  38302. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38303. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38304. */
  38305. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38306. /**
  38307. * Creates a new VRDeviceOrientationArcRotateCamera
  38308. * @param name defines camera name
  38309. * @param alpha defines the camera rotation along the logitudinal axis
  38310. * @param beta defines the camera rotation along the latitudinal axis
  38311. * @param radius defines the camera distance from its target
  38312. * @param target defines the camera target
  38313. * @param scene defines the scene the camera belongs to
  38314. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38315. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38316. */
  38317. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38318. /**
  38319. * Gets camera class name
  38320. * @returns VRDeviceOrientationArcRotateCamera
  38321. */
  38322. getClassName(): string;
  38323. }
  38324. }
  38325. declare module BABYLON {
  38326. /**
  38327. * Camera used to simulate VR rendering (based on FreeCamera)
  38328. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38329. */
  38330. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38331. /**
  38332. * Creates a new VRDeviceOrientationFreeCamera
  38333. * @param name defines camera name
  38334. * @param position defines the start position of the camera
  38335. * @param scene defines the scene the camera belongs to
  38336. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38337. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38338. */
  38339. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38340. /**
  38341. * Gets camera class name
  38342. * @returns VRDeviceOrientationFreeCamera
  38343. */
  38344. getClassName(): string;
  38345. }
  38346. }
  38347. declare module BABYLON {
  38348. /**
  38349. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38350. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38351. */
  38352. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38353. /**
  38354. * Creates a new VRDeviceOrientationGamepadCamera
  38355. * @param name defines camera name
  38356. * @param position defines the start position of the camera
  38357. * @param scene defines the scene the camera belongs to
  38358. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38359. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38360. */
  38361. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38362. /**
  38363. * Gets camera class name
  38364. * @returns VRDeviceOrientationGamepadCamera
  38365. */
  38366. getClassName(): string;
  38367. }
  38368. }
  38369. declare module BABYLON {
  38370. /**
  38371. * Base class of materials working in push mode in babylon JS
  38372. * @hidden
  38373. */
  38374. export class PushMaterial extends Material {
  38375. protected _activeEffect: Effect;
  38376. protected _normalMatrix: Matrix;
  38377. /**
  38378. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38379. * This means that the material can keep using a previous shader while a new one is being compiled.
  38380. * This is mostly used when shader parallel compilation is supported (true by default)
  38381. */
  38382. allowShaderHotSwapping: boolean;
  38383. constructor(name: string, scene: Scene);
  38384. getEffect(): Effect;
  38385. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38386. /**
  38387. * Binds the given world matrix to the active effect
  38388. *
  38389. * @param world the matrix to bind
  38390. */
  38391. bindOnlyWorldMatrix(world: Matrix): void;
  38392. /**
  38393. * Binds the given normal matrix to the active effect
  38394. *
  38395. * @param normalMatrix the matrix to bind
  38396. */
  38397. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38398. bind(world: Matrix, mesh?: Mesh): void;
  38399. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38400. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38401. }
  38402. }
  38403. declare module BABYLON {
  38404. /**
  38405. * This groups all the flags used to control the materials channel.
  38406. */
  38407. export class MaterialFlags {
  38408. private static _DiffuseTextureEnabled;
  38409. /**
  38410. * Are diffuse textures enabled in the application.
  38411. */
  38412. static DiffuseTextureEnabled: boolean;
  38413. private static _AmbientTextureEnabled;
  38414. /**
  38415. * Are ambient textures enabled in the application.
  38416. */
  38417. static AmbientTextureEnabled: boolean;
  38418. private static _OpacityTextureEnabled;
  38419. /**
  38420. * Are opacity textures enabled in the application.
  38421. */
  38422. static OpacityTextureEnabled: boolean;
  38423. private static _ReflectionTextureEnabled;
  38424. /**
  38425. * Are reflection textures enabled in the application.
  38426. */
  38427. static ReflectionTextureEnabled: boolean;
  38428. private static _EmissiveTextureEnabled;
  38429. /**
  38430. * Are emissive textures enabled in the application.
  38431. */
  38432. static EmissiveTextureEnabled: boolean;
  38433. private static _SpecularTextureEnabled;
  38434. /**
  38435. * Are specular textures enabled in the application.
  38436. */
  38437. static SpecularTextureEnabled: boolean;
  38438. private static _BumpTextureEnabled;
  38439. /**
  38440. * Are bump textures enabled in the application.
  38441. */
  38442. static BumpTextureEnabled: boolean;
  38443. private static _LightmapTextureEnabled;
  38444. /**
  38445. * Are lightmap textures enabled in the application.
  38446. */
  38447. static LightmapTextureEnabled: boolean;
  38448. private static _RefractionTextureEnabled;
  38449. /**
  38450. * Are refraction textures enabled in the application.
  38451. */
  38452. static RefractionTextureEnabled: boolean;
  38453. private static _ColorGradingTextureEnabled;
  38454. /**
  38455. * Are color grading textures enabled in the application.
  38456. */
  38457. static ColorGradingTextureEnabled: boolean;
  38458. private static _FresnelEnabled;
  38459. /**
  38460. * Are fresnels enabled in the application.
  38461. */
  38462. static FresnelEnabled: boolean;
  38463. private static _ClearCoatTextureEnabled;
  38464. /**
  38465. * Are clear coat textures enabled in the application.
  38466. */
  38467. static ClearCoatTextureEnabled: boolean;
  38468. private static _ClearCoatBumpTextureEnabled;
  38469. /**
  38470. * Are clear coat bump textures enabled in the application.
  38471. */
  38472. static ClearCoatBumpTextureEnabled: boolean;
  38473. private static _ClearCoatTintTextureEnabled;
  38474. /**
  38475. * Are clear coat tint textures enabled in the application.
  38476. */
  38477. static ClearCoatTintTextureEnabled: boolean;
  38478. private static _SheenTextureEnabled;
  38479. /**
  38480. * Are sheen textures enabled in the application.
  38481. */
  38482. static SheenTextureEnabled: boolean;
  38483. private static _AnisotropicTextureEnabled;
  38484. /**
  38485. * Are anisotropic textures enabled in the application.
  38486. */
  38487. static AnisotropicTextureEnabled: boolean;
  38488. private static _ThicknessTextureEnabled;
  38489. /**
  38490. * Are thickness textures enabled in the application.
  38491. */
  38492. static ThicknessTextureEnabled: boolean;
  38493. }
  38494. }
  38495. declare module BABYLON {
  38496. /** @hidden */
  38497. export var defaultFragmentDeclaration: {
  38498. name: string;
  38499. shader: string;
  38500. };
  38501. }
  38502. declare module BABYLON {
  38503. /** @hidden */
  38504. export var defaultUboDeclaration: {
  38505. name: string;
  38506. shader: string;
  38507. };
  38508. }
  38509. declare module BABYLON {
  38510. /** @hidden */
  38511. export var lightFragmentDeclaration: {
  38512. name: string;
  38513. shader: string;
  38514. };
  38515. }
  38516. declare module BABYLON {
  38517. /** @hidden */
  38518. export var lightUboDeclaration: {
  38519. name: string;
  38520. shader: string;
  38521. };
  38522. }
  38523. declare module BABYLON {
  38524. /** @hidden */
  38525. export var lightsFragmentFunctions: {
  38526. name: string;
  38527. shader: string;
  38528. };
  38529. }
  38530. declare module BABYLON {
  38531. /** @hidden */
  38532. export var shadowsFragmentFunctions: {
  38533. name: string;
  38534. shader: string;
  38535. };
  38536. }
  38537. declare module BABYLON {
  38538. /** @hidden */
  38539. export var fresnelFunction: {
  38540. name: string;
  38541. shader: string;
  38542. };
  38543. }
  38544. declare module BABYLON {
  38545. /** @hidden */
  38546. export var reflectionFunction: {
  38547. name: string;
  38548. shader: string;
  38549. };
  38550. }
  38551. declare module BABYLON {
  38552. /** @hidden */
  38553. export var bumpFragmentFunctions: {
  38554. name: string;
  38555. shader: string;
  38556. };
  38557. }
  38558. declare module BABYLON {
  38559. /** @hidden */
  38560. export var logDepthDeclaration: {
  38561. name: string;
  38562. shader: string;
  38563. };
  38564. }
  38565. declare module BABYLON {
  38566. /** @hidden */
  38567. export var bumpFragment: {
  38568. name: string;
  38569. shader: string;
  38570. };
  38571. }
  38572. declare module BABYLON {
  38573. /** @hidden */
  38574. export var depthPrePass: {
  38575. name: string;
  38576. shader: string;
  38577. };
  38578. }
  38579. declare module BABYLON {
  38580. /** @hidden */
  38581. export var lightFragment: {
  38582. name: string;
  38583. shader: string;
  38584. };
  38585. }
  38586. declare module BABYLON {
  38587. /** @hidden */
  38588. export var logDepthFragment: {
  38589. name: string;
  38590. shader: string;
  38591. };
  38592. }
  38593. declare module BABYLON {
  38594. /** @hidden */
  38595. export var defaultPixelShader: {
  38596. name: string;
  38597. shader: string;
  38598. };
  38599. }
  38600. declare module BABYLON {
  38601. /** @hidden */
  38602. export var defaultVertexDeclaration: {
  38603. name: string;
  38604. shader: string;
  38605. };
  38606. }
  38607. declare module BABYLON {
  38608. /** @hidden */
  38609. export var bumpVertexDeclaration: {
  38610. name: string;
  38611. shader: string;
  38612. };
  38613. }
  38614. declare module BABYLON {
  38615. /** @hidden */
  38616. export var bumpVertex: {
  38617. name: string;
  38618. shader: string;
  38619. };
  38620. }
  38621. declare module BABYLON {
  38622. /** @hidden */
  38623. export var fogVertex: {
  38624. name: string;
  38625. shader: string;
  38626. };
  38627. }
  38628. declare module BABYLON {
  38629. /** @hidden */
  38630. export var shadowsVertex: {
  38631. name: string;
  38632. shader: string;
  38633. };
  38634. }
  38635. declare module BABYLON {
  38636. /** @hidden */
  38637. export var pointCloudVertex: {
  38638. name: string;
  38639. shader: string;
  38640. };
  38641. }
  38642. declare module BABYLON {
  38643. /** @hidden */
  38644. export var logDepthVertex: {
  38645. name: string;
  38646. shader: string;
  38647. };
  38648. }
  38649. declare module BABYLON {
  38650. /** @hidden */
  38651. export var defaultVertexShader: {
  38652. name: string;
  38653. shader: string;
  38654. };
  38655. }
  38656. declare module BABYLON {
  38657. /** @hidden */
  38658. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38659. MAINUV1: boolean;
  38660. MAINUV2: boolean;
  38661. DIFFUSE: boolean;
  38662. DIFFUSEDIRECTUV: number;
  38663. AMBIENT: boolean;
  38664. AMBIENTDIRECTUV: number;
  38665. OPACITY: boolean;
  38666. OPACITYDIRECTUV: number;
  38667. OPACITYRGB: boolean;
  38668. REFLECTION: boolean;
  38669. EMISSIVE: boolean;
  38670. EMISSIVEDIRECTUV: number;
  38671. SPECULAR: boolean;
  38672. SPECULARDIRECTUV: number;
  38673. BUMP: boolean;
  38674. BUMPDIRECTUV: number;
  38675. PARALLAX: boolean;
  38676. PARALLAXOCCLUSION: boolean;
  38677. SPECULAROVERALPHA: boolean;
  38678. CLIPPLANE: boolean;
  38679. CLIPPLANE2: boolean;
  38680. CLIPPLANE3: boolean;
  38681. CLIPPLANE4: boolean;
  38682. ALPHATEST: boolean;
  38683. DEPTHPREPASS: boolean;
  38684. ALPHAFROMDIFFUSE: boolean;
  38685. POINTSIZE: boolean;
  38686. FOG: boolean;
  38687. SPECULARTERM: boolean;
  38688. DIFFUSEFRESNEL: boolean;
  38689. OPACITYFRESNEL: boolean;
  38690. REFLECTIONFRESNEL: boolean;
  38691. REFRACTIONFRESNEL: boolean;
  38692. EMISSIVEFRESNEL: boolean;
  38693. FRESNEL: boolean;
  38694. NORMAL: boolean;
  38695. UV1: boolean;
  38696. UV2: boolean;
  38697. VERTEXCOLOR: boolean;
  38698. VERTEXALPHA: boolean;
  38699. NUM_BONE_INFLUENCERS: number;
  38700. BonesPerMesh: number;
  38701. BONETEXTURE: boolean;
  38702. INSTANCES: boolean;
  38703. GLOSSINESS: boolean;
  38704. ROUGHNESS: boolean;
  38705. EMISSIVEASILLUMINATION: boolean;
  38706. LINKEMISSIVEWITHDIFFUSE: boolean;
  38707. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38708. LIGHTMAP: boolean;
  38709. LIGHTMAPDIRECTUV: number;
  38710. OBJECTSPACE_NORMALMAP: boolean;
  38711. USELIGHTMAPASSHADOWMAP: boolean;
  38712. REFLECTIONMAP_3D: boolean;
  38713. REFLECTIONMAP_SPHERICAL: boolean;
  38714. REFLECTIONMAP_PLANAR: boolean;
  38715. REFLECTIONMAP_CUBIC: boolean;
  38716. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38717. REFLECTIONMAP_PROJECTION: boolean;
  38718. REFLECTIONMAP_SKYBOX: boolean;
  38719. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38720. REFLECTIONMAP_EXPLICIT: boolean;
  38721. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38722. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38723. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38724. INVERTCUBICMAP: boolean;
  38725. LOGARITHMICDEPTH: boolean;
  38726. REFRACTION: boolean;
  38727. REFRACTIONMAP_3D: boolean;
  38728. REFLECTIONOVERALPHA: boolean;
  38729. TWOSIDEDLIGHTING: boolean;
  38730. SHADOWFLOAT: boolean;
  38731. MORPHTARGETS: boolean;
  38732. MORPHTARGETS_NORMAL: boolean;
  38733. MORPHTARGETS_TANGENT: boolean;
  38734. NUM_MORPH_INFLUENCERS: number;
  38735. NONUNIFORMSCALING: boolean;
  38736. PREMULTIPLYALPHA: boolean;
  38737. IMAGEPROCESSING: boolean;
  38738. VIGNETTE: boolean;
  38739. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38740. VIGNETTEBLENDMODEOPAQUE: boolean;
  38741. TONEMAPPING: boolean;
  38742. TONEMAPPING_ACES: boolean;
  38743. CONTRAST: boolean;
  38744. COLORCURVES: boolean;
  38745. COLORGRADING: boolean;
  38746. COLORGRADING3D: boolean;
  38747. SAMPLER3DGREENDEPTH: boolean;
  38748. SAMPLER3DBGRMAP: boolean;
  38749. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38750. MULTIVIEW: boolean;
  38751. /**
  38752. * If the reflection texture on this material is in linear color space
  38753. * @hidden
  38754. */
  38755. IS_REFLECTION_LINEAR: boolean;
  38756. /**
  38757. * If the refraction texture on this material is in linear color space
  38758. * @hidden
  38759. */
  38760. IS_REFRACTION_LINEAR: boolean;
  38761. EXPOSURE: boolean;
  38762. constructor();
  38763. setReflectionMode(modeToEnable: string): void;
  38764. }
  38765. /**
  38766. * This is the default material used in Babylon. It is the best trade off between quality
  38767. * and performances.
  38768. * @see http://doc.babylonjs.com/babylon101/materials
  38769. */
  38770. export class StandardMaterial extends PushMaterial {
  38771. private _diffuseTexture;
  38772. /**
  38773. * The basic texture of the material as viewed under a light.
  38774. */
  38775. diffuseTexture: Nullable<BaseTexture>;
  38776. private _ambientTexture;
  38777. /**
  38778. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38779. */
  38780. ambientTexture: Nullable<BaseTexture>;
  38781. private _opacityTexture;
  38782. /**
  38783. * Define the transparency of the material from a texture.
  38784. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38785. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38786. */
  38787. opacityTexture: Nullable<BaseTexture>;
  38788. private _reflectionTexture;
  38789. /**
  38790. * Define the texture used to display the reflection.
  38791. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38792. */
  38793. reflectionTexture: Nullable<BaseTexture>;
  38794. private _emissiveTexture;
  38795. /**
  38796. * Define texture of the material as if self lit.
  38797. * This will be mixed in the final result even in the absence of light.
  38798. */
  38799. emissiveTexture: Nullable<BaseTexture>;
  38800. private _specularTexture;
  38801. /**
  38802. * Define how the color and intensity of the highlight given by the light in the material.
  38803. */
  38804. specularTexture: Nullable<BaseTexture>;
  38805. private _bumpTexture;
  38806. /**
  38807. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38808. * 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.
  38809. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38810. */
  38811. bumpTexture: Nullable<BaseTexture>;
  38812. private _lightmapTexture;
  38813. /**
  38814. * Complex lighting can be computationally expensive to compute at runtime.
  38815. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38816. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38817. */
  38818. lightmapTexture: Nullable<BaseTexture>;
  38819. private _refractionTexture;
  38820. /**
  38821. * Define the texture used to display the refraction.
  38822. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38823. */
  38824. refractionTexture: Nullable<BaseTexture>;
  38825. /**
  38826. * The color of the material lit by the environmental background lighting.
  38827. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38828. */
  38829. ambientColor: Color3;
  38830. /**
  38831. * The basic color of the material as viewed under a light.
  38832. */
  38833. diffuseColor: Color3;
  38834. /**
  38835. * Define how the color and intensity of the highlight given by the light in the material.
  38836. */
  38837. specularColor: Color3;
  38838. /**
  38839. * Define the color of the material as if self lit.
  38840. * This will be mixed in the final result even in the absence of light.
  38841. */
  38842. emissiveColor: Color3;
  38843. /**
  38844. * Defines how sharp are the highlights in the material.
  38845. * The bigger the value the sharper giving a more glossy feeling to the result.
  38846. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38847. */
  38848. specularPower: number;
  38849. private _useAlphaFromDiffuseTexture;
  38850. /**
  38851. * Does the transparency come from the diffuse texture alpha channel.
  38852. */
  38853. useAlphaFromDiffuseTexture: boolean;
  38854. private _useEmissiveAsIllumination;
  38855. /**
  38856. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38857. */
  38858. useEmissiveAsIllumination: boolean;
  38859. private _linkEmissiveWithDiffuse;
  38860. /**
  38861. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38862. * the emissive level when the final color is close to one.
  38863. */
  38864. linkEmissiveWithDiffuse: boolean;
  38865. private _useSpecularOverAlpha;
  38866. /**
  38867. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38868. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38869. */
  38870. useSpecularOverAlpha: boolean;
  38871. private _useReflectionOverAlpha;
  38872. /**
  38873. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38874. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38875. */
  38876. useReflectionOverAlpha: boolean;
  38877. private _disableLighting;
  38878. /**
  38879. * Does lights from the scene impacts this material.
  38880. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38881. */
  38882. disableLighting: boolean;
  38883. private _useObjectSpaceNormalMap;
  38884. /**
  38885. * Allows using an object space normal map (instead of tangent space).
  38886. */
  38887. useObjectSpaceNormalMap: boolean;
  38888. private _useParallax;
  38889. /**
  38890. * Is parallax enabled or not.
  38891. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38892. */
  38893. useParallax: boolean;
  38894. private _useParallaxOcclusion;
  38895. /**
  38896. * Is parallax occlusion enabled or not.
  38897. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38898. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38899. */
  38900. useParallaxOcclusion: boolean;
  38901. /**
  38902. * 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.
  38903. */
  38904. parallaxScaleBias: number;
  38905. private _roughness;
  38906. /**
  38907. * Helps to define how blurry the reflections should appears in the material.
  38908. */
  38909. roughness: number;
  38910. /**
  38911. * In case of refraction, define the value of the indice of refraction.
  38912. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38913. */
  38914. indexOfRefraction: number;
  38915. /**
  38916. * Invert the refraction texture alongside the y axis.
  38917. * It can be useful with procedural textures or probe for instance.
  38918. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38919. */
  38920. invertRefractionY: boolean;
  38921. /**
  38922. * Defines the alpha limits in alpha test mode.
  38923. */
  38924. alphaCutOff: number;
  38925. private _useLightmapAsShadowmap;
  38926. /**
  38927. * In case of light mapping, define whether the map contains light or shadow informations.
  38928. */
  38929. useLightmapAsShadowmap: boolean;
  38930. private _diffuseFresnelParameters;
  38931. /**
  38932. * Define the diffuse fresnel parameters of the material.
  38933. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38934. */
  38935. diffuseFresnelParameters: FresnelParameters;
  38936. private _opacityFresnelParameters;
  38937. /**
  38938. * Define the opacity fresnel parameters of the material.
  38939. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38940. */
  38941. opacityFresnelParameters: FresnelParameters;
  38942. private _reflectionFresnelParameters;
  38943. /**
  38944. * Define the reflection fresnel parameters of the material.
  38945. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38946. */
  38947. reflectionFresnelParameters: FresnelParameters;
  38948. private _refractionFresnelParameters;
  38949. /**
  38950. * Define the refraction fresnel parameters of the material.
  38951. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38952. */
  38953. refractionFresnelParameters: FresnelParameters;
  38954. private _emissiveFresnelParameters;
  38955. /**
  38956. * Define the emissive fresnel parameters of the material.
  38957. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38958. */
  38959. emissiveFresnelParameters: FresnelParameters;
  38960. private _useReflectionFresnelFromSpecular;
  38961. /**
  38962. * If true automatically deducts the fresnels values from the material specularity.
  38963. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38964. */
  38965. useReflectionFresnelFromSpecular: boolean;
  38966. private _useGlossinessFromSpecularMapAlpha;
  38967. /**
  38968. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38969. */
  38970. useGlossinessFromSpecularMapAlpha: boolean;
  38971. private _maxSimultaneousLights;
  38972. /**
  38973. * Defines the maximum number of lights that can be used in the material
  38974. */
  38975. maxSimultaneousLights: number;
  38976. private _invertNormalMapX;
  38977. /**
  38978. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38979. */
  38980. invertNormalMapX: boolean;
  38981. private _invertNormalMapY;
  38982. /**
  38983. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38984. */
  38985. invertNormalMapY: boolean;
  38986. private _twoSidedLighting;
  38987. /**
  38988. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38989. */
  38990. twoSidedLighting: boolean;
  38991. /**
  38992. * Default configuration related to image processing available in the standard Material.
  38993. */
  38994. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38995. /**
  38996. * Gets the image processing configuration used either in this material.
  38997. */
  38998. /**
  38999. * Sets the Default image processing configuration used either in the this material.
  39000. *
  39001. * If sets to null, the scene one is in use.
  39002. */
  39003. imageProcessingConfiguration: ImageProcessingConfiguration;
  39004. /**
  39005. * Keep track of the image processing observer to allow dispose and replace.
  39006. */
  39007. private _imageProcessingObserver;
  39008. /**
  39009. * Attaches a new image processing configuration to the Standard Material.
  39010. * @param configuration
  39011. */
  39012. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39013. /**
  39014. * Gets wether the color curves effect is enabled.
  39015. */
  39016. /**
  39017. * Sets wether the color curves effect is enabled.
  39018. */
  39019. cameraColorCurvesEnabled: boolean;
  39020. /**
  39021. * Gets wether the color grading effect is enabled.
  39022. */
  39023. /**
  39024. * Gets wether the color grading effect is enabled.
  39025. */
  39026. cameraColorGradingEnabled: boolean;
  39027. /**
  39028. * Gets wether tonemapping is enabled or not.
  39029. */
  39030. /**
  39031. * Sets wether tonemapping is enabled or not
  39032. */
  39033. cameraToneMappingEnabled: boolean;
  39034. /**
  39035. * The camera exposure used on this material.
  39036. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39037. * This corresponds to a photographic exposure.
  39038. */
  39039. /**
  39040. * The camera exposure used on this material.
  39041. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39042. * This corresponds to a photographic exposure.
  39043. */
  39044. cameraExposure: number;
  39045. /**
  39046. * Gets The camera contrast used on this material.
  39047. */
  39048. /**
  39049. * Sets The camera contrast used on this material.
  39050. */
  39051. cameraContrast: number;
  39052. /**
  39053. * Gets the Color Grading 2D Lookup Texture.
  39054. */
  39055. /**
  39056. * Sets the Color Grading 2D Lookup Texture.
  39057. */
  39058. cameraColorGradingTexture: Nullable<BaseTexture>;
  39059. /**
  39060. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39061. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39062. * 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;
  39063. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39064. */
  39065. /**
  39066. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39067. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39068. * 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;
  39069. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39070. */
  39071. cameraColorCurves: Nullable<ColorCurves>;
  39072. /**
  39073. * Custom callback helping to override the default shader used in the material.
  39074. */
  39075. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39076. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39077. protected _worldViewProjectionMatrix: Matrix;
  39078. protected _globalAmbientColor: Color3;
  39079. protected _useLogarithmicDepth: boolean;
  39080. /**
  39081. * Instantiates a new standard material.
  39082. * This is the default material used in Babylon. It is the best trade off between quality
  39083. * and performances.
  39084. * @see http://doc.babylonjs.com/babylon101/materials
  39085. * @param name Define the name of the material in the scene
  39086. * @param scene Define the scene the material belong to
  39087. */
  39088. constructor(name: string, scene: Scene);
  39089. /**
  39090. * Gets a boolean indicating that current material needs to register RTT
  39091. */
  39092. readonly hasRenderTargetTextures: boolean;
  39093. /**
  39094. * Gets the current class name of the material e.g. "StandardMaterial"
  39095. * Mainly use in serialization.
  39096. * @returns the class name
  39097. */
  39098. getClassName(): string;
  39099. /**
  39100. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39101. * You can try switching to logarithmic depth.
  39102. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39103. */
  39104. useLogarithmicDepth: boolean;
  39105. /**
  39106. * Specifies if the material will require alpha blending
  39107. * @returns a boolean specifying if alpha blending is needed
  39108. */
  39109. needAlphaBlending(): boolean;
  39110. /**
  39111. * Specifies if this material should be rendered in alpha test mode
  39112. * @returns a boolean specifying if an alpha test is needed.
  39113. */
  39114. needAlphaTesting(): boolean;
  39115. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39116. /**
  39117. * Get the texture used for alpha test purpose.
  39118. * @returns the diffuse texture in case of the standard material.
  39119. */
  39120. getAlphaTestTexture(): Nullable<BaseTexture>;
  39121. /**
  39122. * Get if the submesh is ready to be used and all its information available.
  39123. * Child classes can use it to update shaders
  39124. * @param mesh defines the mesh to check
  39125. * @param subMesh defines which submesh to check
  39126. * @param useInstances specifies that instances should be used
  39127. * @returns a boolean indicating that the submesh is ready or not
  39128. */
  39129. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39130. /**
  39131. * Builds the material UBO layouts.
  39132. * Used internally during the effect preparation.
  39133. */
  39134. buildUniformLayout(): void;
  39135. /**
  39136. * Unbinds the material from the mesh
  39137. */
  39138. unbind(): void;
  39139. /**
  39140. * Binds the submesh to this material by preparing the effect and shader to draw
  39141. * @param world defines the world transformation matrix
  39142. * @param mesh defines the mesh containing the submesh
  39143. * @param subMesh defines the submesh to bind the material to
  39144. */
  39145. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39146. /**
  39147. * Get the list of animatables in the material.
  39148. * @returns the list of animatables object used in the material
  39149. */
  39150. getAnimatables(): IAnimatable[];
  39151. /**
  39152. * Gets the active textures from the material
  39153. * @returns an array of textures
  39154. */
  39155. getActiveTextures(): BaseTexture[];
  39156. /**
  39157. * Specifies if the material uses a texture
  39158. * @param texture defines the texture to check against the material
  39159. * @returns a boolean specifying if the material uses the texture
  39160. */
  39161. hasTexture(texture: BaseTexture): boolean;
  39162. /**
  39163. * Disposes the material
  39164. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39165. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39166. */
  39167. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39168. /**
  39169. * Makes a duplicate of the material, and gives it a new name
  39170. * @param name defines the new name for the duplicated material
  39171. * @returns the cloned material
  39172. */
  39173. clone(name: string): StandardMaterial;
  39174. /**
  39175. * Serializes this material in a JSON representation
  39176. * @returns the serialized material object
  39177. */
  39178. serialize(): any;
  39179. /**
  39180. * Creates a standard material from parsed material data
  39181. * @param source defines the JSON representation of the material
  39182. * @param scene defines the hosting scene
  39183. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39184. * @returns a new standard material
  39185. */
  39186. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39187. /**
  39188. * Are diffuse textures enabled in the application.
  39189. */
  39190. static DiffuseTextureEnabled: boolean;
  39191. /**
  39192. * Are ambient textures enabled in the application.
  39193. */
  39194. static AmbientTextureEnabled: boolean;
  39195. /**
  39196. * Are opacity textures enabled in the application.
  39197. */
  39198. static OpacityTextureEnabled: boolean;
  39199. /**
  39200. * Are reflection textures enabled in the application.
  39201. */
  39202. static ReflectionTextureEnabled: boolean;
  39203. /**
  39204. * Are emissive textures enabled in the application.
  39205. */
  39206. static EmissiveTextureEnabled: boolean;
  39207. /**
  39208. * Are specular textures enabled in the application.
  39209. */
  39210. static SpecularTextureEnabled: boolean;
  39211. /**
  39212. * Are bump textures enabled in the application.
  39213. */
  39214. static BumpTextureEnabled: boolean;
  39215. /**
  39216. * Are lightmap textures enabled in the application.
  39217. */
  39218. static LightmapTextureEnabled: boolean;
  39219. /**
  39220. * Are refraction textures enabled in the application.
  39221. */
  39222. static RefractionTextureEnabled: boolean;
  39223. /**
  39224. * Are color grading textures enabled in the application.
  39225. */
  39226. static ColorGradingTextureEnabled: boolean;
  39227. /**
  39228. * Are fresnels enabled in the application.
  39229. */
  39230. static FresnelEnabled: boolean;
  39231. }
  39232. }
  39233. declare module BABYLON {
  39234. /**
  39235. * A class extending Texture allowing drawing on a texture
  39236. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39237. */
  39238. export class DynamicTexture extends Texture {
  39239. private _generateMipMaps;
  39240. private _canvas;
  39241. private _context;
  39242. private _engine;
  39243. /**
  39244. * Creates a DynamicTexture
  39245. * @param name defines the name of the texture
  39246. * @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
  39247. * @param scene defines the scene where you want the texture
  39248. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39249. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39250. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39251. */
  39252. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39253. /**
  39254. * Get the current class name of the texture useful for serialization or dynamic coding.
  39255. * @returns "DynamicTexture"
  39256. */
  39257. getClassName(): string;
  39258. /**
  39259. * Gets the current state of canRescale
  39260. */
  39261. readonly canRescale: boolean;
  39262. private _recreate;
  39263. /**
  39264. * Scales the texture
  39265. * @param ratio the scale factor to apply to both width and height
  39266. */
  39267. scale(ratio: number): void;
  39268. /**
  39269. * Resizes the texture
  39270. * @param width the new width
  39271. * @param height the new height
  39272. */
  39273. scaleTo(width: number, height: number): void;
  39274. /**
  39275. * Gets the context of the canvas used by the texture
  39276. * @returns the canvas context of the dynamic texture
  39277. */
  39278. getContext(): CanvasRenderingContext2D;
  39279. /**
  39280. * Clears the texture
  39281. */
  39282. clear(): void;
  39283. /**
  39284. * Updates the texture
  39285. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39286. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39287. */
  39288. update(invertY?: boolean, premulAlpha?: boolean): void;
  39289. /**
  39290. * Draws text onto the texture
  39291. * @param text defines the text to be drawn
  39292. * @param x defines the placement of the text from the left
  39293. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39294. * @param font defines the font to be used with font-style, font-size, font-name
  39295. * @param color defines the color used for the text
  39296. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39297. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39298. * @param update defines whether texture is immediately update (default is true)
  39299. */
  39300. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39301. /**
  39302. * Clones the texture
  39303. * @returns the clone of the texture.
  39304. */
  39305. clone(): DynamicTexture;
  39306. /**
  39307. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39308. * @returns a serialized dynamic texture object
  39309. */
  39310. serialize(): any;
  39311. /** @hidden */
  39312. _rebuild(): void;
  39313. }
  39314. }
  39315. declare module BABYLON {
  39316. /** @hidden */
  39317. export var imageProcessingPixelShader: {
  39318. name: string;
  39319. shader: string;
  39320. };
  39321. }
  39322. declare module BABYLON {
  39323. /**
  39324. * ImageProcessingPostProcess
  39325. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39326. */
  39327. export class ImageProcessingPostProcess extends PostProcess {
  39328. /**
  39329. * Default configuration related to image processing available in the PBR Material.
  39330. */
  39331. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39332. /**
  39333. * Gets the image processing configuration used either in this material.
  39334. */
  39335. /**
  39336. * Sets the Default image processing configuration used either in the this material.
  39337. *
  39338. * If sets to null, the scene one is in use.
  39339. */
  39340. imageProcessingConfiguration: ImageProcessingConfiguration;
  39341. /**
  39342. * Keep track of the image processing observer to allow dispose and replace.
  39343. */
  39344. private _imageProcessingObserver;
  39345. /**
  39346. * Attaches a new image processing configuration to the PBR Material.
  39347. * @param configuration
  39348. */
  39349. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39350. /**
  39351. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39352. */
  39353. /**
  39354. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39355. */
  39356. colorCurves: Nullable<ColorCurves>;
  39357. /**
  39358. * Gets wether the color curves effect is enabled.
  39359. */
  39360. /**
  39361. * Sets wether the color curves effect is enabled.
  39362. */
  39363. colorCurvesEnabled: boolean;
  39364. /**
  39365. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39366. */
  39367. /**
  39368. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39369. */
  39370. colorGradingTexture: Nullable<BaseTexture>;
  39371. /**
  39372. * Gets wether the color grading effect is enabled.
  39373. */
  39374. /**
  39375. * Gets wether the color grading effect is enabled.
  39376. */
  39377. colorGradingEnabled: boolean;
  39378. /**
  39379. * Gets exposure used in the effect.
  39380. */
  39381. /**
  39382. * Sets exposure used in the effect.
  39383. */
  39384. exposure: number;
  39385. /**
  39386. * Gets wether tonemapping is enabled or not.
  39387. */
  39388. /**
  39389. * Sets wether tonemapping is enabled or not
  39390. */
  39391. toneMappingEnabled: boolean;
  39392. /**
  39393. * Gets the type of tone mapping effect.
  39394. */
  39395. /**
  39396. * Sets the type of tone mapping effect.
  39397. */
  39398. toneMappingType: number;
  39399. /**
  39400. * Gets contrast used in the effect.
  39401. */
  39402. /**
  39403. * Sets contrast used in the effect.
  39404. */
  39405. contrast: number;
  39406. /**
  39407. * Gets Vignette stretch size.
  39408. */
  39409. /**
  39410. * Sets Vignette stretch size.
  39411. */
  39412. vignetteStretch: number;
  39413. /**
  39414. * Gets Vignette centre X Offset.
  39415. */
  39416. /**
  39417. * Sets Vignette centre X Offset.
  39418. */
  39419. vignetteCentreX: number;
  39420. /**
  39421. * Gets Vignette centre Y Offset.
  39422. */
  39423. /**
  39424. * Sets Vignette centre Y Offset.
  39425. */
  39426. vignetteCentreY: number;
  39427. /**
  39428. * Gets Vignette weight or intensity of the vignette effect.
  39429. */
  39430. /**
  39431. * Sets Vignette weight or intensity of the vignette effect.
  39432. */
  39433. vignetteWeight: number;
  39434. /**
  39435. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39436. * if vignetteEnabled is set to true.
  39437. */
  39438. /**
  39439. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39440. * if vignetteEnabled is set to true.
  39441. */
  39442. vignetteColor: Color4;
  39443. /**
  39444. * Gets Camera field of view used by the Vignette effect.
  39445. */
  39446. /**
  39447. * Sets Camera field of view used by the Vignette effect.
  39448. */
  39449. vignetteCameraFov: number;
  39450. /**
  39451. * Gets the vignette blend mode allowing different kind of effect.
  39452. */
  39453. /**
  39454. * Sets the vignette blend mode allowing different kind of effect.
  39455. */
  39456. vignetteBlendMode: number;
  39457. /**
  39458. * Gets wether the vignette effect is enabled.
  39459. */
  39460. /**
  39461. * Sets wether the vignette effect is enabled.
  39462. */
  39463. vignetteEnabled: boolean;
  39464. private _fromLinearSpace;
  39465. /**
  39466. * Gets wether the input of the processing is in Gamma or Linear Space.
  39467. */
  39468. /**
  39469. * Sets wether the input of the processing is in Gamma or Linear Space.
  39470. */
  39471. fromLinearSpace: boolean;
  39472. /**
  39473. * Defines cache preventing GC.
  39474. */
  39475. private _defines;
  39476. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39477. /**
  39478. * "ImageProcessingPostProcess"
  39479. * @returns "ImageProcessingPostProcess"
  39480. */
  39481. getClassName(): string;
  39482. protected _updateParameters(): void;
  39483. dispose(camera?: Camera): void;
  39484. }
  39485. }
  39486. declare module BABYLON {
  39487. /**
  39488. * Class containing static functions to help procedurally build meshes
  39489. */
  39490. export class GroundBuilder {
  39491. /**
  39492. * Creates a ground mesh
  39493. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39494. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39496. * @param name defines the name of the mesh
  39497. * @param options defines the options used to create the mesh
  39498. * @param scene defines the hosting scene
  39499. * @returns the ground mesh
  39500. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39501. */
  39502. static CreateGround(name: string, options: {
  39503. width?: number;
  39504. height?: number;
  39505. subdivisions?: number;
  39506. subdivisionsX?: number;
  39507. subdivisionsY?: number;
  39508. updatable?: boolean;
  39509. }, scene: any): Mesh;
  39510. /**
  39511. * Creates a tiled ground mesh
  39512. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39513. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39514. * * 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
  39515. * * 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
  39516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39517. * @param name defines the name of the mesh
  39518. * @param options defines the options used to create the mesh
  39519. * @param scene defines the hosting scene
  39520. * @returns the tiled ground mesh
  39521. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39522. */
  39523. static CreateTiledGround(name: string, options: {
  39524. xmin: number;
  39525. zmin: number;
  39526. xmax: number;
  39527. zmax: number;
  39528. subdivisions?: {
  39529. w: number;
  39530. h: number;
  39531. };
  39532. precision?: {
  39533. w: number;
  39534. h: number;
  39535. };
  39536. updatable?: boolean;
  39537. }, scene?: Nullable<Scene>): Mesh;
  39538. /**
  39539. * Creates a ground mesh from a height map
  39540. * * The parameter `url` sets the URL of the height map image resource.
  39541. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39542. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39543. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39544. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39545. * * 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.
  39546. * * 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).
  39547. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39549. * @param name defines the name of the mesh
  39550. * @param url defines the url to the height map
  39551. * @param options defines the options used to create the mesh
  39552. * @param scene defines the hosting scene
  39553. * @returns the ground mesh
  39554. * @see https://doc.babylonjs.com/babylon101/height_map
  39555. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39556. */
  39557. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39558. width?: number;
  39559. height?: number;
  39560. subdivisions?: number;
  39561. minHeight?: number;
  39562. maxHeight?: number;
  39563. colorFilter?: Color3;
  39564. alphaFilter?: number;
  39565. updatable?: boolean;
  39566. onReady?: (mesh: GroundMesh) => void;
  39567. }, scene?: Nullable<Scene>): GroundMesh;
  39568. }
  39569. }
  39570. declare module BABYLON {
  39571. /**
  39572. * Class containing static functions to help procedurally build meshes
  39573. */
  39574. export class TorusBuilder {
  39575. /**
  39576. * Creates a torus mesh
  39577. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39578. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39579. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39580. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39581. * * 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
  39582. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39583. * @param name defines the name of the mesh
  39584. * @param options defines the options used to create the mesh
  39585. * @param scene defines the hosting scene
  39586. * @returns the torus mesh
  39587. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39588. */
  39589. static CreateTorus(name: string, options: {
  39590. diameter?: number;
  39591. thickness?: number;
  39592. tessellation?: number;
  39593. updatable?: boolean;
  39594. sideOrientation?: number;
  39595. frontUVs?: Vector4;
  39596. backUVs?: Vector4;
  39597. }, scene: any): Mesh;
  39598. }
  39599. }
  39600. declare module BABYLON {
  39601. /**
  39602. * Class containing static functions to help procedurally build meshes
  39603. */
  39604. export class CylinderBuilder {
  39605. /**
  39606. * Creates a cylinder or a cone mesh
  39607. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39608. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39609. * * 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.
  39610. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39611. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39612. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39613. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39614. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39615. * * 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).
  39616. * * 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
  39617. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39618. * * 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
  39619. * * 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.
  39620. * * If `enclose` is false, a ring surface is one element.
  39621. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39622. * * 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
  39623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39624. * * 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
  39625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39626. * @param name defines the name of the mesh
  39627. * @param options defines the options used to create the mesh
  39628. * @param scene defines the hosting scene
  39629. * @returns the cylinder mesh
  39630. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39631. */
  39632. static CreateCylinder(name: string, options: {
  39633. height?: number;
  39634. diameterTop?: number;
  39635. diameterBottom?: number;
  39636. diameter?: number;
  39637. tessellation?: number;
  39638. subdivisions?: number;
  39639. arc?: number;
  39640. faceColors?: Color4[];
  39641. faceUV?: Vector4[];
  39642. updatable?: boolean;
  39643. hasRings?: boolean;
  39644. enclose?: boolean;
  39645. sideOrientation?: number;
  39646. frontUVs?: Vector4;
  39647. backUVs?: Vector4;
  39648. }, scene: any): Mesh;
  39649. }
  39650. }
  39651. declare module BABYLON {
  39652. /**
  39653. * Options to modify the vr teleportation behavior.
  39654. */
  39655. export interface VRTeleportationOptions {
  39656. /**
  39657. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39658. */
  39659. floorMeshName?: string;
  39660. /**
  39661. * A list of meshes to be used as the teleportation floor. (default: empty)
  39662. */
  39663. floorMeshes?: Mesh[];
  39664. }
  39665. /**
  39666. * Options to modify the vr experience helper's behavior.
  39667. */
  39668. export interface VRExperienceHelperOptions extends WebVROptions {
  39669. /**
  39670. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39671. */
  39672. createDeviceOrientationCamera?: boolean;
  39673. /**
  39674. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39675. */
  39676. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39677. /**
  39678. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39679. */
  39680. laserToggle?: boolean;
  39681. /**
  39682. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39683. */
  39684. floorMeshes?: Mesh[];
  39685. /**
  39686. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39687. */
  39688. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39689. }
  39690. /**
  39691. * Event containing information after VR has been entered
  39692. */
  39693. export class OnAfterEnteringVRObservableEvent {
  39694. /**
  39695. * If entering vr was successful
  39696. */
  39697. success: boolean;
  39698. }
  39699. /**
  39700. * Helps to quickly add VR support to an existing scene.
  39701. * See http://doc.babylonjs.com/how_to/webvr_helper
  39702. */
  39703. export class VRExperienceHelper {
  39704. /** Options to modify the vr experience helper's behavior. */
  39705. webVROptions: VRExperienceHelperOptions;
  39706. private _scene;
  39707. private _position;
  39708. private _btnVR;
  39709. private _btnVRDisplayed;
  39710. private _webVRsupported;
  39711. private _webVRready;
  39712. private _webVRrequesting;
  39713. private _webVRpresenting;
  39714. private _hasEnteredVR;
  39715. private _fullscreenVRpresenting;
  39716. private _canvas;
  39717. private _webVRCamera;
  39718. private _vrDeviceOrientationCamera;
  39719. private _deviceOrientationCamera;
  39720. private _existingCamera;
  39721. private _onKeyDown;
  39722. private _onVrDisplayPresentChange;
  39723. private _onVRDisplayChanged;
  39724. private _onVRRequestPresentStart;
  39725. private _onVRRequestPresentComplete;
  39726. /**
  39727. * Observable raised right before entering VR.
  39728. */
  39729. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39730. /**
  39731. * Observable raised when entering VR has completed.
  39732. */
  39733. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39734. /**
  39735. * Observable raised when exiting VR.
  39736. */
  39737. onExitingVRObservable: Observable<VRExperienceHelper>;
  39738. /**
  39739. * Observable raised when controller mesh is loaded.
  39740. */
  39741. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39742. /** Return this.onEnteringVRObservable
  39743. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39744. */
  39745. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39746. /** Return this.onExitingVRObservable
  39747. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39748. */
  39749. readonly onExitingVR: Observable<VRExperienceHelper>;
  39750. /** Return this.onControllerMeshLoadedObservable
  39751. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39752. */
  39753. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39754. private _rayLength;
  39755. private _useCustomVRButton;
  39756. private _teleportationRequested;
  39757. private _teleportActive;
  39758. private _floorMeshName;
  39759. private _floorMeshesCollection;
  39760. private _rotationAllowed;
  39761. private _teleportBackwardsVector;
  39762. private _teleportationTarget;
  39763. private _isDefaultTeleportationTarget;
  39764. private _postProcessMove;
  39765. private _teleportationFillColor;
  39766. private _teleportationBorderColor;
  39767. private _rotationAngle;
  39768. private _haloCenter;
  39769. private _cameraGazer;
  39770. private _padSensibilityUp;
  39771. private _padSensibilityDown;
  39772. private _leftController;
  39773. private _rightController;
  39774. /**
  39775. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39776. */
  39777. onNewMeshSelected: Observable<AbstractMesh>;
  39778. /**
  39779. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39780. */
  39781. onNewMeshPicked: Observable<PickingInfo>;
  39782. private _circleEase;
  39783. /**
  39784. * Observable raised before camera teleportation
  39785. */
  39786. onBeforeCameraTeleport: Observable<Vector3>;
  39787. /**
  39788. * Observable raised after camera teleportation
  39789. */
  39790. onAfterCameraTeleport: Observable<Vector3>;
  39791. /**
  39792. * Observable raised when current selected mesh gets unselected
  39793. */
  39794. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39795. private _raySelectionPredicate;
  39796. /**
  39797. * To be optionaly changed by user to define custom ray selection
  39798. */
  39799. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39800. /**
  39801. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39802. */
  39803. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39804. /**
  39805. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39806. */
  39807. teleportationEnabled: boolean;
  39808. private _defaultHeight;
  39809. private _teleportationInitialized;
  39810. private _interactionsEnabled;
  39811. private _interactionsRequested;
  39812. private _displayGaze;
  39813. private _displayLaserPointer;
  39814. /**
  39815. * The mesh used to display where the user is going to teleport.
  39816. */
  39817. /**
  39818. * Sets the mesh to be used to display where the user is going to teleport.
  39819. */
  39820. teleportationTarget: Mesh;
  39821. /**
  39822. * 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
  39823. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39824. * See http://doc.babylonjs.com/resources/baking_transformations
  39825. */
  39826. gazeTrackerMesh: Mesh;
  39827. /**
  39828. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39829. */
  39830. updateGazeTrackerScale: boolean;
  39831. /**
  39832. * If the gaze trackers color should be updated when selecting meshes
  39833. */
  39834. updateGazeTrackerColor: boolean;
  39835. /**
  39836. * The gaze tracking mesh corresponding to the left controller
  39837. */
  39838. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39839. /**
  39840. * The gaze tracking mesh corresponding to the right controller
  39841. */
  39842. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39843. /**
  39844. * If the ray of the gaze should be displayed.
  39845. */
  39846. /**
  39847. * Sets if the ray of the gaze should be displayed.
  39848. */
  39849. displayGaze: boolean;
  39850. /**
  39851. * If the ray of the LaserPointer should be displayed.
  39852. */
  39853. /**
  39854. * Sets if the ray of the LaserPointer should be displayed.
  39855. */
  39856. displayLaserPointer: boolean;
  39857. /**
  39858. * The deviceOrientationCamera used as the camera when not in VR.
  39859. */
  39860. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39861. /**
  39862. * Based on the current WebVR support, returns the current VR camera used.
  39863. */
  39864. readonly currentVRCamera: Nullable<Camera>;
  39865. /**
  39866. * The webVRCamera which is used when in VR.
  39867. */
  39868. readonly webVRCamera: WebVRFreeCamera;
  39869. /**
  39870. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39871. */
  39872. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39873. private readonly _teleportationRequestInitiated;
  39874. /**
  39875. * Defines wether or not Pointer lock should be requested when switching to
  39876. * full screen.
  39877. */
  39878. requestPointerLockOnFullScreen: boolean;
  39879. /**
  39880. * Instantiates a VRExperienceHelper.
  39881. * Helps to quickly add VR support to an existing scene.
  39882. * @param scene The scene the VRExperienceHelper belongs to.
  39883. * @param webVROptions Options to modify the vr experience helper's behavior.
  39884. */
  39885. constructor(scene: Scene,
  39886. /** Options to modify the vr experience helper's behavior. */
  39887. webVROptions?: VRExperienceHelperOptions);
  39888. private _onDefaultMeshLoaded;
  39889. private _onResize;
  39890. private _onFullscreenChange;
  39891. /**
  39892. * Gets a value indicating if we are currently in VR mode.
  39893. */
  39894. readonly isInVRMode: boolean;
  39895. private onVrDisplayPresentChange;
  39896. private onVRDisplayChanged;
  39897. private moveButtonToBottomRight;
  39898. private displayVRButton;
  39899. private updateButtonVisibility;
  39900. private _cachedAngularSensibility;
  39901. /**
  39902. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39903. * Otherwise, will use the fullscreen API.
  39904. */
  39905. enterVR(): void;
  39906. /**
  39907. * Attempt to exit VR, or fullscreen.
  39908. */
  39909. exitVR(): void;
  39910. /**
  39911. * The position of the vr experience helper.
  39912. */
  39913. /**
  39914. * Sets the position of the vr experience helper.
  39915. */
  39916. position: Vector3;
  39917. /**
  39918. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39919. */
  39920. enableInteractions(): void;
  39921. private readonly _noControllerIsActive;
  39922. private beforeRender;
  39923. private _isTeleportationFloor;
  39924. /**
  39925. * Adds a floor mesh to be used for teleportation.
  39926. * @param floorMesh the mesh to be used for teleportation.
  39927. */
  39928. addFloorMesh(floorMesh: Mesh): void;
  39929. /**
  39930. * Removes a floor mesh from being used for teleportation.
  39931. * @param floorMesh the mesh to be removed.
  39932. */
  39933. removeFloorMesh(floorMesh: Mesh): void;
  39934. /**
  39935. * Enables interactions and teleportation using the VR controllers and gaze.
  39936. * @param vrTeleportationOptions options to modify teleportation behavior.
  39937. */
  39938. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39939. private _onNewGamepadConnected;
  39940. private _tryEnableInteractionOnController;
  39941. private _onNewGamepadDisconnected;
  39942. private _enableInteractionOnController;
  39943. private _checkTeleportWithRay;
  39944. private _checkRotate;
  39945. private _checkTeleportBackwards;
  39946. private _enableTeleportationOnController;
  39947. private _createTeleportationCircles;
  39948. private _displayTeleportationTarget;
  39949. private _hideTeleportationTarget;
  39950. private _rotateCamera;
  39951. private _moveTeleportationSelectorTo;
  39952. private _workingVector;
  39953. private _workingQuaternion;
  39954. private _workingMatrix;
  39955. /**
  39956. * Teleports the users feet to the desired location
  39957. * @param location The location where the user's feet should be placed
  39958. */
  39959. teleportCamera(location: Vector3): void;
  39960. private _convertNormalToDirectionOfRay;
  39961. private _castRayAndSelectObject;
  39962. private _notifySelectedMeshUnselected;
  39963. /**
  39964. * Sets the color of the laser ray from the vr controllers.
  39965. * @param color new color for the ray.
  39966. */
  39967. changeLaserColor(color: Color3): void;
  39968. /**
  39969. * Sets the color of the ray from the vr headsets gaze.
  39970. * @param color new color for the ray.
  39971. */
  39972. changeGazeColor(color: Color3): void;
  39973. /**
  39974. * Exits VR and disposes of the vr experience helper
  39975. */
  39976. dispose(): void;
  39977. /**
  39978. * Gets the name of the VRExperienceHelper class
  39979. * @returns "VRExperienceHelper"
  39980. */
  39981. getClassName(): string;
  39982. }
  39983. }
  39984. declare module BABYLON {
  39985. /**
  39986. * Manages an XRSession
  39987. * @see https://doc.babylonjs.com/how_to/webxr
  39988. */
  39989. export class WebXRSessionManager implements IDisposable {
  39990. private scene;
  39991. /**
  39992. * Fires every time a new xrFrame arrives which can be used to update the camera
  39993. */
  39994. onXRFrameObservable: Observable<any>;
  39995. /**
  39996. * Fires when the xr session is ended either by the device or manually done
  39997. */
  39998. onXRSessionEnded: Observable<any>;
  39999. /** @hidden */
  40000. _xrSession: XRSession;
  40001. /** @hidden */
  40002. _frameOfReference: XRFrameOfReference;
  40003. /** @hidden */
  40004. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40005. /** @hidden */
  40006. _currentXRFrame: Nullable<XRFrame>;
  40007. private _xrNavigator;
  40008. private _xrDevice;
  40009. private _tmpMatrix;
  40010. /**
  40011. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40012. * @param scene The scene which the session should be created for
  40013. */
  40014. constructor(scene: Scene);
  40015. /**
  40016. * Initializes the manager
  40017. * After initialization enterXR can be called to start an XR session
  40018. * @returns Promise which resolves after it is initialized
  40019. */
  40020. initializeAsync(): Promise<void>;
  40021. /**
  40022. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40023. * @param sessionCreationOptions xr options to create the session with
  40024. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40025. * @returns Promise which resolves after it enters XR
  40026. */
  40027. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40028. /**
  40029. * Stops the xrSession and restores the renderloop
  40030. * @returns Promise which resolves after it exits XR
  40031. */
  40032. exitXRAsync(): Promise<void>;
  40033. /**
  40034. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40035. * @param ray ray to cast into the environment
  40036. * @returns Promise which resolves with a collision point in the environment if it exists
  40037. */
  40038. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40039. /**
  40040. * Checks if a session would be supported for the creation options specified
  40041. * @param options creation options to check if they are supported
  40042. * @returns true if supported
  40043. */
  40044. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40045. /**
  40046. * @hidden
  40047. * Converts the render layer of xrSession to a render target
  40048. * @param session session to create render target for
  40049. * @param scene scene the new render target should be created for
  40050. */
  40051. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40052. /**
  40053. * Disposes of the session manager
  40054. */
  40055. dispose(): void;
  40056. }
  40057. }
  40058. declare module BABYLON {
  40059. /**
  40060. * WebXR Camera which holds the views for the xrSession
  40061. * @see https://doc.babylonjs.com/how_to/webxr
  40062. */
  40063. export class WebXRCamera extends FreeCamera {
  40064. private static _TmpMatrix;
  40065. /**
  40066. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40067. * @param name the name of the camera
  40068. * @param scene the scene to add the camera to
  40069. */
  40070. constructor(name: string, scene: Scene);
  40071. private _updateNumberOfRigCameras;
  40072. /** @hidden */
  40073. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40074. /**
  40075. * Updates the cameras position from the current pose information of the XR session
  40076. * @param xrSessionManager the session containing pose information
  40077. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40078. */
  40079. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40080. }
  40081. }
  40082. declare module BABYLON {
  40083. /**
  40084. * States of the webXR experience
  40085. */
  40086. export enum WebXRState {
  40087. /**
  40088. * Transitioning to being in XR mode
  40089. */
  40090. ENTERING_XR = 0,
  40091. /**
  40092. * Transitioning to non XR mode
  40093. */
  40094. EXITING_XR = 1,
  40095. /**
  40096. * In XR mode and presenting
  40097. */
  40098. IN_XR = 2,
  40099. /**
  40100. * Not entered XR mode
  40101. */
  40102. NOT_IN_XR = 3
  40103. }
  40104. /**
  40105. * Helper class used to enable XR
  40106. * @see https://doc.babylonjs.com/how_to/webxr
  40107. */
  40108. export class WebXRExperienceHelper implements IDisposable {
  40109. private scene;
  40110. /**
  40111. * 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
  40112. */
  40113. container: AbstractMesh;
  40114. /**
  40115. * Camera used to render xr content
  40116. */
  40117. camera: WebXRCamera;
  40118. /**
  40119. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40120. */
  40121. state: WebXRState;
  40122. private _setState;
  40123. private static _TmpVector;
  40124. /**
  40125. * Fires when the state of the experience helper has changed
  40126. */
  40127. onStateChangedObservable: Observable<WebXRState>;
  40128. /** @hidden */
  40129. _sessionManager: WebXRSessionManager;
  40130. private _nonVRCamera;
  40131. private _originalSceneAutoClear;
  40132. private _supported;
  40133. /**
  40134. * Creates the experience helper
  40135. * @param scene the scene to attach the experience helper to
  40136. * @returns a promise for the experience helper
  40137. */
  40138. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40139. /**
  40140. * Creates a WebXRExperienceHelper
  40141. * @param scene The scene the helper should be created in
  40142. */
  40143. private constructor();
  40144. /**
  40145. * Exits XR mode and returns the scene to its original state
  40146. * @returns promise that resolves after xr mode has exited
  40147. */
  40148. exitXRAsync(): Promise<void>;
  40149. /**
  40150. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40151. * @param sessionCreationOptions options for the XR session
  40152. * @param frameOfReference frame of reference of the XR session
  40153. * @returns promise that resolves after xr mode has entered
  40154. */
  40155. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40156. /**
  40157. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40158. * @param ray ray to cast into the environment
  40159. * @returns Promise which resolves with a collision point in the environment if it exists
  40160. */
  40161. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40162. /**
  40163. * Updates the global position of the camera by moving the camera's container
  40164. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40165. * @param position The desired global position of the camera
  40166. */
  40167. setPositionOfCameraUsingContainer(position: Vector3): void;
  40168. /**
  40169. * Rotates the xr camera by rotating the camera's container around the camera's position
  40170. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40171. * @param rotation the desired quaternion rotation to apply to the camera
  40172. */
  40173. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40174. /**
  40175. * Checks if the creation options are supported by the xr session
  40176. * @param options creation options
  40177. * @returns true if supported
  40178. */
  40179. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40180. /**
  40181. * Disposes of the experience helper
  40182. */
  40183. dispose(): void;
  40184. }
  40185. }
  40186. declare module BABYLON {
  40187. /**
  40188. * Button which can be used to enter a different mode of XR
  40189. */
  40190. export class WebXREnterExitUIButton {
  40191. /** button element */
  40192. element: HTMLElement;
  40193. /** XR initialization options for the button */
  40194. initializationOptions: XRSessionCreationOptions;
  40195. /**
  40196. * Creates a WebXREnterExitUIButton
  40197. * @param element button element
  40198. * @param initializationOptions XR initialization options for the button
  40199. */
  40200. constructor(
  40201. /** button element */
  40202. element: HTMLElement,
  40203. /** XR initialization options for the button */
  40204. initializationOptions: XRSessionCreationOptions);
  40205. /**
  40206. * Overwritable function which can be used to update the button's visuals when the state changes
  40207. * @param activeButton the current active button in the UI
  40208. */
  40209. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40210. }
  40211. /**
  40212. * Options to create the webXR UI
  40213. */
  40214. export class WebXREnterExitUIOptions {
  40215. /**
  40216. * Context to enter xr with
  40217. */
  40218. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40219. /**
  40220. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40221. */
  40222. customButtons?: Array<WebXREnterExitUIButton>;
  40223. }
  40224. /**
  40225. * UI to allow the user to enter/exit XR mode
  40226. */
  40227. export class WebXREnterExitUI implements IDisposable {
  40228. private scene;
  40229. private _overlay;
  40230. private _buttons;
  40231. private _activeButton;
  40232. /**
  40233. * Fired every time the active button is changed.
  40234. *
  40235. * When xr is entered via a button that launches xr that button will be the callback parameter
  40236. *
  40237. * When exiting xr the callback parameter will be null)
  40238. */
  40239. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40240. /**
  40241. * Creates UI to allow the user to enter/exit XR mode
  40242. * @param scene the scene to add the ui to
  40243. * @param helper the xr experience helper to enter/exit xr with
  40244. * @param options options to configure the UI
  40245. * @returns the created ui
  40246. */
  40247. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40248. private constructor();
  40249. private _updateButtons;
  40250. /**
  40251. * Disposes of the object
  40252. */
  40253. dispose(): void;
  40254. }
  40255. }
  40256. declare module BABYLON {
  40257. /**
  40258. * Represents an XR input
  40259. */
  40260. export class WebXRController {
  40261. /**
  40262. * 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
  40263. */
  40264. grip?: AbstractMesh;
  40265. /**
  40266. * Pointer which can be used to select objects or attach a visible laser to
  40267. */
  40268. pointer: AbstractMesh;
  40269. /**
  40270. * Creates the controller
  40271. * @see https://doc.babylonjs.com/how_to/webxr
  40272. * @param scene the scene which the controller should be associated to
  40273. */
  40274. constructor(scene: Scene);
  40275. /**
  40276. * Disposes of the object
  40277. */
  40278. dispose(): void;
  40279. }
  40280. /**
  40281. * XR input used to track XR inputs such as controllers/rays
  40282. */
  40283. export class WebXRInput implements IDisposable {
  40284. private helper;
  40285. /**
  40286. * XR controllers being tracked
  40287. */
  40288. controllers: Array<WebXRController>;
  40289. private _tmpMatrix;
  40290. private _frameObserver;
  40291. /**
  40292. * Initializes the WebXRInput
  40293. * @param helper experience helper which the input should be created for
  40294. */
  40295. constructor(helper: WebXRExperienceHelper);
  40296. /**
  40297. * Disposes of the object
  40298. */
  40299. dispose(): void;
  40300. }
  40301. }
  40302. declare module BABYLON {
  40303. /**
  40304. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40305. */
  40306. export class WebXRManagedOutputCanvas implements IDisposable {
  40307. private _canvas;
  40308. /**
  40309. * xrpresent context of the canvas which can be used to display/mirror xr content
  40310. */
  40311. canvasContext: Nullable<WebGLRenderingContext>;
  40312. /**
  40313. * Initializes the canvas to be added/removed upon entering/exiting xr
  40314. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40315. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40316. */
  40317. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40318. /**
  40319. * Disposes of the object
  40320. */
  40321. dispose(): void;
  40322. private _setManagedOutputCanvas;
  40323. private _addCanvas;
  40324. private _removeCanvas;
  40325. }
  40326. }
  40327. declare module BABYLON {
  40328. /**
  40329. * Contains an array of blocks representing the octree
  40330. */
  40331. export interface IOctreeContainer<T> {
  40332. /**
  40333. * Blocks within the octree
  40334. */
  40335. blocks: Array<OctreeBlock<T>>;
  40336. }
  40337. /**
  40338. * Class used to store a cell in an octree
  40339. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40340. */
  40341. export class OctreeBlock<T> {
  40342. /**
  40343. * Gets the content of the current block
  40344. */
  40345. entries: T[];
  40346. /**
  40347. * Gets the list of block children
  40348. */
  40349. blocks: Array<OctreeBlock<T>>;
  40350. private _depth;
  40351. private _maxDepth;
  40352. private _capacity;
  40353. private _minPoint;
  40354. private _maxPoint;
  40355. private _boundingVectors;
  40356. private _creationFunc;
  40357. /**
  40358. * Creates a new block
  40359. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40360. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40361. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40362. * @param depth defines the current depth of this block in the octree
  40363. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40364. * @param creationFunc defines a callback to call when an element is added to the block
  40365. */
  40366. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40367. /**
  40368. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40369. */
  40370. readonly capacity: number;
  40371. /**
  40372. * Gets the minimum vector (in world space) of the block's bounding box
  40373. */
  40374. readonly minPoint: Vector3;
  40375. /**
  40376. * Gets the maximum vector (in world space) of the block's bounding box
  40377. */
  40378. readonly maxPoint: Vector3;
  40379. /**
  40380. * Add a new element to this block
  40381. * @param entry defines the element to add
  40382. */
  40383. addEntry(entry: T): void;
  40384. /**
  40385. * Remove an element from this block
  40386. * @param entry defines the element to remove
  40387. */
  40388. removeEntry(entry: T): void;
  40389. /**
  40390. * Add an array of elements to this block
  40391. * @param entries defines the array of elements to add
  40392. */
  40393. addEntries(entries: T[]): void;
  40394. /**
  40395. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40396. * @param frustumPlanes defines the frustum planes to test
  40397. * @param selection defines the array to store current content if selection is positive
  40398. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40399. */
  40400. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40401. /**
  40402. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40403. * @param sphereCenter defines the bounding sphere center
  40404. * @param sphereRadius defines the bounding sphere radius
  40405. * @param selection defines the array to store current content if selection is positive
  40406. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40407. */
  40408. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40409. /**
  40410. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40411. * @param ray defines the ray to test with
  40412. * @param selection defines the array to store current content if selection is positive
  40413. */
  40414. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40415. /**
  40416. * Subdivide the content into child blocks (this block will then be empty)
  40417. */
  40418. createInnerBlocks(): void;
  40419. /**
  40420. * @hidden
  40421. */
  40422. 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;
  40423. }
  40424. }
  40425. declare module BABYLON {
  40426. /**
  40427. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40428. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40429. */
  40430. export class Octree<T> {
  40431. /** 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.) */
  40432. maxDepth: number;
  40433. /**
  40434. * Blocks within the octree containing objects
  40435. */
  40436. blocks: Array<OctreeBlock<T>>;
  40437. /**
  40438. * Content stored in the octree
  40439. */
  40440. dynamicContent: T[];
  40441. private _maxBlockCapacity;
  40442. private _selectionContent;
  40443. private _creationFunc;
  40444. /**
  40445. * Creates a octree
  40446. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40447. * @param creationFunc function to be used to instatiate the octree
  40448. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40449. * @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.)
  40450. */
  40451. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40452. /** 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.) */
  40453. maxDepth?: number);
  40454. /**
  40455. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40456. * @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);
  40457. * @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);
  40458. * @param entries meshes to be added to the octree blocks
  40459. */
  40460. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40461. /**
  40462. * Adds a mesh to the octree
  40463. * @param entry Mesh to add to the octree
  40464. */
  40465. addMesh(entry: T): void;
  40466. /**
  40467. * Remove an element from the octree
  40468. * @param entry defines the element to remove
  40469. */
  40470. removeMesh(entry: T): void;
  40471. /**
  40472. * Selects an array of meshes within the frustum
  40473. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40474. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40475. * @returns array of meshes within the frustum
  40476. */
  40477. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40478. /**
  40479. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40480. * @param sphereCenter defines the bounding sphere center
  40481. * @param sphereRadius defines the bounding sphere radius
  40482. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40483. * @returns an array of objects that intersect the sphere
  40484. */
  40485. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40486. /**
  40487. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40488. * @param ray defines the ray to test with
  40489. * @returns array of intersected objects
  40490. */
  40491. intersectsRay(ray: Ray): SmartArray<T>;
  40492. /**
  40493. * Adds a mesh into the octree block if it intersects the block
  40494. */
  40495. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40496. /**
  40497. * Adds a submesh into the octree block if it intersects the block
  40498. */
  40499. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40500. }
  40501. }
  40502. declare module BABYLON {
  40503. interface Scene {
  40504. /**
  40505. * @hidden
  40506. * Backing Filed
  40507. */
  40508. _selectionOctree: Octree<AbstractMesh>;
  40509. /**
  40510. * Gets the octree used to boost mesh selection (picking)
  40511. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40512. */
  40513. selectionOctree: Octree<AbstractMesh>;
  40514. /**
  40515. * Creates or updates the octree used to boost selection (picking)
  40516. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40517. * @param maxCapacity defines the maximum capacity per leaf
  40518. * @param maxDepth defines the maximum depth of the octree
  40519. * @returns an octree of AbstractMesh
  40520. */
  40521. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40522. }
  40523. interface AbstractMesh {
  40524. /**
  40525. * @hidden
  40526. * Backing Field
  40527. */
  40528. _submeshesOctree: Octree<SubMesh>;
  40529. /**
  40530. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40531. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40532. * @param maxCapacity defines the maximum size of each block (64 by default)
  40533. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40534. * @returns the new octree
  40535. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40536. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40537. */
  40538. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40539. }
  40540. /**
  40541. * Defines the octree scene component responsible to manage any octrees
  40542. * in a given scene.
  40543. */
  40544. export class OctreeSceneComponent {
  40545. /**
  40546. * The component name help to identify the component in the list of scene components.
  40547. */
  40548. readonly name: string;
  40549. /**
  40550. * The scene the component belongs to.
  40551. */
  40552. scene: Scene;
  40553. /**
  40554. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40555. */
  40556. readonly checksIsEnabled: boolean;
  40557. /**
  40558. * Creates a new instance of the component for the given scene
  40559. * @param scene Defines the scene to register the component in
  40560. */
  40561. constructor(scene: Scene);
  40562. /**
  40563. * Registers the component in a given scene
  40564. */
  40565. register(): void;
  40566. /**
  40567. * Return the list of active meshes
  40568. * @returns the list of active meshes
  40569. */
  40570. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40571. /**
  40572. * Return the list of active sub meshes
  40573. * @param mesh The mesh to get the candidates sub meshes from
  40574. * @returns the list of active sub meshes
  40575. */
  40576. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40577. private _tempRay;
  40578. /**
  40579. * Return the list of sub meshes intersecting with a given local ray
  40580. * @param mesh defines the mesh to find the submesh for
  40581. * @param localRay defines the ray in local space
  40582. * @returns the list of intersecting sub meshes
  40583. */
  40584. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40585. /**
  40586. * Return the list of sub meshes colliding with a collider
  40587. * @param mesh defines the mesh to find the submesh for
  40588. * @param collider defines the collider to evaluate the collision against
  40589. * @returns the list of colliding sub meshes
  40590. */
  40591. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40592. /**
  40593. * Rebuilds the elements related to this component in case of
  40594. * context lost for instance.
  40595. */
  40596. rebuild(): void;
  40597. /**
  40598. * Disposes the component and the associated ressources.
  40599. */
  40600. dispose(): void;
  40601. }
  40602. }
  40603. declare module BABYLON {
  40604. /**
  40605. * Renders a layer on top of an existing scene
  40606. */
  40607. export class UtilityLayerRenderer implements IDisposable {
  40608. /** the original scene that will be rendered on top of */
  40609. originalScene: Scene;
  40610. private _pointerCaptures;
  40611. private _lastPointerEvents;
  40612. private static _DefaultUtilityLayer;
  40613. private static _DefaultKeepDepthUtilityLayer;
  40614. private _sharedGizmoLight;
  40615. /**
  40616. * @hidden
  40617. * Light which used by gizmos to get light shading
  40618. */
  40619. _getSharedGizmoLight(): HemisphericLight;
  40620. /**
  40621. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40622. */
  40623. pickUtilitySceneFirst: boolean;
  40624. /**
  40625. * 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)
  40626. */
  40627. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40628. /**
  40629. * 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)
  40630. */
  40631. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40632. /**
  40633. * The scene that is rendered on top of the original scene
  40634. */
  40635. utilityLayerScene: Scene;
  40636. /**
  40637. * If the utility layer should automatically be rendered on top of existing scene
  40638. */
  40639. shouldRender: boolean;
  40640. /**
  40641. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40642. */
  40643. onlyCheckPointerDownEvents: boolean;
  40644. /**
  40645. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40646. */
  40647. processAllEvents: boolean;
  40648. /**
  40649. * Observable raised when the pointer move from the utility layer scene to the main scene
  40650. */
  40651. onPointerOutObservable: Observable<number>;
  40652. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40653. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40654. private _afterRenderObserver;
  40655. private _sceneDisposeObserver;
  40656. private _originalPointerObserver;
  40657. /**
  40658. * Instantiates a UtilityLayerRenderer
  40659. * @param originalScene the original scene that will be rendered on top of
  40660. * @param handleEvents boolean indicating if the utility layer should handle events
  40661. */
  40662. constructor(
  40663. /** the original scene that will be rendered on top of */
  40664. originalScene: Scene, handleEvents?: boolean);
  40665. private _notifyObservers;
  40666. /**
  40667. * Renders the utility layers scene on top of the original scene
  40668. */
  40669. render(): void;
  40670. /**
  40671. * Disposes of the renderer
  40672. */
  40673. dispose(): void;
  40674. private _updateCamera;
  40675. }
  40676. }
  40677. declare module BABYLON {
  40678. /**
  40679. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40680. */
  40681. export class Gizmo implements IDisposable {
  40682. /** The utility layer the gizmo will be added to */
  40683. gizmoLayer: UtilityLayerRenderer;
  40684. /**
  40685. * The root mesh of the gizmo
  40686. */
  40687. _rootMesh: Mesh;
  40688. private _attachedMesh;
  40689. /**
  40690. * Ratio for the scale of the gizmo (Default: 1)
  40691. */
  40692. scaleRatio: number;
  40693. /**
  40694. * If a custom mesh has been set (Default: false)
  40695. */
  40696. protected _customMeshSet: boolean;
  40697. /**
  40698. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40699. * * When set, interactions will be enabled
  40700. */
  40701. attachedMesh: Nullable<AbstractMesh>;
  40702. /**
  40703. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40704. * @param mesh The mesh to replace the default mesh of the gizmo
  40705. */
  40706. setCustomMesh(mesh: Mesh): void;
  40707. /**
  40708. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40709. */
  40710. updateGizmoRotationToMatchAttachedMesh: boolean;
  40711. /**
  40712. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40713. */
  40714. updateGizmoPositionToMatchAttachedMesh: boolean;
  40715. /**
  40716. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40717. */
  40718. protected _updateScale: boolean;
  40719. protected _interactionsEnabled: boolean;
  40720. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40721. private _beforeRenderObserver;
  40722. private _tempVector;
  40723. /**
  40724. * Creates a gizmo
  40725. * @param gizmoLayer The utility layer the gizmo will be added to
  40726. */
  40727. constructor(
  40728. /** The utility layer the gizmo will be added to */
  40729. gizmoLayer?: UtilityLayerRenderer);
  40730. /**
  40731. * Updates the gizmo to match the attached mesh's position/rotation
  40732. */
  40733. protected _update(): void;
  40734. /**
  40735. * Disposes of the gizmo
  40736. */
  40737. dispose(): void;
  40738. }
  40739. }
  40740. declare module BABYLON {
  40741. /**
  40742. * Single axis drag gizmo
  40743. */
  40744. export class AxisDragGizmo extends Gizmo {
  40745. /**
  40746. * Drag behavior responsible for the gizmos dragging interactions
  40747. */
  40748. dragBehavior: PointerDragBehavior;
  40749. private _pointerObserver;
  40750. /**
  40751. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40752. */
  40753. snapDistance: number;
  40754. /**
  40755. * Event that fires each time the gizmo snaps to a new location.
  40756. * * snapDistance is the the change in distance
  40757. */
  40758. onSnapObservable: Observable<{
  40759. snapDistance: number;
  40760. }>;
  40761. /** @hidden */
  40762. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40763. /** @hidden */
  40764. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40765. /**
  40766. * Creates an AxisDragGizmo
  40767. * @param gizmoLayer The utility layer the gizmo will be added to
  40768. * @param dragAxis The axis which the gizmo will be able to drag on
  40769. * @param color The color of the gizmo
  40770. */
  40771. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40772. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40773. /**
  40774. * Disposes of the gizmo
  40775. */
  40776. dispose(): void;
  40777. }
  40778. }
  40779. declare module BABYLON.Debug {
  40780. /**
  40781. * The Axes viewer will show 3 axes in a specific point in space
  40782. */
  40783. export class AxesViewer {
  40784. private _xAxis;
  40785. private _yAxis;
  40786. private _zAxis;
  40787. private _scaleLinesFactor;
  40788. private _instanced;
  40789. /**
  40790. * Gets the hosting scene
  40791. */
  40792. scene: Scene;
  40793. /**
  40794. * Gets or sets a number used to scale line length
  40795. */
  40796. scaleLines: number;
  40797. /** Gets the node hierarchy used to render x-axis */
  40798. readonly xAxis: TransformNode;
  40799. /** Gets the node hierarchy used to render y-axis */
  40800. readonly yAxis: TransformNode;
  40801. /** Gets the node hierarchy used to render z-axis */
  40802. readonly zAxis: TransformNode;
  40803. /**
  40804. * Creates a new AxesViewer
  40805. * @param scene defines the hosting scene
  40806. * @param scaleLines defines a number used to scale line length (1 by default)
  40807. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40808. * @param xAxis defines the node hierarchy used to render the x-axis
  40809. * @param yAxis defines the node hierarchy used to render the y-axis
  40810. * @param zAxis defines the node hierarchy used to render the z-axis
  40811. */
  40812. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40813. /**
  40814. * Force the viewer to update
  40815. * @param position defines the position of the viewer
  40816. * @param xaxis defines the x axis of the viewer
  40817. * @param yaxis defines the y axis of the viewer
  40818. * @param zaxis defines the z axis of the viewer
  40819. */
  40820. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40821. /**
  40822. * Creates an instance of this axes viewer.
  40823. * @returns a new axes viewer with instanced meshes
  40824. */
  40825. createInstance(): AxesViewer;
  40826. /** Releases resources */
  40827. dispose(): void;
  40828. private static _SetRenderingGroupId;
  40829. }
  40830. }
  40831. declare module BABYLON.Debug {
  40832. /**
  40833. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40834. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40835. */
  40836. export class BoneAxesViewer extends AxesViewer {
  40837. /**
  40838. * Gets or sets the target mesh where to display the axes viewer
  40839. */
  40840. mesh: Nullable<Mesh>;
  40841. /**
  40842. * Gets or sets the target bone where to display the axes viewer
  40843. */
  40844. bone: Nullable<Bone>;
  40845. /** Gets current position */
  40846. pos: Vector3;
  40847. /** Gets direction of X axis */
  40848. xaxis: Vector3;
  40849. /** Gets direction of Y axis */
  40850. yaxis: Vector3;
  40851. /** Gets direction of Z axis */
  40852. zaxis: Vector3;
  40853. /**
  40854. * Creates a new BoneAxesViewer
  40855. * @param scene defines the hosting scene
  40856. * @param bone defines the target bone
  40857. * @param mesh defines the target mesh
  40858. * @param scaleLines defines a scaling factor for line length (1 by default)
  40859. */
  40860. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40861. /**
  40862. * Force the viewer to update
  40863. */
  40864. update(): void;
  40865. /** Releases resources */
  40866. dispose(): void;
  40867. }
  40868. }
  40869. declare module BABYLON {
  40870. /**
  40871. * Interface used to define scene explorer extensibility option
  40872. */
  40873. export interface IExplorerExtensibilityOption {
  40874. /**
  40875. * Define the option label
  40876. */
  40877. label: string;
  40878. /**
  40879. * Defines the action to execute on click
  40880. */
  40881. action: (entity: any) => void;
  40882. }
  40883. /**
  40884. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40885. */
  40886. export interface IExplorerExtensibilityGroup {
  40887. /**
  40888. * Defines a predicate to test if a given type mut be extended
  40889. */
  40890. predicate: (entity: any) => boolean;
  40891. /**
  40892. * Gets the list of options added to a type
  40893. */
  40894. entries: IExplorerExtensibilityOption[];
  40895. }
  40896. /**
  40897. * Interface used to define the options to use to create the Inspector
  40898. */
  40899. export interface IInspectorOptions {
  40900. /**
  40901. * Display in overlay mode (default: false)
  40902. */
  40903. overlay?: boolean;
  40904. /**
  40905. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40906. */
  40907. globalRoot?: HTMLElement;
  40908. /**
  40909. * Display the Scene explorer
  40910. */
  40911. showExplorer?: boolean;
  40912. /**
  40913. * Display the property inspector
  40914. */
  40915. showInspector?: boolean;
  40916. /**
  40917. * Display in embed mode (both panes on the right)
  40918. */
  40919. embedMode?: boolean;
  40920. /**
  40921. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40922. */
  40923. handleResize?: boolean;
  40924. /**
  40925. * Allow the panes to popup (default: true)
  40926. */
  40927. enablePopup?: boolean;
  40928. /**
  40929. * Allow the panes to be closed by users (default: true)
  40930. */
  40931. enableClose?: boolean;
  40932. /**
  40933. * Optional list of extensibility entries
  40934. */
  40935. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40936. /**
  40937. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40938. */
  40939. inspectorURL?: string;
  40940. }
  40941. interface Scene {
  40942. /**
  40943. * @hidden
  40944. * Backing field
  40945. */
  40946. _debugLayer: DebugLayer;
  40947. /**
  40948. * Gets the debug layer (aka Inspector) associated with the scene
  40949. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40950. */
  40951. debugLayer: DebugLayer;
  40952. }
  40953. /**
  40954. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40955. * what is happening in your scene
  40956. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40957. */
  40958. export class DebugLayer {
  40959. /**
  40960. * Define the url to get the inspector script from.
  40961. * By default it uses the babylonjs CDN.
  40962. * @ignoreNaming
  40963. */
  40964. static InspectorURL: string;
  40965. private _scene;
  40966. private BJSINSPECTOR;
  40967. /**
  40968. * Observable triggered when a property is changed through the inspector.
  40969. */
  40970. onPropertyChangedObservable: Observable<{
  40971. object: any;
  40972. property: string;
  40973. value: any;
  40974. initialValue: any;
  40975. }>;
  40976. /**
  40977. * Instantiates a new debug layer.
  40978. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40979. * what is happening in your scene
  40980. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40981. * @param scene Defines the scene to inspect
  40982. */
  40983. constructor(scene: Scene);
  40984. /** Creates the inspector window. */
  40985. private _createInspector;
  40986. /**
  40987. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40988. * @param entity defines the entity to select
  40989. * @param lineContainerTitle defines the specific block to highlight
  40990. */
  40991. select(entity: any, lineContainerTitle?: string): void;
  40992. /** Get the inspector from bundle or global */
  40993. private _getGlobalInspector;
  40994. /**
  40995. * Get if the inspector is visible or not.
  40996. * @returns true if visible otherwise, false
  40997. */
  40998. isVisible(): boolean;
  40999. /**
  41000. * Hide the inspector and close its window.
  41001. */
  41002. hide(): void;
  41003. /**
  41004. * Launch the debugLayer.
  41005. * @param config Define the configuration of the inspector
  41006. * @return a promise fulfilled when the debug layer is visible
  41007. */
  41008. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41009. }
  41010. }
  41011. declare module BABYLON {
  41012. /**
  41013. * Class containing static functions to help procedurally build meshes
  41014. */
  41015. export class BoxBuilder {
  41016. /**
  41017. * Creates a box mesh
  41018. * * The parameter `size` sets the size (float) of each box side (default 1)
  41019. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41020. * * 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)
  41021. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41023. * * 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
  41024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41025. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41026. * @param name defines the name of the mesh
  41027. * @param options defines the options used to create the mesh
  41028. * @param scene defines the hosting scene
  41029. * @returns the box mesh
  41030. */
  41031. static CreateBox(name: string, options: {
  41032. size?: number;
  41033. width?: number;
  41034. height?: number;
  41035. depth?: number;
  41036. faceUV?: Vector4[];
  41037. faceColors?: Color4[];
  41038. sideOrientation?: number;
  41039. frontUVs?: Vector4;
  41040. backUVs?: Vector4;
  41041. wrap?: boolean;
  41042. topBaseAt?: number;
  41043. bottomBaseAt?: number;
  41044. updatable?: boolean;
  41045. }, scene?: Nullable<Scene>): Mesh;
  41046. }
  41047. }
  41048. declare module BABYLON {
  41049. /**
  41050. * Class containing static functions to help procedurally build meshes
  41051. */
  41052. export class SphereBuilder {
  41053. /**
  41054. * Creates a sphere mesh
  41055. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41056. * * 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`)
  41057. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41058. * * 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
  41059. * * 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)
  41060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41061. * * 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
  41062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41063. * @param name defines the name of the mesh
  41064. * @param options defines the options used to create the mesh
  41065. * @param scene defines the hosting scene
  41066. * @returns the sphere mesh
  41067. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41068. */
  41069. static CreateSphere(name: string, options: {
  41070. segments?: number;
  41071. diameter?: number;
  41072. diameterX?: number;
  41073. diameterY?: number;
  41074. diameterZ?: number;
  41075. arc?: number;
  41076. slice?: number;
  41077. sideOrientation?: number;
  41078. frontUVs?: Vector4;
  41079. backUVs?: Vector4;
  41080. updatable?: boolean;
  41081. }, scene: any): Mesh;
  41082. }
  41083. }
  41084. declare module BABYLON.Debug {
  41085. /**
  41086. * Used to show the physics impostor around the specific mesh
  41087. */
  41088. export class PhysicsViewer {
  41089. /** @hidden */
  41090. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41091. /** @hidden */
  41092. protected _meshes: Array<Nullable<AbstractMesh>>;
  41093. /** @hidden */
  41094. protected _scene: Nullable<Scene>;
  41095. /** @hidden */
  41096. protected _numMeshes: number;
  41097. /** @hidden */
  41098. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41099. private _renderFunction;
  41100. private _utilityLayer;
  41101. private _debugBoxMesh;
  41102. private _debugSphereMesh;
  41103. private _debugCylinderMesh;
  41104. private _debugMaterial;
  41105. private _debugMeshMeshes;
  41106. /**
  41107. * Creates a new PhysicsViewer
  41108. * @param scene defines the hosting scene
  41109. */
  41110. constructor(scene: Scene);
  41111. /** @hidden */
  41112. protected _updateDebugMeshes(): void;
  41113. /**
  41114. * Renders a specified physic impostor
  41115. * @param impostor defines the impostor to render
  41116. * @param targetMesh defines the mesh represented by the impostor
  41117. * @returns the new debug mesh used to render the impostor
  41118. */
  41119. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41120. /**
  41121. * Hides a specified physic impostor
  41122. * @param impostor defines the impostor to hide
  41123. */
  41124. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41125. private _getDebugMaterial;
  41126. private _getDebugBoxMesh;
  41127. private _getDebugSphereMesh;
  41128. private _getDebugCylinderMesh;
  41129. private _getDebugMeshMesh;
  41130. private _getDebugMesh;
  41131. /** Releases all resources */
  41132. dispose(): void;
  41133. }
  41134. }
  41135. declare module BABYLON {
  41136. /**
  41137. * Class containing static functions to help procedurally build meshes
  41138. */
  41139. export class LinesBuilder {
  41140. /**
  41141. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41142. * * 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
  41143. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41144. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41145. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41146. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41147. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41148. * * 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
  41149. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41151. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41152. * @param name defines the name of the new line system
  41153. * @param options defines the options used to create the line system
  41154. * @param scene defines the hosting scene
  41155. * @returns a new line system mesh
  41156. */
  41157. static CreateLineSystem(name: string, options: {
  41158. lines: Vector3[][];
  41159. updatable?: boolean;
  41160. instance?: Nullable<LinesMesh>;
  41161. colors?: Nullable<Color4[][]>;
  41162. useVertexAlpha?: boolean;
  41163. }, scene: Nullable<Scene>): LinesMesh;
  41164. /**
  41165. * Creates a line mesh
  41166. * 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
  41167. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41168. * * The parameter `points` is an array successive Vector3
  41169. * * 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
  41170. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41171. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41172. * * When updating an instance, remember that only point positions can change, not the number of points
  41173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41175. * @param name defines the name of the new line system
  41176. * @param options defines the options used to create the line system
  41177. * @param scene defines the hosting scene
  41178. * @returns a new line mesh
  41179. */
  41180. static CreateLines(name: string, options: {
  41181. points: Vector3[];
  41182. updatable?: boolean;
  41183. instance?: Nullable<LinesMesh>;
  41184. colors?: Color4[];
  41185. useVertexAlpha?: boolean;
  41186. }, scene?: Nullable<Scene>): LinesMesh;
  41187. /**
  41188. * Creates a dashed line mesh
  41189. * * 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
  41190. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41191. * * The parameter `points` is an array successive Vector3
  41192. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41193. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41194. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41195. * * 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
  41196. * * When updating an instance, remember that only point positions can change, not the number of points
  41197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41198. * @param name defines the name of the mesh
  41199. * @param options defines the options used to create the mesh
  41200. * @param scene defines the hosting scene
  41201. * @returns the dashed line mesh
  41202. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41203. */
  41204. static CreateDashedLines(name: string, options: {
  41205. points: Vector3[];
  41206. dashSize?: number;
  41207. gapSize?: number;
  41208. dashNb?: number;
  41209. updatable?: boolean;
  41210. instance?: LinesMesh;
  41211. }, scene?: Nullable<Scene>): LinesMesh;
  41212. }
  41213. }
  41214. declare module BABYLON {
  41215. /**
  41216. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41217. * in order to better appreciate the issue one might have.
  41218. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41219. */
  41220. export class RayHelper {
  41221. /**
  41222. * Defines the ray we are currently tryin to visualize.
  41223. */
  41224. ray: Nullable<Ray>;
  41225. private _renderPoints;
  41226. private _renderLine;
  41227. private _renderFunction;
  41228. private _scene;
  41229. private _updateToMeshFunction;
  41230. private _attachedToMesh;
  41231. private _meshSpaceDirection;
  41232. private _meshSpaceOrigin;
  41233. /**
  41234. * Helper function to create a colored helper in a scene in one line.
  41235. * @param ray Defines the ray we are currently tryin to visualize
  41236. * @param scene Defines the scene the ray is used in
  41237. * @param color Defines the color we want to see the ray in
  41238. * @returns The newly created ray helper.
  41239. */
  41240. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41241. /**
  41242. * Instantiate a new ray helper.
  41243. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41244. * in order to better appreciate the issue one might have.
  41245. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41246. * @param ray Defines the ray we are currently tryin to visualize
  41247. */
  41248. constructor(ray: Ray);
  41249. /**
  41250. * Shows the ray we are willing to debug.
  41251. * @param scene Defines the scene the ray needs to be rendered in
  41252. * @param color Defines the color the ray needs to be rendered in
  41253. */
  41254. show(scene: Scene, color?: Color3): void;
  41255. /**
  41256. * Hides the ray we are debugging.
  41257. */
  41258. hide(): void;
  41259. private _render;
  41260. /**
  41261. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41262. * @param mesh Defines the mesh we want the helper attached to
  41263. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41264. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41265. * @param length Defines the length of the ray
  41266. */
  41267. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41268. /**
  41269. * Detach the ray helper from the mesh it has previously been attached to.
  41270. */
  41271. detachFromMesh(): void;
  41272. private _updateToMesh;
  41273. /**
  41274. * Dispose the helper and release its associated resources.
  41275. */
  41276. dispose(): void;
  41277. }
  41278. }
  41279. declare module BABYLON.Debug {
  41280. /**
  41281. * Class used to render a debug view of a given skeleton
  41282. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41283. */
  41284. export class SkeletonViewer {
  41285. /** defines the skeleton to render */
  41286. skeleton: Skeleton;
  41287. /** defines the mesh attached to the skeleton */
  41288. mesh: AbstractMesh;
  41289. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41290. autoUpdateBonesMatrices: boolean;
  41291. /** defines the rendering group id to use with the viewer */
  41292. renderingGroupId: number;
  41293. /** Gets or sets the color used to render the skeleton */
  41294. color: Color3;
  41295. private _scene;
  41296. private _debugLines;
  41297. private _debugMesh;
  41298. private _isEnabled;
  41299. private _renderFunction;
  41300. private _utilityLayer;
  41301. /**
  41302. * Returns the mesh used to render the bones
  41303. */
  41304. readonly debugMesh: Nullable<LinesMesh>;
  41305. /**
  41306. * Creates a new SkeletonViewer
  41307. * @param skeleton defines the skeleton to render
  41308. * @param mesh defines the mesh attached to the skeleton
  41309. * @param scene defines the hosting scene
  41310. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41311. * @param renderingGroupId defines the rendering group id to use with the viewer
  41312. */
  41313. constructor(
  41314. /** defines the skeleton to render */
  41315. skeleton: Skeleton,
  41316. /** defines the mesh attached to the skeleton */
  41317. mesh: AbstractMesh, scene: Scene,
  41318. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41319. autoUpdateBonesMatrices?: boolean,
  41320. /** defines the rendering group id to use with the viewer */
  41321. renderingGroupId?: number);
  41322. /** Gets or sets a boolean indicating if the viewer is enabled */
  41323. isEnabled: boolean;
  41324. private _getBonePosition;
  41325. private _getLinesForBonesWithLength;
  41326. private _getLinesForBonesNoLength;
  41327. /** Update the viewer to sync with current skeleton state */
  41328. update(): void;
  41329. /** Release associated resources */
  41330. dispose(): void;
  41331. }
  41332. }
  41333. declare module BABYLON {
  41334. /**
  41335. * Options to create the null engine
  41336. */
  41337. export class NullEngineOptions {
  41338. /**
  41339. * Render width (Default: 512)
  41340. */
  41341. renderWidth: number;
  41342. /**
  41343. * Render height (Default: 256)
  41344. */
  41345. renderHeight: number;
  41346. /**
  41347. * Texture size (Default: 512)
  41348. */
  41349. textureSize: number;
  41350. /**
  41351. * If delta time between frames should be constant
  41352. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41353. */
  41354. deterministicLockstep: boolean;
  41355. /**
  41356. * Maximum about of steps between frames (Default: 4)
  41357. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41358. */
  41359. lockstepMaxSteps: number;
  41360. }
  41361. /**
  41362. * The null engine class provides support for headless version of babylon.js.
  41363. * This can be used in server side scenario or for testing purposes
  41364. */
  41365. export class NullEngine extends Engine {
  41366. private _options;
  41367. /**
  41368. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41369. */
  41370. isDeterministicLockStep(): boolean;
  41371. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41372. getLockstepMaxSteps(): number;
  41373. /**
  41374. * Sets hardware scaling, used to save performance if needed
  41375. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41376. */
  41377. getHardwareScalingLevel(): number;
  41378. constructor(options?: NullEngineOptions);
  41379. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41380. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41381. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41382. getRenderWidth(useScreen?: boolean): number;
  41383. getRenderHeight(useScreen?: boolean): number;
  41384. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41385. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41386. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41387. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41388. bindSamplers(effect: Effect): void;
  41389. enableEffect(effect: Effect): void;
  41390. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41391. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41392. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41393. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41394. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41395. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41396. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41397. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41398. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41399. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41400. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41401. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41402. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41403. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41404. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41405. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41406. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41407. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41408. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41409. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41410. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41411. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41412. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41413. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41414. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41415. bindBuffers(vertexBuffers: {
  41416. [key: string]: VertexBuffer;
  41417. }, indexBuffer: DataBuffer, effect: Effect): void;
  41418. wipeCaches(bruteForce?: boolean): void;
  41419. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41420. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41421. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41422. /** @hidden */
  41423. _createTexture(): WebGLTexture;
  41424. /** @hidden */
  41425. _releaseTexture(texture: InternalTexture): void;
  41426. 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;
  41427. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41428. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41429. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41430. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41431. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  41432. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41433. areAllEffectsReady(): boolean;
  41434. /**
  41435. * @hidden
  41436. * Get the current error code of the webGL context
  41437. * @returns the error code
  41438. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41439. */
  41440. getError(): number;
  41441. /** @hidden */
  41442. _getUnpackAlignement(): number;
  41443. /** @hidden */
  41444. _unpackFlipY(value: boolean): void;
  41445. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41446. /**
  41447. * Updates a dynamic vertex buffer.
  41448. * @param vertexBuffer the vertex buffer to update
  41449. * @param data the data used to update the vertex buffer
  41450. * @param byteOffset the byte offset of the data (optional)
  41451. * @param byteLength the byte length of the data (optional)
  41452. */
  41453. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41454. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41455. /** @hidden */
  41456. _bindTexture(channel: number, texture: InternalTexture): void;
  41457. /** @hidden */
  41458. _releaseBuffer(buffer: DataBuffer): boolean;
  41459. releaseEffects(): void;
  41460. displayLoadingUI(): void;
  41461. hideLoadingUI(): void;
  41462. /** @hidden */
  41463. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41464. /** @hidden */
  41465. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41466. /** @hidden */
  41467. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41468. /** @hidden */
  41469. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41470. }
  41471. }
  41472. declare module BABYLON {
  41473. /** @hidden */
  41474. export class _OcclusionDataStorage {
  41475. /** @hidden */
  41476. occlusionInternalRetryCounter: number;
  41477. /** @hidden */
  41478. isOcclusionQueryInProgress: boolean;
  41479. /** @hidden */
  41480. isOccluded: boolean;
  41481. /** @hidden */
  41482. occlusionRetryCount: number;
  41483. /** @hidden */
  41484. occlusionType: number;
  41485. /** @hidden */
  41486. occlusionQueryAlgorithmType: number;
  41487. }
  41488. interface Engine {
  41489. /**
  41490. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41491. * @return the new query
  41492. */
  41493. createQuery(): WebGLQuery;
  41494. /**
  41495. * Delete and release a webGL query
  41496. * @param query defines the query to delete
  41497. * @return the current engine
  41498. */
  41499. deleteQuery(query: WebGLQuery): Engine;
  41500. /**
  41501. * Check if a given query has resolved and got its value
  41502. * @param query defines the query to check
  41503. * @returns true if the query got its value
  41504. */
  41505. isQueryResultAvailable(query: WebGLQuery): boolean;
  41506. /**
  41507. * Gets the value of a given query
  41508. * @param query defines the query to check
  41509. * @returns the value of the query
  41510. */
  41511. getQueryResult(query: WebGLQuery): number;
  41512. /**
  41513. * Initiates an occlusion query
  41514. * @param algorithmType defines the algorithm to use
  41515. * @param query defines the query to use
  41516. * @returns the current engine
  41517. * @see http://doc.babylonjs.com/features/occlusionquery
  41518. */
  41519. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41520. /**
  41521. * Ends an occlusion query
  41522. * @see http://doc.babylonjs.com/features/occlusionquery
  41523. * @param algorithmType defines the algorithm to use
  41524. * @returns the current engine
  41525. */
  41526. endOcclusionQuery(algorithmType: number): Engine;
  41527. /**
  41528. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41529. * Please note that only one query can be issued at a time
  41530. * @returns a time token used to track the time span
  41531. */
  41532. startTimeQuery(): Nullable<_TimeToken>;
  41533. /**
  41534. * Ends a time query
  41535. * @param token defines the token used to measure the time span
  41536. * @returns the time spent (in ns)
  41537. */
  41538. endTimeQuery(token: _TimeToken): int;
  41539. /** @hidden */
  41540. _currentNonTimestampToken: Nullable<_TimeToken>;
  41541. /** @hidden */
  41542. _createTimeQuery(): WebGLQuery;
  41543. /** @hidden */
  41544. _deleteTimeQuery(query: WebGLQuery): void;
  41545. /** @hidden */
  41546. _getGlAlgorithmType(algorithmType: number): number;
  41547. /** @hidden */
  41548. _getTimeQueryResult(query: WebGLQuery): any;
  41549. /** @hidden */
  41550. _getTimeQueryAvailability(query: WebGLQuery): any;
  41551. }
  41552. interface AbstractMesh {
  41553. /**
  41554. * Backing filed
  41555. * @hidden
  41556. */
  41557. __occlusionDataStorage: _OcclusionDataStorage;
  41558. /**
  41559. * Access property
  41560. * @hidden
  41561. */
  41562. _occlusionDataStorage: _OcclusionDataStorage;
  41563. /**
  41564. * 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.
  41565. * The default value is -1 which means don't break the query and wait till the result
  41566. * @see http://doc.babylonjs.com/features/occlusionquery
  41567. */
  41568. occlusionRetryCount: number;
  41569. /**
  41570. * 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:
  41571. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41572. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41573. * * 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.
  41574. * @see http://doc.babylonjs.com/features/occlusionquery
  41575. */
  41576. occlusionType: number;
  41577. /**
  41578. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41579. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41580. * * 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.
  41581. * @see http://doc.babylonjs.com/features/occlusionquery
  41582. */
  41583. occlusionQueryAlgorithmType: number;
  41584. /**
  41585. * 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
  41586. * @see http://doc.babylonjs.com/features/occlusionquery
  41587. */
  41588. isOccluded: boolean;
  41589. /**
  41590. * Flag to check the progress status of the query
  41591. * @see http://doc.babylonjs.com/features/occlusionquery
  41592. */
  41593. isOcclusionQueryInProgress: boolean;
  41594. }
  41595. }
  41596. declare module BABYLON {
  41597. /** @hidden */
  41598. export var _forceTransformFeedbackToBundle: boolean;
  41599. interface Engine {
  41600. /**
  41601. * Creates a webGL transform feedback object
  41602. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41603. * @returns the webGL transform feedback object
  41604. */
  41605. createTransformFeedback(): WebGLTransformFeedback;
  41606. /**
  41607. * Delete a webGL transform feedback object
  41608. * @param value defines the webGL transform feedback object to delete
  41609. */
  41610. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41611. /**
  41612. * Bind a webGL transform feedback object to the webgl context
  41613. * @param value defines the webGL transform feedback object to bind
  41614. */
  41615. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41616. /**
  41617. * Begins a transform feedback operation
  41618. * @param usePoints defines if points or triangles must be used
  41619. */
  41620. beginTransformFeedback(usePoints: boolean): void;
  41621. /**
  41622. * Ends a transform feedback operation
  41623. */
  41624. endTransformFeedback(): void;
  41625. /**
  41626. * Specify the varyings to use with transform feedback
  41627. * @param program defines the associated webGL program
  41628. * @param value defines the list of strings representing the varying names
  41629. */
  41630. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41631. /**
  41632. * Bind a webGL buffer for a transform feedback operation
  41633. * @param value defines the webGL buffer to bind
  41634. */
  41635. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  41636. }
  41637. }
  41638. declare module BABYLON {
  41639. /**
  41640. * Creation options of the multi render target texture.
  41641. */
  41642. export interface IMultiRenderTargetOptions {
  41643. /**
  41644. * Define if the texture needs to create mip maps after render.
  41645. */
  41646. generateMipMaps?: boolean;
  41647. /**
  41648. * Define the types of all the draw buffers we want to create
  41649. */
  41650. types?: number[];
  41651. /**
  41652. * Define the sampling modes of all the draw buffers we want to create
  41653. */
  41654. samplingModes?: number[];
  41655. /**
  41656. * Define if a depth buffer is required
  41657. */
  41658. generateDepthBuffer?: boolean;
  41659. /**
  41660. * Define if a stencil buffer is required
  41661. */
  41662. generateStencilBuffer?: boolean;
  41663. /**
  41664. * Define if a depth texture is required instead of a depth buffer
  41665. */
  41666. generateDepthTexture?: boolean;
  41667. /**
  41668. * Define the number of desired draw buffers
  41669. */
  41670. textureCount?: number;
  41671. /**
  41672. * Define if aspect ratio should be adapted to the texture or stay the scene one
  41673. */
  41674. doNotChangeAspectRatio?: boolean;
  41675. /**
  41676. * Define the default type of the buffers we are creating
  41677. */
  41678. defaultType?: number;
  41679. }
  41680. /**
  41681. * A multi render target, like a render target provides the ability to render to a texture.
  41682. * Unlike the render target, it can render to several draw buffers in one draw.
  41683. * This is specially interesting in deferred rendering or for any effects requiring more than
  41684. * just one color from a single pass.
  41685. */
  41686. export class MultiRenderTarget extends RenderTargetTexture {
  41687. private _internalTextures;
  41688. private _textures;
  41689. private _multiRenderTargetOptions;
  41690. /**
  41691. * Get if draw buffers are currently supported by the used hardware and browser.
  41692. */
  41693. readonly isSupported: boolean;
  41694. /**
  41695. * Get the list of textures generated by the multi render target.
  41696. */
  41697. readonly textures: Texture[];
  41698. /**
  41699. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  41700. */
  41701. readonly depthTexture: Texture;
  41702. /**
  41703. * Set the wrapping mode on U of all the textures we are rendering to.
  41704. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41705. */
  41706. wrapU: number;
  41707. /**
  41708. * Set the wrapping mode on V of all the textures we are rendering to.
  41709. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41710. */
  41711. wrapV: number;
  41712. /**
  41713. * Instantiate a new multi render target texture.
  41714. * A multi render target, like a render target provides the ability to render to a texture.
  41715. * Unlike the render target, it can render to several draw buffers in one draw.
  41716. * This is specially interesting in deferred rendering or for any effects requiring more than
  41717. * just one color from a single pass.
  41718. * @param name Define the name of the texture
  41719. * @param size Define the size of the buffers to render to
  41720. * @param count Define the number of target we are rendering into
  41721. * @param scene Define the scene the texture belongs to
  41722. * @param options Define the options used to create the multi render target
  41723. */
  41724. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  41725. /** @hidden */
  41726. _rebuild(): void;
  41727. private _createInternalTextures;
  41728. private _createTextures;
  41729. /**
  41730. * Define the number of samples used if MSAA is enabled.
  41731. */
  41732. samples: number;
  41733. /**
  41734. * Resize all the textures in the multi render target.
  41735. * Be carrefull as it will recreate all the data in the new texture.
  41736. * @param size Define the new size
  41737. */
  41738. resize(size: any): void;
  41739. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41740. /**
  41741. * Dispose the render targets and their associated resources
  41742. */
  41743. dispose(): void;
  41744. /**
  41745. * Release all the underlying texture used as draw buffers.
  41746. */
  41747. releaseInternalTextures(): void;
  41748. }
  41749. }
  41750. declare module BABYLON {
  41751. interface Engine {
  41752. /**
  41753. * Unbind a list of render target textures from the webGL context
  41754. * This is used only when drawBuffer extension or webGL2 are active
  41755. * @param textures defines the render target textures to unbind
  41756. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41757. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41758. */
  41759. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41760. /**
  41761. * Create a multi render target texture
  41762. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41763. * @param size defines the size of the texture
  41764. * @param options defines the creation options
  41765. * @returns the cube texture as an InternalTexture
  41766. */
  41767. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41768. /**
  41769. * Update the sample count for a given multiple render target texture
  41770. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41771. * @param textures defines the textures to update
  41772. * @param samples defines the sample count to set
  41773. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41774. */
  41775. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41776. }
  41777. }
  41778. declare module BABYLON {
  41779. /**
  41780. * Gather the list of clipboard event types as constants.
  41781. */
  41782. export class ClipboardEventTypes {
  41783. /**
  41784. * The clipboard event is fired when a copy command is active (pressed).
  41785. */
  41786. static readonly COPY: number;
  41787. /**
  41788. * The clipboard event is fired when a cut command is active (pressed).
  41789. */
  41790. static readonly CUT: number;
  41791. /**
  41792. * The clipboard event is fired when a paste command is active (pressed).
  41793. */
  41794. static readonly PASTE: number;
  41795. }
  41796. /**
  41797. * This class is used to store clipboard related info for the onClipboardObservable event.
  41798. */
  41799. export class ClipboardInfo {
  41800. /**
  41801. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41802. */
  41803. type: number;
  41804. /**
  41805. * Defines the related dom event
  41806. */
  41807. event: ClipboardEvent;
  41808. /**
  41809. *Creates an instance of ClipboardInfo.
  41810. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41811. * @param event Defines the related dom event
  41812. */
  41813. constructor(
  41814. /**
  41815. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41816. */
  41817. type: number,
  41818. /**
  41819. * Defines the related dom event
  41820. */
  41821. event: ClipboardEvent);
  41822. /**
  41823. * Get the clipboard event's type from the keycode.
  41824. * @param keyCode Defines the keyCode for the current keyboard event.
  41825. * @return {number}
  41826. */
  41827. static GetTypeFromCharacter(keyCode: number): number;
  41828. }
  41829. }
  41830. declare module BABYLON {
  41831. /**
  41832. * Class used to represent data loading progression
  41833. */
  41834. export class SceneLoaderProgressEvent {
  41835. /** defines if data length to load can be evaluated */
  41836. readonly lengthComputable: boolean;
  41837. /** defines the loaded data length */
  41838. readonly loaded: number;
  41839. /** defines the data length to load */
  41840. readonly total: number;
  41841. /**
  41842. * Create a new progress event
  41843. * @param lengthComputable defines if data length to load can be evaluated
  41844. * @param loaded defines the loaded data length
  41845. * @param total defines the data length to load
  41846. */
  41847. constructor(
  41848. /** defines if data length to load can be evaluated */
  41849. lengthComputable: boolean,
  41850. /** defines the loaded data length */
  41851. loaded: number,
  41852. /** defines the data length to load */
  41853. total: number);
  41854. /**
  41855. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41856. * @param event defines the source event
  41857. * @returns a new SceneLoaderProgressEvent
  41858. */
  41859. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41860. }
  41861. /**
  41862. * Interface used by SceneLoader plugins to define supported file extensions
  41863. */
  41864. export interface ISceneLoaderPluginExtensions {
  41865. /**
  41866. * Defines the list of supported extensions
  41867. */
  41868. [extension: string]: {
  41869. isBinary: boolean;
  41870. };
  41871. }
  41872. /**
  41873. * Interface used by SceneLoader plugin factory
  41874. */
  41875. export interface ISceneLoaderPluginFactory {
  41876. /**
  41877. * Defines the name of the factory
  41878. */
  41879. name: string;
  41880. /**
  41881. * Function called to create a new plugin
  41882. * @return the new plugin
  41883. */
  41884. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41885. /**
  41886. * Boolean indicating if the plugin can direct load specific data
  41887. */
  41888. canDirectLoad?: (data: string) => boolean;
  41889. }
  41890. /**
  41891. * Interface used to define a SceneLoader plugin
  41892. */
  41893. export interface ISceneLoaderPlugin {
  41894. /**
  41895. * The friendly name of this plugin.
  41896. */
  41897. name: string;
  41898. /**
  41899. * The file extensions supported by this plugin.
  41900. */
  41901. extensions: string | ISceneLoaderPluginExtensions;
  41902. /**
  41903. * Import meshes into a scene.
  41904. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41905. * @param scene The scene to import into
  41906. * @param data The data to import
  41907. * @param rootUrl The root url for scene and resources
  41908. * @param meshes The meshes array to import into
  41909. * @param particleSystems The particle systems array to import into
  41910. * @param skeletons The skeletons array to import into
  41911. * @param onError The callback when import fails
  41912. * @returns True if successful or false otherwise
  41913. */
  41914. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41915. /**
  41916. * Load into a scene.
  41917. * @param scene The scene to load into
  41918. * @param data The data to import
  41919. * @param rootUrl The root url for scene and resources
  41920. * @param onError The callback when import fails
  41921. * @returns true if successful or false otherwise
  41922. */
  41923. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41924. /**
  41925. * The callback that returns true if the data can be directly loaded.
  41926. */
  41927. canDirectLoad?: (data: string) => boolean;
  41928. /**
  41929. * The callback that allows custom handling of the root url based on the response url.
  41930. */
  41931. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41932. /**
  41933. * Load into an asset container.
  41934. * @param scene The scene to load into
  41935. * @param data The data to import
  41936. * @param rootUrl The root url for scene and resources
  41937. * @param onError The callback when import fails
  41938. * @returns The loaded asset container
  41939. */
  41940. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41941. }
  41942. /**
  41943. * Interface used to define an async SceneLoader plugin
  41944. */
  41945. export interface ISceneLoaderPluginAsync {
  41946. /**
  41947. * The friendly name of this plugin.
  41948. */
  41949. name: string;
  41950. /**
  41951. * The file extensions supported by this plugin.
  41952. */
  41953. extensions: string | ISceneLoaderPluginExtensions;
  41954. /**
  41955. * Import meshes into a scene.
  41956. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41957. * @param scene The scene to import into
  41958. * @param data The data to import
  41959. * @param rootUrl The root url for scene and resources
  41960. * @param onProgress The callback when the load progresses
  41961. * @param fileName Defines the name of the file to load
  41962. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41963. */
  41964. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41965. meshes: AbstractMesh[];
  41966. particleSystems: IParticleSystem[];
  41967. skeletons: Skeleton[];
  41968. animationGroups: AnimationGroup[];
  41969. }>;
  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 onProgress The callback when the load progresses
  41976. * @param fileName Defines the name of the file to load
  41977. * @returns Nothing
  41978. */
  41979. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41980. /**
  41981. * The callback that returns true if the data can be directly loaded.
  41982. */
  41983. canDirectLoad?: (data: string) => boolean;
  41984. /**
  41985. * The callback that allows custom handling of the root url based on the response url.
  41986. */
  41987. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41988. /**
  41989. * Load into an asset container.
  41990. * @param scene The scene to load into
  41991. * @param data The data to import
  41992. * @param rootUrl The root url for scene and resources
  41993. * @param onProgress The callback when the load progresses
  41994. * @param fileName Defines the name of the file to load
  41995. * @returns The loaded asset container
  41996. */
  41997. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41998. }
  41999. /**
  42000. * Class used to load scene from various file formats using registered plugins
  42001. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42002. */
  42003. export class SceneLoader {
  42004. /**
  42005. * No logging while loading
  42006. */
  42007. static readonly NO_LOGGING: number;
  42008. /**
  42009. * Minimal logging while loading
  42010. */
  42011. static readonly MINIMAL_LOGGING: number;
  42012. /**
  42013. * Summary logging while loading
  42014. */
  42015. static readonly SUMMARY_LOGGING: number;
  42016. /**
  42017. * Detailled logging while loading
  42018. */
  42019. static readonly DETAILED_LOGGING: number;
  42020. /**
  42021. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42022. */
  42023. static ForceFullSceneLoadingForIncremental: boolean;
  42024. /**
  42025. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42026. */
  42027. static ShowLoadingScreen: boolean;
  42028. /**
  42029. * Defines the current logging level (while loading the scene)
  42030. * @ignorenaming
  42031. */
  42032. static loggingLevel: number;
  42033. /**
  42034. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42035. */
  42036. static CleanBoneMatrixWeights: boolean;
  42037. /**
  42038. * Event raised when a plugin is used to load a scene
  42039. */
  42040. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42041. private static _registeredPlugins;
  42042. private static _getDefaultPlugin;
  42043. private static _getPluginForExtension;
  42044. private static _getPluginForDirectLoad;
  42045. private static _getPluginForFilename;
  42046. private static _getDirectLoad;
  42047. private static _loadData;
  42048. private static _getFileInfo;
  42049. /**
  42050. * Gets a plugin that can load the given extension
  42051. * @param extension defines the extension to load
  42052. * @returns a plugin or null if none works
  42053. */
  42054. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42055. /**
  42056. * Gets a boolean indicating that the given extension can be loaded
  42057. * @param extension defines the extension to load
  42058. * @returns true if the extension is supported
  42059. */
  42060. static IsPluginForExtensionAvailable(extension: string): boolean;
  42061. /**
  42062. * Adds a new plugin to the list of registered plugins
  42063. * @param plugin defines the plugin to add
  42064. */
  42065. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42066. /**
  42067. * Import meshes into a scene
  42068. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42069. * @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)
  42070. * @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)
  42071. * @param scene the instance of BABYLON.Scene to append to
  42072. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42073. * @param onProgress a callback with a progress event for each file being loaded
  42074. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42075. * @param pluginExtension the extension used to determine the plugin
  42076. * @returns The loaded plugin
  42077. */
  42078. 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>;
  42079. /**
  42080. * Import meshes into a scene
  42081. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42082. * @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)
  42083. * @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)
  42084. * @param scene the instance of BABYLON.Scene to append to
  42085. * @param onProgress a callback with a progress event for each file being loaded
  42086. * @param pluginExtension the extension used to determine the plugin
  42087. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42088. */
  42089. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42090. meshes: AbstractMesh[];
  42091. particleSystems: IParticleSystem[];
  42092. skeletons: Skeleton[];
  42093. animationGroups: AnimationGroup[];
  42094. }>;
  42095. /**
  42096. * Load a scene
  42097. * @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)
  42098. * @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)
  42099. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42100. * @param onSuccess a callback with the scene when import succeeds
  42101. * @param onProgress a callback with a progress event for each file being loaded
  42102. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42103. * @param pluginExtension the extension used to determine the plugin
  42104. * @returns The loaded plugin
  42105. */
  42106. 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>;
  42107. /**
  42108. * Load a scene
  42109. * @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)
  42110. * @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)
  42111. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42112. * @param onProgress a callback with a progress event for each file being loaded
  42113. * @param pluginExtension the extension used to determine the plugin
  42114. * @returns The loaded scene
  42115. */
  42116. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42117. /**
  42118. * Append a scene
  42119. * @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)
  42120. * @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)
  42121. * @param scene is the instance of BABYLON.Scene to append to
  42122. * @param onSuccess a callback with the scene when import succeeds
  42123. * @param onProgress a callback with a progress event for each file being loaded
  42124. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42125. * @param pluginExtension the extension used to determine the plugin
  42126. * @returns The loaded plugin
  42127. */
  42128. 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>;
  42129. /**
  42130. * Append a scene
  42131. * @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)
  42132. * @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)
  42133. * @param scene is the instance of BABYLON.Scene to append to
  42134. * @param onProgress a callback with a progress event for each file being loaded
  42135. * @param pluginExtension the extension used to determine the plugin
  42136. * @returns The given scene
  42137. */
  42138. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42139. /**
  42140. * Load a scene into an asset container
  42141. * @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)
  42142. * @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)
  42143. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42144. * @param onSuccess a callback with the scene when import succeeds
  42145. * @param onProgress a callback with a progress event for each file being loaded
  42146. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42147. * @param pluginExtension the extension used to determine the plugin
  42148. * @returns The loaded plugin
  42149. */
  42150. 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>;
  42151. /**
  42152. * Load a scene into an asset container
  42153. * @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)
  42154. * @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)
  42155. * @param scene is the instance of Scene to append to
  42156. * @param onProgress a callback with a progress event for each file being loaded
  42157. * @param pluginExtension the extension used to determine the plugin
  42158. * @returns The loaded asset container
  42159. */
  42160. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42161. }
  42162. }
  42163. declare module BABYLON {
  42164. /**
  42165. * Google Daydream controller
  42166. */
  42167. export class DaydreamController extends WebVRController {
  42168. /**
  42169. * Base Url for the controller model.
  42170. */
  42171. static MODEL_BASE_URL: string;
  42172. /**
  42173. * File name for the controller model.
  42174. */
  42175. static MODEL_FILENAME: string;
  42176. /**
  42177. * Gamepad Id prefix used to identify Daydream Controller.
  42178. */
  42179. static readonly GAMEPAD_ID_PREFIX: string;
  42180. /**
  42181. * Creates a new DaydreamController from a gamepad
  42182. * @param vrGamepad the gamepad that the controller should be created from
  42183. */
  42184. constructor(vrGamepad: any);
  42185. /**
  42186. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42187. * @param scene scene in which to add meshes
  42188. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42189. */
  42190. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42191. /**
  42192. * Called once for each button that changed state since the last frame
  42193. * @param buttonIdx Which button index changed
  42194. * @param state New state of the button
  42195. * @param changes Which properties on the state changed since last frame
  42196. */
  42197. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42198. }
  42199. }
  42200. declare module BABYLON {
  42201. /**
  42202. * Gear VR Controller
  42203. */
  42204. export class GearVRController extends WebVRController {
  42205. /**
  42206. * Base Url for the controller model.
  42207. */
  42208. static MODEL_BASE_URL: string;
  42209. /**
  42210. * File name for the controller model.
  42211. */
  42212. static MODEL_FILENAME: string;
  42213. /**
  42214. * Gamepad Id prefix used to identify this controller.
  42215. */
  42216. static readonly GAMEPAD_ID_PREFIX: string;
  42217. private readonly _buttonIndexToObservableNameMap;
  42218. /**
  42219. * Creates a new GearVRController from a gamepad
  42220. * @param vrGamepad the gamepad that the controller should be created from
  42221. */
  42222. constructor(vrGamepad: any);
  42223. /**
  42224. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42225. * @param scene scene in which to add meshes
  42226. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42227. */
  42228. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42229. /**
  42230. * Called once for each button that changed state since the last frame
  42231. * @param buttonIdx Which button index changed
  42232. * @param state New state of the button
  42233. * @param changes Which properties on the state changed since last frame
  42234. */
  42235. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42236. }
  42237. }
  42238. declare module BABYLON {
  42239. /**
  42240. * Generic Controller
  42241. */
  42242. export class GenericController extends WebVRController {
  42243. /**
  42244. * Base Url for the controller model.
  42245. */
  42246. static readonly MODEL_BASE_URL: string;
  42247. /**
  42248. * File name for the controller model.
  42249. */
  42250. static readonly MODEL_FILENAME: string;
  42251. /**
  42252. * Creates a new GenericController from a gamepad
  42253. * @param vrGamepad the gamepad that the controller should be created from
  42254. */
  42255. constructor(vrGamepad: any);
  42256. /**
  42257. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42258. * @param scene scene in which to add meshes
  42259. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42260. */
  42261. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42262. /**
  42263. * Called once for each button that changed state since the last frame
  42264. * @param buttonIdx Which button index changed
  42265. * @param state New state of the button
  42266. * @param changes Which properties on the state changed since last frame
  42267. */
  42268. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42269. }
  42270. }
  42271. declare module BABYLON {
  42272. /**
  42273. * Oculus Touch Controller
  42274. */
  42275. export class OculusTouchController extends WebVRController {
  42276. /**
  42277. * Base Url for the controller model.
  42278. */
  42279. static MODEL_BASE_URL: string;
  42280. /**
  42281. * File name for the left controller model.
  42282. */
  42283. static MODEL_LEFT_FILENAME: string;
  42284. /**
  42285. * File name for the right controller model.
  42286. */
  42287. static MODEL_RIGHT_FILENAME: string;
  42288. /**
  42289. * Fired when the secondary trigger on this controller is modified
  42290. */
  42291. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42292. /**
  42293. * Fired when the thumb rest on this controller is modified
  42294. */
  42295. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42296. /**
  42297. * Creates a new OculusTouchController from a gamepad
  42298. * @param vrGamepad the gamepad that the controller should be created from
  42299. */
  42300. constructor(vrGamepad: any);
  42301. /**
  42302. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42303. * @param scene scene in which to add meshes
  42304. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42305. */
  42306. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42307. /**
  42308. * Fired when the A button on this controller is modified
  42309. */
  42310. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42311. /**
  42312. * Fired when the B button on this controller is modified
  42313. */
  42314. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42315. /**
  42316. * Fired when the X button on this controller is modified
  42317. */
  42318. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42319. /**
  42320. * Fired when the Y button on this controller is modified
  42321. */
  42322. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42323. /**
  42324. * Called once for each button that changed state since the last frame
  42325. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42326. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42327. * 2) secondary trigger (same)
  42328. * 3) A (right) X (left), touch, pressed = value
  42329. * 4) B / Y
  42330. * 5) thumb rest
  42331. * @param buttonIdx Which button index changed
  42332. * @param state New state of the button
  42333. * @param changes Which properties on the state changed since last frame
  42334. */
  42335. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42336. }
  42337. }
  42338. declare module BABYLON {
  42339. /**
  42340. * Vive Controller
  42341. */
  42342. export class ViveController extends WebVRController {
  42343. /**
  42344. * Base Url for the controller model.
  42345. */
  42346. static MODEL_BASE_URL: string;
  42347. /**
  42348. * File name for the controller model.
  42349. */
  42350. static MODEL_FILENAME: string;
  42351. /**
  42352. * Creates a new ViveController 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 left button on this controller is modified
  42364. */
  42365. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42366. /**
  42367. * Fired when the right button on this controller is modified
  42368. */
  42369. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42370. /**
  42371. * Fired when the menu button on this controller is modified
  42372. */
  42373. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42374. /**
  42375. * Called once for each button that changed state since the last frame
  42376. * Vive mapping:
  42377. * 0: touchpad
  42378. * 1: trigger
  42379. * 2: left AND right buttons
  42380. * 3: menu button
  42381. * @param buttonIdx Which button index changed
  42382. * @param state New state of the button
  42383. * @param changes Which properties on the state changed since last frame
  42384. */
  42385. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42386. }
  42387. }
  42388. declare module BABYLON {
  42389. /**
  42390. * Defines the WindowsMotionController object that the state of the windows motion controller
  42391. */
  42392. export class WindowsMotionController extends WebVRController {
  42393. /**
  42394. * The base url used to load the left and right controller models
  42395. */
  42396. static MODEL_BASE_URL: string;
  42397. /**
  42398. * The name of the left controller model file
  42399. */
  42400. static MODEL_LEFT_FILENAME: string;
  42401. /**
  42402. * The name of the right controller model file
  42403. */
  42404. static MODEL_RIGHT_FILENAME: string;
  42405. /**
  42406. * The controller name prefix for this controller type
  42407. */
  42408. static readonly GAMEPAD_ID_PREFIX: string;
  42409. /**
  42410. * The controller id pattern for this controller type
  42411. */
  42412. private static readonly GAMEPAD_ID_PATTERN;
  42413. private _loadedMeshInfo;
  42414. private readonly _mapping;
  42415. /**
  42416. * Fired when the trackpad on this controller is clicked
  42417. */
  42418. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42419. /**
  42420. * Fired when the trackpad on this controller is modified
  42421. */
  42422. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42423. /**
  42424. * The current x and y values of this controller's trackpad
  42425. */
  42426. trackpad: StickValues;
  42427. /**
  42428. * Creates a new WindowsMotionController from a gamepad
  42429. * @param vrGamepad the gamepad that the controller should be created from
  42430. */
  42431. constructor(vrGamepad: any);
  42432. /**
  42433. * Fired when the trigger on this controller is modified
  42434. */
  42435. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42436. /**
  42437. * Fired when the menu button on this controller is modified
  42438. */
  42439. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42440. /**
  42441. * Fired when the grip button on this controller is modified
  42442. */
  42443. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42444. /**
  42445. * Fired when the thumbstick button on this controller is modified
  42446. */
  42447. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42448. /**
  42449. * Fired when the touchpad button on this controller is modified
  42450. */
  42451. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42452. /**
  42453. * Fired when the touchpad values on this controller are modified
  42454. */
  42455. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42456. private _updateTrackpad;
  42457. /**
  42458. * Called once per frame by the engine.
  42459. */
  42460. update(): void;
  42461. /**
  42462. * Called once for each button that changed state since the last frame
  42463. * @param buttonIdx Which button index changed
  42464. * @param state New state of the button
  42465. * @param changes Which properties on the state changed since last frame
  42466. */
  42467. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42468. /**
  42469. * Moves the buttons on the controller mesh based on their current state
  42470. * @param buttonName the name of the button to move
  42471. * @param buttonValue the value of the button which determines the buttons new position
  42472. */
  42473. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42474. /**
  42475. * Moves the axis on the controller mesh based on its current state
  42476. * @param axis the index of the axis
  42477. * @param axisValue the value of the axis which determines the meshes new position
  42478. * @hidden
  42479. */
  42480. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42481. /**
  42482. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42483. * @param scene scene in which to add meshes
  42484. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42485. */
  42486. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42487. /**
  42488. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42489. * can be transformed by button presses and axes values, based on this._mapping.
  42490. *
  42491. * @param scene scene in which the meshes exist
  42492. * @param meshes list of meshes that make up the controller model to process
  42493. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42494. */
  42495. private processModel;
  42496. private createMeshInfo;
  42497. /**
  42498. * Gets the ray of the controller in the direction the controller is pointing
  42499. * @param length the length the resulting ray should be
  42500. * @returns a ray in the direction the controller is pointing
  42501. */
  42502. getForwardRay(length?: number): Ray;
  42503. /**
  42504. * Disposes of the controller
  42505. */
  42506. dispose(): void;
  42507. }
  42508. }
  42509. declare module BABYLON {
  42510. /**
  42511. * Single axis scale gizmo
  42512. */
  42513. export class AxisScaleGizmo extends Gizmo {
  42514. private _coloredMaterial;
  42515. /**
  42516. * Drag behavior responsible for the gizmos dragging interactions
  42517. */
  42518. dragBehavior: PointerDragBehavior;
  42519. private _pointerObserver;
  42520. /**
  42521. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42522. */
  42523. snapDistance: number;
  42524. /**
  42525. * Event that fires each time the gizmo snaps to a new location.
  42526. * * snapDistance is the the change in distance
  42527. */
  42528. onSnapObservable: Observable<{
  42529. snapDistance: number;
  42530. }>;
  42531. /**
  42532. * If the scaling operation should be done on all axis (default: false)
  42533. */
  42534. uniformScaling: boolean;
  42535. /**
  42536. * Creates an AxisScaleGizmo
  42537. * @param gizmoLayer The utility layer the gizmo will be added to
  42538. * @param dragAxis The axis which the gizmo will be able to scale on
  42539. * @param color The color of the gizmo
  42540. */
  42541. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42542. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42543. /**
  42544. * Disposes of the gizmo
  42545. */
  42546. dispose(): void;
  42547. /**
  42548. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42549. * @param mesh The mesh to replace the default mesh of the gizmo
  42550. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42551. */
  42552. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42553. }
  42554. }
  42555. declare module BABYLON {
  42556. /**
  42557. * Bounding box gizmo
  42558. */
  42559. export class BoundingBoxGizmo extends Gizmo {
  42560. private _lineBoundingBox;
  42561. private _rotateSpheresParent;
  42562. private _scaleBoxesParent;
  42563. private _boundingDimensions;
  42564. private _renderObserver;
  42565. private _pointerObserver;
  42566. private _scaleDragSpeed;
  42567. private _tmpQuaternion;
  42568. private _tmpVector;
  42569. private _tmpRotationMatrix;
  42570. /**
  42571. * 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)
  42572. */
  42573. ignoreChildren: boolean;
  42574. /**
  42575. * 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)
  42576. */
  42577. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42578. /**
  42579. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42580. */
  42581. rotationSphereSize: number;
  42582. /**
  42583. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42584. */
  42585. scaleBoxSize: number;
  42586. /**
  42587. * 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)
  42588. */
  42589. fixedDragMeshScreenSize: boolean;
  42590. /**
  42591. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42592. */
  42593. fixedDragMeshScreenSizeDistanceFactor: number;
  42594. /**
  42595. * Fired when a rotation sphere or scale box is dragged
  42596. */
  42597. onDragStartObservable: Observable<{}>;
  42598. /**
  42599. * Fired when a scale box is dragged
  42600. */
  42601. onScaleBoxDragObservable: Observable<{}>;
  42602. /**
  42603. * Fired when a scale box drag is ended
  42604. */
  42605. onScaleBoxDragEndObservable: Observable<{}>;
  42606. /**
  42607. * Fired when a rotation sphere is dragged
  42608. */
  42609. onRotationSphereDragObservable: Observable<{}>;
  42610. /**
  42611. * Fired when a rotation sphere drag is ended
  42612. */
  42613. onRotationSphereDragEndObservable: Observable<{}>;
  42614. /**
  42615. * 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)
  42616. */
  42617. scalePivot: Nullable<Vector3>;
  42618. /**
  42619. * Mesh used as a pivot to rotate the attached mesh
  42620. */
  42621. private _anchorMesh;
  42622. private _existingMeshScale;
  42623. private _dragMesh;
  42624. private pointerDragBehavior;
  42625. private coloredMaterial;
  42626. private hoverColoredMaterial;
  42627. /**
  42628. * Sets the color of the bounding box gizmo
  42629. * @param color the color to set
  42630. */
  42631. setColor(color: Color3): void;
  42632. /**
  42633. * Creates an BoundingBoxGizmo
  42634. * @param gizmoLayer The utility layer the gizmo will be added to
  42635. * @param color The color of the gizmo
  42636. */
  42637. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42638. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42639. private _selectNode;
  42640. /**
  42641. * Updates the bounding box information for the Gizmo
  42642. */
  42643. updateBoundingBox(): void;
  42644. private _updateRotationSpheres;
  42645. private _updateScaleBoxes;
  42646. /**
  42647. * Enables rotation on the specified axis and disables rotation on the others
  42648. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42649. */
  42650. setEnabledRotationAxis(axis: string): void;
  42651. /**
  42652. * Enables/disables scaling
  42653. * @param enable if scaling should be enabled
  42654. */
  42655. setEnabledScaling(enable: boolean): void;
  42656. private _updateDummy;
  42657. /**
  42658. * Enables a pointer drag behavior on the bounding box of the gizmo
  42659. */
  42660. enableDragBehavior(): void;
  42661. /**
  42662. * Disposes of the gizmo
  42663. */
  42664. dispose(): void;
  42665. /**
  42666. * 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)
  42667. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42668. * @returns the bounding box mesh with the passed in mesh as a child
  42669. */
  42670. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42671. /**
  42672. * CustomMeshes are not supported by this gizmo
  42673. * @param mesh The mesh to replace the default mesh of the gizmo
  42674. */
  42675. setCustomMesh(mesh: Mesh): void;
  42676. }
  42677. }
  42678. declare module BABYLON {
  42679. /**
  42680. * Single plane rotation gizmo
  42681. */
  42682. export class PlaneRotationGizmo extends Gizmo {
  42683. /**
  42684. * Drag behavior responsible for the gizmos dragging interactions
  42685. */
  42686. dragBehavior: PointerDragBehavior;
  42687. private _pointerObserver;
  42688. /**
  42689. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42690. */
  42691. snapDistance: number;
  42692. /**
  42693. * Event that fires each time the gizmo snaps to a new location.
  42694. * * snapDistance is the the change in distance
  42695. */
  42696. onSnapObservable: Observable<{
  42697. snapDistance: number;
  42698. }>;
  42699. /**
  42700. * Creates a PlaneRotationGizmo
  42701. * @param gizmoLayer The utility layer the gizmo will be added to
  42702. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42703. * @param color The color of the gizmo
  42704. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42705. */
  42706. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42707. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42708. /**
  42709. * Disposes of the gizmo
  42710. */
  42711. dispose(): void;
  42712. }
  42713. }
  42714. declare module BABYLON {
  42715. /**
  42716. * Gizmo that enables rotating a mesh along 3 axis
  42717. */
  42718. export class RotationGizmo extends Gizmo {
  42719. /**
  42720. * Internal gizmo used for interactions on the x axis
  42721. */
  42722. xGizmo: PlaneRotationGizmo;
  42723. /**
  42724. * Internal gizmo used for interactions on the y axis
  42725. */
  42726. yGizmo: PlaneRotationGizmo;
  42727. /**
  42728. * Internal gizmo used for interactions on the z axis
  42729. */
  42730. zGizmo: PlaneRotationGizmo;
  42731. /** Fires an event when any of it's sub gizmos are dragged */
  42732. onDragStartObservable: Observable<{}>;
  42733. /** Fires an event when any of it's sub gizmos are released from dragging */
  42734. onDragEndObservable: Observable<{}>;
  42735. attachedMesh: Nullable<AbstractMesh>;
  42736. /**
  42737. * Creates a RotationGizmo
  42738. * @param gizmoLayer The utility layer the gizmo will be added to
  42739. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42740. */
  42741. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42742. updateGizmoRotationToMatchAttachedMesh: boolean;
  42743. /**
  42744. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42745. */
  42746. snapDistance: number;
  42747. /**
  42748. * Ratio for the scale of the gizmo (Default: 1)
  42749. */
  42750. scaleRatio: number;
  42751. /**
  42752. * Disposes of the gizmo
  42753. */
  42754. dispose(): void;
  42755. /**
  42756. * CustomMeshes are not supported by this gizmo
  42757. * @param mesh The mesh to replace the default mesh of the gizmo
  42758. */
  42759. setCustomMesh(mesh: Mesh): void;
  42760. }
  42761. }
  42762. declare module BABYLON {
  42763. /**
  42764. * Gizmo that enables dragging a mesh along 3 axis
  42765. */
  42766. export class PositionGizmo extends Gizmo {
  42767. /**
  42768. * Internal gizmo used for interactions on the x axis
  42769. */
  42770. xGizmo: AxisDragGizmo;
  42771. /**
  42772. * Internal gizmo used for interactions on the y axis
  42773. */
  42774. yGizmo: AxisDragGizmo;
  42775. /**
  42776. * Internal gizmo used for interactions on the z axis
  42777. */
  42778. zGizmo: AxisDragGizmo;
  42779. /** Fires an event when any of it's sub gizmos are dragged */
  42780. onDragStartObservable: Observable<{}>;
  42781. /** Fires an event when any of it's sub gizmos are released from dragging */
  42782. onDragEndObservable: Observable<{}>;
  42783. attachedMesh: Nullable<AbstractMesh>;
  42784. /**
  42785. * Creates a PositionGizmo
  42786. * @param gizmoLayer The utility layer the gizmo will be added to
  42787. */
  42788. constructor(gizmoLayer?: UtilityLayerRenderer);
  42789. updateGizmoRotationToMatchAttachedMesh: boolean;
  42790. /**
  42791. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42792. */
  42793. snapDistance: number;
  42794. /**
  42795. * Ratio for the scale of the gizmo (Default: 1)
  42796. */
  42797. scaleRatio: number;
  42798. /**
  42799. * Disposes of the gizmo
  42800. */
  42801. dispose(): void;
  42802. /**
  42803. * CustomMeshes are not supported by this gizmo
  42804. * @param mesh The mesh to replace the default mesh of the gizmo
  42805. */
  42806. setCustomMesh(mesh: Mesh): void;
  42807. }
  42808. }
  42809. declare module BABYLON {
  42810. /**
  42811. * Class containing static functions to help procedurally build meshes
  42812. */
  42813. export class PolyhedronBuilder {
  42814. /**
  42815. * Creates a polyhedron mesh
  42816. * * 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
  42817. * * The parameter `size` (positive float, default 1) sets the polygon size
  42818. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42819. * * 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`
  42820. * * 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
  42821. * * 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)`)
  42822. * * 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
  42823. * * 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
  42824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42825. * * 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
  42826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42827. * @param name defines the name of the mesh
  42828. * @param options defines the options used to create the mesh
  42829. * @param scene defines the hosting scene
  42830. * @returns the polyhedron mesh
  42831. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42832. */
  42833. static CreatePolyhedron(name: string, options: {
  42834. type?: number;
  42835. size?: number;
  42836. sizeX?: number;
  42837. sizeY?: number;
  42838. sizeZ?: number;
  42839. custom?: any;
  42840. faceUV?: Vector4[];
  42841. faceColors?: Color4[];
  42842. flat?: boolean;
  42843. updatable?: boolean;
  42844. sideOrientation?: number;
  42845. frontUVs?: Vector4;
  42846. backUVs?: Vector4;
  42847. }, scene?: Nullable<Scene>): Mesh;
  42848. }
  42849. }
  42850. declare module BABYLON {
  42851. /**
  42852. * Gizmo that enables scaling a mesh along 3 axis
  42853. */
  42854. export class ScaleGizmo extends Gizmo {
  42855. /**
  42856. * Internal gizmo used for interactions on the x axis
  42857. */
  42858. xGizmo: AxisScaleGizmo;
  42859. /**
  42860. * Internal gizmo used for interactions on the y axis
  42861. */
  42862. yGizmo: AxisScaleGizmo;
  42863. /**
  42864. * Internal gizmo used for interactions on the z axis
  42865. */
  42866. zGizmo: AxisScaleGizmo;
  42867. /**
  42868. * Internal gizmo used to scale all axis equally
  42869. */
  42870. uniformScaleGizmo: AxisScaleGizmo;
  42871. /** Fires an event when any of it's sub gizmos are dragged */
  42872. onDragStartObservable: Observable<{}>;
  42873. /** Fires an event when any of it's sub gizmos are released from dragging */
  42874. onDragEndObservable: Observable<{}>;
  42875. attachedMesh: Nullable<AbstractMesh>;
  42876. /**
  42877. * Creates a ScaleGizmo
  42878. * @param gizmoLayer The utility layer the gizmo will be added to
  42879. */
  42880. constructor(gizmoLayer?: UtilityLayerRenderer);
  42881. updateGizmoRotationToMatchAttachedMesh: boolean;
  42882. /**
  42883. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42884. */
  42885. snapDistance: number;
  42886. /**
  42887. * Ratio for the scale of the gizmo (Default: 1)
  42888. */
  42889. scaleRatio: number;
  42890. /**
  42891. * Disposes of the gizmo
  42892. */
  42893. dispose(): void;
  42894. }
  42895. }
  42896. declare module BABYLON {
  42897. /**
  42898. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42899. */
  42900. export class GizmoManager implements IDisposable {
  42901. private scene;
  42902. /**
  42903. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42904. */
  42905. gizmos: {
  42906. positionGizmo: Nullable<PositionGizmo>;
  42907. rotationGizmo: Nullable<RotationGizmo>;
  42908. scaleGizmo: Nullable<ScaleGizmo>;
  42909. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42910. };
  42911. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42912. clearGizmoOnEmptyPointerEvent: boolean;
  42913. /** Fires an event when the manager is attached to a mesh */
  42914. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42915. private _gizmosEnabled;
  42916. private _pointerObserver;
  42917. private _attachedMesh;
  42918. private _boundingBoxColor;
  42919. private _defaultUtilityLayer;
  42920. private _defaultKeepDepthUtilityLayer;
  42921. /**
  42922. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42923. */
  42924. boundingBoxDragBehavior: SixDofDragBehavior;
  42925. /**
  42926. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42927. */
  42928. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42929. /**
  42930. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42931. */
  42932. usePointerToAttachGizmos: boolean;
  42933. /**
  42934. * Instatiates a gizmo manager
  42935. * @param scene the scene to overlay the gizmos on top of
  42936. */
  42937. constructor(scene: Scene);
  42938. /**
  42939. * Attaches a set of gizmos to the specified mesh
  42940. * @param mesh The mesh the gizmo's should be attached to
  42941. */
  42942. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42943. /**
  42944. * If the position gizmo is enabled
  42945. */
  42946. positionGizmoEnabled: boolean;
  42947. /**
  42948. * If the rotation gizmo is enabled
  42949. */
  42950. rotationGizmoEnabled: boolean;
  42951. /**
  42952. * If the scale gizmo is enabled
  42953. */
  42954. scaleGizmoEnabled: boolean;
  42955. /**
  42956. * If the boundingBox gizmo is enabled
  42957. */
  42958. boundingBoxGizmoEnabled: boolean;
  42959. /**
  42960. * Disposes of the gizmo manager
  42961. */
  42962. dispose(): void;
  42963. }
  42964. }
  42965. declare module BABYLON {
  42966. /**
  42967. * A directional light is defined by a direction (what a surprise!).
  42968. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42969. * 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.
  42970. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42971. */
  42972. export class DirectionalLight extends ShadowLight {
  42973. private _shadowFrustumSize;
  42974. /**
  42975. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42976. */
  42977. /**
  42978. * Specifies a fix frustum size for the shadow generation.
  42979. */
  42980. shadowFrustumSize: number;
  42981. private _shadowOrthoScale;
  42982. /**
  42983. * Gets the shadow projection scale against the optimal computed one.
  42984. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42985. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42986. */
  42987. /**
  42988. * Sets the shadow projection scale against the optimal computed one.
  42989. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42990. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42991. */
  42992. shadowOrthoScale: number;
  42993. /**
  42994. * Automatically compute the projection matrix to best fit (including all the casters)
  42995. * on each frame.
  42996. */
  42997. autoUpdateExtends: boolean;
  42998. private _orthoLeft;
  42999. private _orthoRight;
  43000. private _orthoTop;
  43001. private _orthoBottom;
  43002. /**
  43003. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43004. * The directional light is emitted from everywhere in the given direction.
  43005. * It can cast shadows.
  43006. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43007. * @param name The friendly name of the light
  43008. * @param direction The direction of the light
  43009. * @param scene The scene the light belongs to
  43010. */
  43011. constructor(name: string, direction: Vector3, scene: Scene);
  43012. /**
  43013. * Returns the string "DirectionalLight".
  43014. * @return The class name
  43015. */
  43016. getClassName(): string;
  43017. /**
  43018. * Returns the integer 1.
  43019. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43020. */
  43021. getTypeID(): number;
  43022. /**
  43023. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43024. * Returns the DirectionalLight Shadow projection matrix.
  43025. */
  43026. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43027. /**
  43028. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43029. * Returns the DirectionalLight Shadow projection matrix.
  43030. */
  43031. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43032. /**
  43033. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43034. * Returns the DirectionalLight Shadow projection matrix.
  43035. */
  43036. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43037. protected _buildUniformLayout(): void;
  43038. /**
  43039. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43040. * @param effect The effect to update
  43041. * @param lightIndex The index of the light in the effect to update
  43042. * @returns The directional light
  43043. */
  43044. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43045. /**
  43046. * Gets the minZ used for shadow according to both the scene and the light.
  43047. *
  43048. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43049. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43050. * @param activeCamera The camera we are returning the min for
  43051. * @returns the depth min z
  43052. */
  43053. getDepthMinZ(activeCamera: Camera): number;
  43054. /**
  43055. * Gets the maxZ used for shadow according to both the scene and the light.
  43056. *
  43057. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43058. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43059. * @param activeCamera The camera we are returning the max for
  43060. * @returns the depth max z
  43061. */
  43062. getDepthMaxZ(activeCamera: Camera): number;
  43063. /**
  43064. * Prepares the list of defines specific to the light type.
  43065. * @param defines the list of defines
  43066. * @param lightIndex defines the index of the light for the effect
  43067. */
  43068. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43069. }
  43070. }
  43071. declare module BABYLON {
  43072. /**
  43073. * Class containing static functions to help procedurally build meshes
  43074. */
  43075. export class HemisphereBuilder {
  43076. /**
  43077. * Creates a hemisphere mesh
  43078. * @param name defines the name of the mesh
  43079. * @param options defines the options used to create the mesh
  43080. * @param scene defines the hosting scene
  43081. * @returns the hemisphere mesh
  43082. */
  43083. static CreateHemisphere(name: string, options: {
  43084. segments?: number;
  43085. diameter?: number;
  43086. sideOrientation?: number;
  43087. }, scene: any): Mesh;
  43088. }
  43089. }
  43090. declare module BABYLON {
  43091. /**
  43092. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43093. * These values define a cone of light starting from the position, emitting toward the direction.
  43094. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43095. * and the exponent defines the speed of the decay of the light with distance (reach).
  43096. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43097. */
  43098. export class SpotLight extends ShadowLight {
  43099. private _angle;
  43100. private _innerAngle;
  43101. private _cosHalfAngle;
  43102. private _lightAngleScale;
  43103. private _lightAngleOffset;
  43104. /**
  43105. * Gets the cone angle of the spot light in Radians.
  43106. */
  43107. /**
  43108. * Sets the cone angle of the spot light in Radians.
  43109. */
  43110. angle: number;
  43111. /**
  43112. * Only used in gltf falloff mode, this defines the angle where
  43113. * the directional falloff will start before cutting at angle which could be seen
  43114. * as outer angle.
  43115. */
  43116. /**
  43117. * Only used in gltf falloff mode, this defines the angle where
  43118. * the directional falloff will start before cutting at angle which could be seen
  43119. * as outer angle.
  43120. */
  43121. innerAngle: number;
  43122. private _shadowAngleScale;
  43123. /**
  43124. * Allows scaling the angle of the light for shadow generation only.
  43125. */
  43126. /**
  43127. * Allows scaling the angle of the light for shadow generation only.
  43128. */
  43129. shadowAngleScale: number;
  43130. /**
  43131. * The light decay speed with the distance from the emission spot.
  43132. */
  43133. exponent: number;
  43134. private _projectionTextureMatrix;
  43135. /**
  43136. * Allows reading the projecton texture
  43137. */
  43138. readonly projectionTextureMatrix: Matrix;
  43139. protected _projectionTextureLightNear: number;
  43140. /**
  43141. * Gets the near clip of the Spotlight for texture projection.
  43142. */
  43143. /**
  43144. * Sets the near clip of the Spotlight for texture projection.
  43145. */
  43146. projectionTextureLightNear: number;
  43147. protected _projectionTextureLightFar: number;
  43148. /**
  43149. * Gets the far clip of the Spotlight for texture projection.
  43150. */
  43151. /**
  43152. * Sets the far clip of the Spotlight for texture projection.
  43153. */
  43154. projectionTextureLightFar: number;
  43155. protected _projectionTextureUpDirection: Vector3;
  43156. /**
  43157. * Gets the Up vector of the Spotlight for texture projection.
  43158. */
  43159. /**
  43160. * Sets the Up vector of the Spotlight for texture projection.
  43161. */
  43162. projectionTextureUpDirection: Vector3;
  43163. private _projectionTexture;
  43164. /**
  43165. * Gets the projection texture of the light.
  43166. */
  43167. /**
  43168. * Sets the projection texture of the light.
  43169. */
  43170. projectionTexture: Nullable<BaseTexture>;
  43171. private _projectionTextureViewLightDirty;
  43172. private _projectionTextureProjectionLightDirty;
  43173. private _projectionTextureDirty;
  43174. private _projectionTextureViewTargetVector;
  43175. private _projectionTextureViewLightMatrix;
  43176. private _projectionTextureProjectionLightMatrix;
  43177. private _projectionTextureScalingMatrix;
  43178. /**
  43179. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43180. * It can cast shadows.
  43181. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43182. * @param name The light friendly name
  43183. * @param position The position of the spot light in the scene
  43184. * @param direction The direction of the light in the scene
  43185. * @param angle The cone angle of the light in Radians
  43186. * @param exponent The light decay speed with the distance from the emission spot
  43187. * @param scene The scene the lights belongs to
  43188. */
  43189. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43190. /**
  43191. * Returns the string "SpotLight".
  43192. * @returns the class name
  43193. */
  43194. getClassName(): string;
  43195. /**
  43196. * Returns the integer 2.
  43197. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43198. */
  43199. getTypeID(): number;
  43200. /**
  43201. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43202. */
  43203. protected _setDirection(value: Vector3): void;
  43204. /**
  43205. * Overrides the position setter to recompute the projection texture view light Matrix.
  43206. */
  43207. protected _setPosition(value: Vector3): void;
  43208. /**
  43209. * 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.
  43210. * Returns the SpotLight.
  43211. */
  43212. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43213. protected _computeProjectionTextureViewLightMatrix(): void;
  43214. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43215. /**
  43216. * Main function for light texture projection matrix computing.
  43217. */
  43218. protected _computeProjectionTextureMatrix(): void;
  43219. protected _buildUniformLayout(): void;
  43220. private _computeAngleValues;
  43221. /**
  43222. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43223. * @param effect The effect to update
  43224. * @param lightIndex The index of the light in the effect to update
  43225. * @returns The spot light
  43226. */
  43227. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43228. /**
  43229. * Disposes the light and the associated resources.
  43230. */
  43231. dispose(): void;
  43232. /**
  43233. * Prepares the list of defines specific to the light type.
  43234. * @param defines the list of defines
  43235. * @param lightIndex defines the index of the light for the effect
  43236. */
  43237. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43238. }
  43239. }
  43240. declare module BABYLON {
  43241. /**
  43242. * Gizmo that enables viewing a light
  43243. */
  43244. export class LightGizmo extends Gizmo {
  43245. private _lightMesh;
  43246. private _material;
  43247. private cachedPosition;
  43248. private cachedForward;
  43249. /**
  43250. * Creates a LightGizmo
  43251. * @param gizmoLayer The utility layer the gizmo will be added to
  43252. */
  43253. constructor(gizmoLayer?: UtilityLayerRenderer);
  43254. private _light;
  43255. /**
  43256. * The light that the gizmo is attached to
  43257. */
  43258. light: Nullable<Light>;
  43259. /**
  43260. * @hidden
  43261. * Updates the gizmo to match the attached mesh's position/rotation
  43262. */
  43263. protected _update(): void;
  43264. private static _Scale;
  43265. /**
  43266. * Creates the lines for a light mesh
  43267. */
  43268. private static _createLightLines;
  43269. private static _CreateHemisphericLightMesh;
  43270. private static _CreatePointLightMesh;
  43271. private static _CreateSpotLightMesh;
  43272. private static _CreateDirectionalLightMesh;
  43273. }
  43274. }
  43275. declare module BABYLON {
  43276. /** @hidden */
  43277. export var backgroundFragmentDeclaration: {
  43278. name: string;
  43279. shader: string;
  43280. };
  43281. }
  43282. declare module BABYLON {
  43283. /** @hidden */
  43284. export var backgroundUboDeclaration: {
  43285. name: string;
  43286. shader: string;
  43287. };
  43288. }
  43289. declare module BABYLON {
  43290. /** @hidden */
  43291. export var backgroundPixelShader: {
  43292. name: string;
  43293. shader: string;
  43294. };
  43295. }
  43296. declare module BABYLON {
  43297. /** @hidden */
  43298. export var backgroundVertexDeclaration: {
  43299. name: string;
  43300. shader: string;
  43301. };
  43302. }
  43303. declare module BABYLON {
  43304. /** @hidden */
  43305. export var backgroundVertexShader: {
  43306. name: string;
  43307. shader: string;
  43308. };
  43309. }
  43310. declare module BABYLON {
  43311. /**
  43312. * Background material used to create an efficient environement around your scene.
  43313. */
  43314. export class BackgroundMaterial extends PushMaterial {
  43315. /**
  43316. * Standard reflectance value at parallel view angle.
  43317. */
  43318. static StandardReflectance0: number;
  43319. /**
  43320. * Standard reflectance value at grazing angle.
  43321. */
  43322. static StandardReflectance90: number;
  43323. protected _primaryColor: Color3;
  43324. /**
  43325. * Key light Color (multiply against the environement texture)
  43326. */
  43327. primaryColor: Color3;
  43328. protected __perceptualColor: Nullable<Color3>;
  43329. /**
  43330. * Experimental Internal Use Only.
  43331. *
  43332. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43333. * This acts as a helper to set the primary color to a more "human friendly" value.
  43334. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43335. * output color as close as possible from the chosen value.
  43336. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43337. * part of lighting setup.)
  43338. */
  43339. _perceptualColor: Nullable<Color3>;
  43340. protected _primaryColorShadowLevel: float;
  43341. /**
  43342. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43343. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43344. */
  43345. primaryColorShadowLevel: float;
  43346. protected _primaryColorHighlightLevel: float;
  43347. /**
  43348. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43349. * The primary color is used at the level chosen to define what the white area would look.
  43350. */
  43351. primaryColorHighlightLevel: float;
  43352. protected _reflectionTexture: Nullable<BaseTexture>;
  43353. /**
  43354. * Reflection Texture used in the material.
  43355. * Should be author in a specific way for the best result (refer to the documentation).
  43356. */
  43357. reflectionTexture: Nullable<BaseTexture>;
  43358. protected _reflectionBlur: float;
  43359. /**
  43360. * Reflection Texture level of blur.
  43361. *
  43362. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43363. * texture twice.
  43364. */
  43365. reflectionBlur: float;
  43366. protected _diffuseTexture: Nullable<BaseTexture>;
  43367. /**
  43368. * Diffuse Texture used in the material.
  43369. * Should be author in a specific way for the best result (refer to the documentation).
  43370. */
  43371. diffuseTexture: Nullable<BaseTexture>;
  43372. protected _shadowLights: Nullable<IShadowLight[]>;
  43373. /**
  43374. * Specify the list of lights casting shadow on the material.
  43375. * All scene shadow lights will be included if null.
  43376. */
  43377. shadowLights: Nullable<IShadowLight[]>;
  43378. protected _shadowLevel: float;
  43379. /**
  43380. * Helps adjusting the shadow to a softer level if required.
  43381. * 0 means black shadows and 1 means no shadows.
  43382. */
  43383. shadowLevel: float;
  43384. protected _sceneCenter: Vector3;
  43385. /**
  43386. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43387. * It is usually zero but might be interesting to modify according to your setup.
  43388. */
  43389. sceneCenter: Vector3;
  43390. protected _opacityFresnel: boolean;
  43391. /**
  43392. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43393. * This helps ensuring a nice transition when the camera goes under the ground.
  43394. */
  43395. opacityFresnel: boolean;
  43396. protected _reflectionFresnel: boolean;
  43397. /**
  43398. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43399. * This helps adding a mirror texture on the ground.
  43400. */
  43401. reflectionFresnel: boolean;
  43402. protected _reflectionFalloffDistance: number;
  43403. /**
  43404. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43405. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43406. */
  43407. reflectionFalloffDistance: number;
  43408. protected _reflectionAmount: number;
  43409. /**
  43410. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43411. */
  43412. reflectionAmount: number;
  43413. protected _reflectionReflectance0: number;
  43414. /**
  43415. * This specifies the weight of the reflection at grazing angle.
  43416. */
  43417. reflectionReflectance0: number;
  43418. protected _reflectionReflectance90: number;
  43419. /**
  43420. * This specifies the weight of the reflection at a perpendicular point of view.
  43421. */
  43422. reflectionReflectance90: number;
  43423. /**
  43424. * Sets the reflection reflectance fresnel values according to the default standard
  43425. * empirically know to work well :-)
  43426. */
  43427. reflectionStandardFresnelWeight: number;
  43428. protected _useRGBColor: boolean;
  43429. /**
  43430. * Helps to directly use the maps channels instead of their level.
  43431. */
  43432. useRGBColor: boolean;
  43433. protected _enableNoise: boolean;
  43434. /**
  43435. * This helps reducing the banding effect that could occur on the background.
  43436. */
  43437. enableNoise: boolean;
  43438. /**
  43439. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43440. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43441. * Recommended to be keep at 1.0 except for special cases.
  43442. */
  43443. fovMultiplier: number;
  43444. private _fovMultiplier;
  43445. /**
  43446. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43447. */
  43448. useEquirectangularFOV: boolean;
  43449. private _maxSimultaneousLights;
  43450. /**
  43451. * Number of Simultaneous lights allowed on the material.
  43452. */
  43453. maxSimultaneousLights: int;
  43454. /**
  43455. * Default configuration related to image processing available in the Background Material.
  43456. */
  43457. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43458. /**
  43459. * Keep track of the image processing observer to allow dispose and replace.
  43460. */
  43461. private _imageProcessingObserver;
  43462. /**
  43463. * Attaches a new image processing configuration to the PBR Material.
  43464. * @param configuration (if null the scene configuration will be use)
  43465. */
  43466. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43467. /**
  43468. * Gets the image processing configuration used either in this material.
  43469. */
  43470. /**
  43471. * Sets the Default image processing configuration used either in the this material.
  43472. *
  43473. * If sets to null, the scene one is in use.
  43474. */
  43475. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43476. /**
  43477. * Gets wether the color curves effect is enabled.
  43478. */
  43479. /**
  43480. * Sets wether the color curves effect is enabled.
  43481. */
  43482. cameraColorCurvesEnabled: boolean;
  43483. /**
  43484. * Gets wether the color grading effect is enabled.
  43485. */
  43486. /**
  43487. * Gets wether the color grading effect is enabled.
  43488. */
  43489. cameraColorGradingEnabled: boolean;
  43490. /**
  43491. * Gets wether tonemapping is enabled or not.
  43492. */
  43493. /**
  43494. * Sets wether tonemapping is enabled or not
  43495. */
  43496. cameraToneMappingEnabled: boolean;
  43497. /**
  43498. * The camera exposure used on this material.
  43499. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43500. * This corresponds to a photographic exposure.
  43501. */
  43502. /**
  43503. * The camera exposure used on this material.
  43504. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43505. * This corresponds to a photographic exposure.
  43506. */
  43507. cameraExposure: float;
  43508. /**
  43509. * Gets The camera contrast used on this material.
  43510. */
  43511. /**
  43512. * Sets The camera contrast used on this material.
  43513. */
  43514. cameraContrast: float;
  43515. /**
  43516. * Gets the Color Grading 2D Lookup Texture.
  43517. */
  43518. /**
  43519. * Sets the Color Grading 2D Lookup Texture.
  43520. */
  43521. cameraColorGradingTexture: Nullable<BaseTexture>;
  43522. /**
  43523. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43524. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43525. * 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;
  43526. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43527. */
  43528. /**
  43529. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43530. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43531. * 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;
  43532. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43533. */
  43534. cameraColorCurves: Nullable<ColorCurves>;
  43535. /**
  43536. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43537. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43538. */
  43539. switchToBGR: boolean;
  43540. private _renderTargets;
  43541. private _reflectionControls;
  43542. private _white;
  43543. private _primaryShadowColor;
  43544. private _primaryHighlightColor;
  43545. /**
  43546. * Instantiates a Background Material in the given scene
  43547. * @param name The friendly name of the material
  43548. * @param scene The scene to add the material to
  43549. */
  43550. constructor(name: string, scene: Scene);
  43551. /**
  43552. * Gets a boolean indicating that current material needs to register RTT
  43553. */
  43554. readonly hasRenderTargetTextures: boolean;
  43555. /**
  43556. * The entire material has been created in order to prevent overdraw.
  43557. * @returns false
  43558. */
  43559. needAlphaTesting(): boolean;
  43560. /**
  43561. * The entire material has been created in order to prevent overdraw.
  43562. * @returns true if blending is enable
  43563. */
  43564. needAlphaBlending(): boolean;
  43565. /**
  43566. * Checks wether the material is ready to be rendered for a given mesh.
  43567. * @param mesh The mesh to render
  43568. * @param subMesh The submesh to check against
  43569. * @param useInstances Specify wether or not the material is used with instances
  43570. * @returns true if all the dependencies are ready (Textures, Effects...)
  43571. */
  43572. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43573. /**
  43574. * Compute the primary color according to the chosen perceptual color.
  43575. */
  43576. private _computePrimaryColorFromPerceptualColor;
  43577. /**
  43578. * Compute the highlights and shadow colors according to their chosen levels.
  43579. */
  43580. private _computePrimaryColors;
  43581. /**
  43582. * Build the uniform buffer used in the material.
  43583. */
  43584. buildUniformLayout(): void;
  43585. /**
  43586. * Unbind the material.
  43587. */
  43588. unbind(): void;
  43589. /**
  43590. * Bind only the world matrix to the material.
  43591. * @param world The world matrix to bind.
  43592. */
  43593. bindOnlyWorldMatrix(world: Matrix): void;
  43594. /**
  43595. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43596. * @param world The world matrix to bind.
  43597. * @param subMesh The submesh to bind for.
  43598. */
  43599. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43600. /**
  43601. * Dispose the material.
  43602. * @param forceDisposeEffect Force disposal of the associated effect.
  43603. * @param forceDisposeTextures Force disposal of the associated textures.
  43604. */
  43605. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43606. /**
  43607. * Clones the material.
  43608. * @param name The cloned name.
  43609. * @returns The cloned material.
  43610. */
  43611. clone(name: string): BackgroundMaterial;
  43612. /**
  43613. * Serializes the current material to its JSON representation.
  43614. * @returns The JSON representation.
  43615. */
  43616. serialize(): any;
  43617. /**
  43618. * Gets the class name of the material
  43619. * @returns "BackgroundMaterial"
  43620. */
  43621. getClassName(): string;
  43622. /**
  43623. * Parse a JSON input to create back a background material.
  43624. * @param source The JSON data to parse
  43625. * @param scene The scene to create the parsed material in
  43626. * @param rootUrl The root url of the assets the material depends upon
  43627. * @returns the instantiated BackgroundMaterial.
  43628. */
  43629. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43630. }
  43631. }
  43632. declare module BABYLON {
  43633. /**
  43634. * Represents the different options available during the creation of
  43635. * a Environment helper.
  43636. *
  43637. * This can control the default ground, skybox and image processing setup of your scene.
  43638. */
  43639. export interface IEnvironmentHelperOptions {
  43640. /**
  43641. * Specifies wether or not to create a ground.
  43642. * True by default.
  43643. */
  43644. createGround: boolean;
  43645. /**
  43646. * Specifies the ground size.
  43647. * 15 by default.
  43648. */
  43649. groundSize: number;
  43650. /**
  43651. * The texture used on the ground for the main color.
  43652. * Comes from the BabylonJS CDN by default.
  43653. *
  43654. * Remarks: Can be either a texture or a url.
  43655. */
  43656. groundTexture: string | BaseTexture;
  43657. /**
  43658. * The color mixed in the ground texture by default.
  43659. * BabylonJS clearColor by default.
  43660. */
  43661. groundColor: Color3;
  43662. /**
  43663. * Specifies the ground opacity.
  43664. * 1 by default.
  43665. */
  43666. groundOpacity: number;
  43667. /**
  43668. * Enables the ground to receive shadows.
  43669. * True by default.
  43670. */
  43671. enableGroundShadow: boolean;
  43672. /**
  43673. * Helps preventing the shadow to be fully black on the ground.
  43674. * 0.5 by default.
  43675. */
  43676. groundShadowLevel: number;
  43677. /**
  43678. * Creates a mirror texture attach to the ground.
  43679. * false by default.
  43680. */
  43681. enableGroundMirror: boolean;
  43682. /**
  43683. * Specifies the ground mirror size ratio.
  43684. * 0.3 by default as the default kernel is 64.
  43685. */
  43686. groundMirrorSizeRatio: number;
  43687. /**
  43688. * Specifies the ground mirror blur kernel size.
  43689. * 64 by default.
  43690. */
  43691. groundMirrorBlurKernel: number;
  43692. /**
  43693. * Specifies the ground mirror visibility amount.
  43694. * 1 by default
  43695. */
  43696. groundMirrorAmount: number;
  43697. /**
  43698. * Specifies the ground mirror reflectance weight.
  43699. * This uses the standard weight of the background material to setup the fresnel effect
  43700. * of the mirror.
  43701. * 1 by default.
  43702. */
  43703. groundMirrorFresnelWeight: number;
  43704. /**
  43705. * Specifies the ground mirror Falloff distance.
  43706. * This can helps reducing the size of the reflection.
  43707. * 0 by Default.
  43708. */
  43709. groundMirrorFallOffDistance: number;
  43710. /**
  43711. * Specifies the ground mirror texture type.
  43712. * Unsigned Int by Default.
  43713. */
  43714. groundMirrorTextureType: number;
  43715. /**
  43716. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43717. * the shown objects.
  43718. */
  43719. groundYBias: number;
  43720. /**
  43721. * Specifies wether or not to create a skybox.
  43722. * True by default.
  43723. */
  43724. createSkybox: boolean;
  43725. /**
  43726. * Specifies the skybox size.
  43727. * 20 by default.
  43728. */
  43729. skyboxSize: number;
  43730. /**
  43731. * The texture used on the skybox for the main color.
  43732. * Comes from the BabylonJS CDN by default.
  43733. *
  43734. * Remarks: Can be either a texture or a url.
  43735. */
  43736. skyboxTexture: string | BaseTexture;
  43737. /**
  43738. * The color mixed in the skybox texture by default.
  43739. * BabylonJS clearColor by default.
  43740. */
  43741. skyboxColor: Color3;
  43742. /**
  43743. * The background rotation around the Y axis of the scene.
  43744. * This helps aligning the key lights of your scene with the background.
  43745. * 0 by default.
  43746. */
  43747. backgroundYRotation: number;
  43748. /**
  43749. * Compute automatically the size of the elements to best fit with the scene.
  43750. */
  43751. sizeAuto: boolean;
  43752. /**
  43753. * Default position of the rootMesh if autoSize is not true.
  43754. */
  43755. rootPosition: Vector3;
  43756. /**
  43757. * Sets up the image processing in the scene.
  43758. * true by default.
  43759. */
  43760. setupImageProcessing: boolean;
  43761. /**
  43762. * The texture used as your environment texture in the scene.
  43763. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43764. *
  43765. * Remarks: Can be either a texture or a url.
  43766. */
  43767. environmentTexture: string | BaseTexture;
  43768. /**
  43769. * The value of the exposure to apply to the scene.
  43770. * 0.6 by default if setupImageProcessing is true.
  43771. */
  43772. cameraExposure: number;
  43773. /**
  43774. * The value of the contrast to apply to the scene.
  43775. * 1.6 by default if setupImageProcessing is true.
  43776. */
  43777. cameraContrast: number;
  43778. /**
  43779. * Specifies wether or not tonemapping should be enabled in the scene.
  43780. * true by default if setupImageProcessing is true.
  43781. */
  43782. toneMappingEnabled: boolean;
  43783. }
  43784. /**
  43785. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43786. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43787. * It also helps with the default setup of your imageProcessing configuration.
  43788. */
  43789. export class EnvironmentHelper {
  43790. /**
  43791. * Default ground texture URL.
  43792. */
  43793. private static _groundTextureCDNUrl;
  43794. /**
  43795. * Default skybox texture URL.
  43796. */
  43797. private static _skyboxTextureCDNUrl;
  43798. /**
  43799. * Default environment texture URL.
  43800. */
  43801. private static _environmentTextureCDNUrl;
  43802. /**
  43803. * Creates the default options for the helper.
  43804. */
  43805. private static _getDefaultOptions;
  43806. private _rootMesh;
  43807. /**
  43808. * Gets the root mesh created by the helper.
  43809. */
  43810. readonly rootMesh: Mesh;
  43811. private _skybox;
  43812. /**
  43813. * Gets the skybox created by the helper.
  43814. */
  43815. readonly skybox: Nullable<Mesh>;
  43816. private _skyboxTexture;
  43817. /**
  43818. * Gets the skybox texture created by the helper.
  43819. */
  43820. readonly skyboxTexture: Nullable<BaseTexture>;
  43821. private _skyboxMaterial;
  43822. /**
  43823. * Gets the skybox material created by the helper.
  43824. */
  43825. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43826. private _ground;
  43827. /**
  43828. * Gets the ground mesh created by the helper.
  43829. */
  43830. readonly ground: Nullable<Mesh>;
  43831. private _groundTexture;
  43832. /**
  43833. * Gets the ground texture created by the helper.
  43834. */
  43835. readonly groundTexture: Nullable<BaseTexture>;
  43836. private _groundMirror;
  43837. /**
  43838. * Gets the ground mirror created by the helper.
  43839. */
  43840. readonly groundMirror: Nullable<MirrorTexture>;
  43841. /**
  43842. * Gets the ground mirror render list to helps pushing the meshes
  43843. * you wish in the ground reflection.
  43844. */
  43845. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43846. private _groundMaterial;
  43847. /**
  43848. * Gets the ground material created by the helper.
  43849. */
  43850. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43851. /**
  43852. * Stores the creation options.
  43853. */
  43854. private readonly _scene;
  43855. private _options;
  43856. /**
  43857. * This observable will be notified with any error during the creation of the environment,
  43858. * mainly texture creation errors.
  43859. */
  43860. onErrorObservable: Observable<{
  43861. message?: string;
  43862. exception?: any;
  43863. }>;
  43864. /**
  43865. * constructor
  43866. * @param options Defines the options we want to customize the helper
  43867. * @param scene The scene to add the material to
  43868. */
  43869. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43870. /**
  43871. * Updates the background according to the new options
  43872. * @param options
  43873. */
  43874. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43875. /**
  43876. * Sets the primary color of all the available elements.
  43877. * @param color the main color to affect to the ground and the background
  43878. */
  43879. setMainColor(color: Color3): void;
  43880. /**
  43881. * Setup the image processing according to the specified options.
  43882. */
  43883. private _setupImageProcessing;
  43884. /**
  43885. * Setup the environment texture according to the specified options.
  43886. */
  43887. private _setupEnvironmentTexture;
  43888. /**
  43889. * Setup the background according to the specified options.
  43890. */
  43891. private _setupBackground;
  43892. /**
  43893. * Get the scene sizes according to the setup.
  43894. */
  43895. private _getSceneSize;
  43896. /**
  43897. * Setup the ground according to the specified options.
  43898. */
  43899. private _setupGround;
  43900. /**
  43901. * Setup the ground material according to the specified options.
  43902. */
  43903. private _setupGroundMaterial;
  43904. /**
  43905. * Setup the ground diffuse texture according to the specified options.
  43906. */
  43907. private _setupGroundDiffuseTexture;
  43908. /**
  43909. * Setup the ground mirror texture according to the specified options.
  43910. */
  43911. private _setupGroundMirrorTexture;
  43912. /**
  43913. * Setup the ground to receive the mirror texture.
  43914. */
  43915. private _setupMirrorInGroundMaterial;
  43916. /**
  43917. * Setup the skybox according to the specified options.
  43918. */
  43919. private _setupSkybox;
  43920. /**
  43921. * Setup the skybox material according to the specified options.
  43922. */
  43923. private _setupSkyboxMaterial;
  43924. /**
  43925. * Setup the skybox reflection texture according to the specified options.
  43926. */
  43927. private _setupSkyboxReflectionTexture;
  43928. private _errorHandler;
  43929. /**
  43930. * Dispose all the elements created by the Helper.
  43931. */
  43932. dispose(): void;
  43933. }
  43934. }
  43935. declare module BABYLON {
  43936. /**
  43937. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43938. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43939. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43940. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43941. */
  43942. export class PhotoDome extends TransformNode {
  43943. private _useDirectMapping;
  43944. /**
  43945. * The texture being displayed on the sphere
  43946. */
  43947. protected _photoTexture: Texture;
  43948. /**
  43949. * Gets or sets the texture being displayed on the sphere
  43950. */
  43951. photoTexture: Texture;
  43952. /**
  43953. * Observable raised when an error occured while loading the 360 image
  43954. */
  43955. onLoadErrorObservable: Observable<string>;
  43956. /**
  43957. * The skybox material
  43958. */
  43959. protected _material: BackgroundMaterial;
  43960. /**
  43961. * The surface used for the skybox
  43962. */
  43963. protected _mesh: Mesh;
  43964. /**
  43965. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43966. * Also see the options.resolution property.
  43967. */
  43968. fovMultiplier: number;
  43969. /**
  43970. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43971. * @param name Element's name, child elements will append suffixes for their own names.
  43972. * @param urlsOfPhoto defines the url of the photo to display
  43973. * @param options defines an object containing optional or exposed sub element properties
  43974. * @param onError defines a callback called when an error occured while loading the texture
  43975. */
  43976. constructor(name: string, urlOfPhoto: string, options: {
  43977. resolution?: number;
  43978. size?: number;
  43979. useDirectMapping?: boolean;
  43980. faceForward?: boolean;
  43981. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43982. /**
  43983. * Releases resources associated with this node.
  43984. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43985. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43986. */
  43987. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43988. }
  43989. }
  43990. declare module BABYLON {
  43991. /** @hidden */
  43992. export var rgbdDecodePixelShader: {
  43993. name: string;
  43994. shader: string;
  43995. };
  43996. }
  43997. declare module BABYLON {
  43998. /**
  43999. * Class used to host texture specific utilities
  44000. */
  44001. export class BRDFTextureTools {
  44002. /**
  44003. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44004. * @param texture the texture to expand.
  44005. */
  44006. private static _ExpandDefaultBRDFTexture;
  44007. /**
  44008. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44009. * @param scene defines the hosting scene
  44010. * @returns the environment BRDF texture
  44011. */
  44012. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44013. private static _environmentBRDFBase64Texture;
  44014. }
  44015. }
  44016. declare module BABYLON {
  44017. /**
  44018. * @hidden
  44019. */
  44020. export interface IMaterialClearCoatDefines {
  44021. CLEARCOAT: boolean;
  44022. CLEARCOAT_DEFAULTIOR: boolean;
  44023. CLEARCOAT_TEXTURE: boolean;
  44024. CLEARCOAT_TEXTUREDIRECTUV: number;
  44025. CLEARCOAT_BUMP: boolean;
  44026. CLEARCOAT_BUMPDIRECTUV: number;
  44027. CLEARCOAT_TINT: boolean;
  44028. CLEARCOAT_TINT_TEXTURE: boolean;
  44029. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44030. /** @hidden */
  44031. _areTexturesDirty: boolean;
  44032. }
  44033. /**
  44034. * Define the code related to the clear coat parameters of the pbr material.
  44035. */
  44036. export class PBRClearCoatConfiguration {
  44037. /**
  44038. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44039. * The default fits with a polyurethane material.
  44040. */
  44041. private static readonly _DefaultIndiceOfRefraction;
  44042. private _isEnabled;
  44043. /**
  44044. * Defines if the clear coat is enabled in the material.
  44045. */
  44046. isEnabled: boolean;
  44047. /**
  44048. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44049. */
  44050. intensity: number;
  44051. /**
  44052. * Defines the clear coat layer roughness.
  44053. */
  44054. roughness: number;
  44055. private _indiceOfRefraction;
  44056. /**
  44057. * Defines the indice of refraction of the clear coat.
  44058. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44059. * The default fits with a polyurethane material.
  44060. * Changing the default value is more performance intensive.
  44061. */
  44062. indiceOfRefraction: number;
  44063. private _texture;
  44064. /**
  44065. * Stores the clear coat values in a texture.
  44066. */
  44067. texture: Nullable<BaseTexture>;
  44068. private _bumpTexture;
  44069. /**
  44070. * Define the clear coat specific bump texture.
  44071. */
  44072. bumpTexture: Nullable<BaseTexture>;
  44073. private _isTintEnabled;
  44074. /**
  44075. * Defines if the clear coat tint is enabled in the material.
  44076. */
  44077. isTintEnabled: boolean;
  44078. /**
  44079. * Defines the clear coat tint of the material.
  44080. * This is only use if tint is enabled
  44081. */
  44082. tintColor: Color3;
  44083. /**
  44084. * Defines the distance at which the tint color should be found in the
  44085. * clear coat media.
  44086. * This is only use if tint is enabled
  44087. */
  44088. tintColorAtDistance: number;
  44089. /**
  44090. * Defines the clear coat layer thickness.
  44091. * This is only use if tint is enabled
  44092. */
  44093. tintThickness: number;
  44094. private _tintTexture;
  44095. /**
  44096. * Stores the clear tint values in a texture.
  44097. * rgb is tint
  44098. * a is a thickness factor
  44099. */
  44100. tintTexture: Nullable<BaseTexture>;
  44101. /** @hidden */
  44102. private _internalMarkAllSubMeshesAsTexturesDirty;
  44103. /** @hidden */
  44104. _markAllSubMeshesAsTexturesDirty(): void;
  44105. /**
  44106. * Instantiate a new istance of clear coat configuration.
  44107. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44108. */
  44109. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44110. /**
  44111. * Gets wehter the submesh is ready to be used or not.
  44112. * @param defines the list of "defines" to update.
  44113. * @param scene defines the scene the material belongs to.
  44114. * @param engine defines the engine the material belongs to.
  44115. * @param disableBumpMap defines wether the material disables bump or not.
  44116. * @returns - boolean indicating that the submesh is ready or not.
  44117. */
  44118. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44119. /**
  44120. * Checks to see if a texture is used in the material.
  44121. * @param defines the list of "defines" to update.
  44122. * @param scene defines the scene to the material belongs to.
  44123. */
  44124. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44125. /**
  44126. * Binds the material data.
  44127. * @param uniformBuffer defines the Uniform buffer to fill in.
  44128. * @param scene defines the scene the material belongs to.
  44129. * @param engine defines the engine the material belongs to.
  44130. * @param disableBumpMap defines wether the material disables bump or not.
  44131. * @param isFrozen defines wether the material is frozen or not.
  44132. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44133. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44134. */
  44135. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44136. /**
  44137. * Checks to see if a texture is used in the material.
  44138. * @param texture - Base texture to use.
  44139. * @returns - Boolean specifying if a texture is used in the material.
  44140. */
  44141. hasTexture(texture: BaseTexture): boolean;
  44142. /**
  44143. * Returns an array of the actively used textures.
  44144. * @param activeTextures Array of BaseTextures
  44145. */
  44146. getActiveTextures(activeTextures: BaseTexture[]): void;
  44147. /**
  44148. * Returns the animatable textures.
  44149. * @param animatables Array of animatable textures.
  44150. */
  44151. getAnimatables(animatables: IAnimatable[]): void;
  44152. /**
  44153. * Disposes the resources of the material.
  44154. * @param forceDisposeTextures - Forces the disposal of all textures.
  44155. */
  44156. dispose(forceDisposeTextures?: boolean): void;
  44157. /**
  44158. * Get the current class name of the texture useful for serialization or dynamic coding.
  44159. * @returns "PBRClearCoatConfiguration"
  44160. */
  44161. getClassName(): string;
  44162. /**
  44163. * Add fallbacks to the effect fallbacks list.
  44164. * @param defines defines the Base texture to use.
  44165. * @param fallbacks defines the current fallback list.
  44166. * @param currentRank defines the current fallback rank.
  44167. * @returns the new fallback rank.
  44168. */
  44169. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44170. /**
  44171. * Add the required uniforms to the current list.
  44172. * @param uniforms defines the current uniform list.
  44173. */
  44174. static AddUniforms(uniforms: string[]): void;
  44175. /**
  44176. * Add the required samplers to the current list.
  44177. * @param samplers defines the current sampler list.
  44178. */
  44179. static AddSamplers(samplers: string[]): void;
  44180. /**
  44181. * Add the required uniforms to the current buffer.
  44182. * @param uniformBuffer defines the current uniform buffer.
  44183. */
  44184. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44185. /**
  44186. * Makes a duplicate of the current configuration into another one.
  44187. * @param clearCoatConfiguration define the config where to copy the info
  44188. */
  44189. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44190. /**
  44191. * Serializes this clear coat configuration.
  44192. * @returns - An object with the serialized config.
  44193. */
  44194. serialize(): any;
  44195. /**
  44196. * Parses a Clear Coat Configuration from a serialized object.
  44197. * @param source - Serialized object.
  44198. */
  44199. parse(source: any): void;
  44200. }
  44201. }
  44202. declare module BABYLON {
  44203. /**
  44204. * @hidden
  44205. */
  44206. export interface IMaterialAnisotropicDefines {
  44207. ANISOTROPIC: boolean;
  44208. ANISOTROPIC_TEXTURE: boolean;
  44209. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44210. MAINUV1: boolean;
  44211. _areTexturesDirty: boolean;
  44212. _needUVs: boolean;
  44213. }
  44214. /**
  44215. * Define the code related to the anisotropic parameters of the pbr material.
  44216. */
  44217. export class PBRAnisotropicConfiguration {
  44218. private _isEnabled;
  44219. /**
  44220. * Defines if the anisotropy is enabled in the material.
  44221. */
  44222. isEnabled: boolean;
  44223. /**
  44224. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44225. */
  44226. intensity: number;
  44227. /**
  44228. * Defines if the effect is along the tangents, bitangents or in between.
  44229. * By default, the effect is "strectching" the highlights along the tangents.
  44230. */
  44231. direction: Vector2;
  44232. private _texture;
  44233. /**
  44234. * Stores the anisotropy values in a texture.
  44235. * rg is direction (like normal from -1 to 1)
  44236. * b is a intensity
  44237. */
  44238. texture: Nullable<BaseTexture>;
  44239. /** @hidden */
  44240. private _internalMarkAllSubMeshesAsTexturesDirty;
  44241. /** @hidden */
  44242. _markAllSubMeshesAsTexturesDirty(): void;
  44243. /**
  44244. * Instantiate a new istance of anisotropy configuration.
  44245. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44246. */
  44247. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44248. /**
  44249. * Specifies that the submesh is ready to be used.
  44250. * @param defines the list of "defines" to update.
  44251. * @param scene defines the scene the material belongs to.
  44252. * @returns - boolean indicating that the submesh is ready or not.
  44253. */
  44254. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44255. /**
  44256. * Checks to see if a texture is used in the material.
  44257. * @param defines the list of "defines" to update.
  44258. * @param mesh the mesh we are preparing the defines for.
  44259. * @param scene defines the scene the material belongs to.
  44260. */
  44261. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44262. /**
  44263. * Binds the material data.
  44264. * @param uniformBuffer defines the Uniform buffer to fill in.
  44265. * @param scene defines the scene the material belongs to.
  44266. * @param isFrozen defines wether the material is frozen or not.
  44267. */
  44268. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44269. /**
  44270. * Checks to see if a texture is used in the material.
  44271. * @param texture - Base texture to use.
  44272. * @returns - Boolean specifying if a texture is used in the material.
  44273. */
  44274. hasTexture(texture: BaseTexture): boolean;
  44275. /**
  44276. * Returns an array of the actively used textures.
  44277. * @param activeTextures Array of BaseTextures
  44278. */
  44279. getActiveTextures(activeTextures: BaseTexture[]): void;
  44280. /**
  44281. * Returns the animatable textures.
  44282. * @param animatables Array of animatable textures.
  44283. */
  44284. getAnimatables(animatables: IAnimatable[]): void;
  44285. /**
  44286. * Disposes the resources of the material.
  44287. * @param forceDisposeTextures - Forces the disposal of all textures.
  44288. */
  44289. dispose(forceDisposeTextures?: boolean): void;
  44290. /**
  44291. * Get the current class name of the texture useful for serialization or dynamic coding.
  44292. * @returns "PBRAnisotropicConfiguration"
  44293. */
  44294. getClassName(): string;
  44295. /**
  44296. * Add fallbacks to the effect fallbacks list.
  44297. * @param defines defines the Base texture to use.
  44298. * @param fallbacks defines the current fallback list.
  44299. * @param currentRank defines the current fallback rank.
  44300. * @returns the new fallback rank.
  44301. */
  44302. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44303. /**
  44304. * Add the required uniforms to the current list.
  44305. * @param uniforms defines the current uniform list.
  44306. */
  44307. static AddUniforms(uniforms: string[]): void;
  44308. /**
  44309. * Add the required uniforms to the current buffer.
  44310. * @param uniformBuffer defines the current uniform buffer.
  44311. */
  44312. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44313. /**
  44314. * Add the required samplers to the current list.
  44315. * @param samplers defines the current sampler list.
  44316. */
  44317. static AddSamplers(samplers: string[]): void;
  44318. /**
  44319. * Makes a duplicate of the current configuration into another one.
  44320. * @param anisotropicConfiguration define the config where to copy the info
  44321. */
  44322. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44323. /**
  44324. * Serializes this anisotropy configuration.
  44325. * @returns - An object with the serialized config.
  44326. */
  44327. serialize(): any;
  44328. /**
  44329. * Parses a anisotropy Configuration from a serialized object.
  44330. * @param source - Serialized object.
  44331. */
  44332. parse(source: any): void;
  44333. }
  44334. }
  44335. declare module BABYLON {
  44336. /**
  44337. * @hidden
  44338. */
  44339. export interface IMaterialBRDFDefines {
  44340. BRDF_V_HEIGHT_CORRELATED: boolean;
  44341. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44342. SPHERICAL_HARMONICS: boolean;
  44343. /** @hidden */
  44344. _areMiscDirty: boolean;
  44345. }
  44346. /**
  44347. * Define the code related to the BRDF parameters of the pbr material.
  44348. */
  44349. export class PBRBRDFConfiguration {
  44350. /**
  44351. * Default value used for the energy conservation.
  44352. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44353. */
  44354. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44355. /**
  44356. * Default value used for the Smith Visibility Height Correlated mode.
  44357. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44358. */
  44359. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44360. /**
  44361. * Default value used for the IBL diffuse part.
  44362. * This can help switching back to the polynomials mode globally which is a tiny bit
  44363. * less GPU intensive at the drawback of a lower quality.
  44364. */
  44365. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44366. private _useEnergyConservation;
  44367. /**
  44368. * Defines if the material uses energy conservation.
  44369. */
  44370. useEnergyConservation: boolean;
  44371. private _useSmithVisibilityHeightCorrelated;
  44372. /**
  44373. * LEGACY Mode set to false
  44374. * Defines if the material uses height smith correlated visibility term.
  44375. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44376. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44377. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44378. * Not relying on height correlated will also disable energy conservation.
  44379. */
  44380. useSmithVisibilityHeightCorrelated: boolean;
  44381. private _useSphericalHarmonics;
  44382. /**
  44383. * LEGACY Mode set to false
  44384. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  44385. * diffuse part of the IBL.
  44386. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  44387. * to the ground truth.
  44388. */
  44389. useSphericalHarmonics: boolean;
  44390. /** @hidden */
  44391. private _internalMarkAllSubMeshesAsMiscDirty;
  44392. /** @hidden */
  44393. _markAllSubMeshesAsMiscDirty(): void;
  44394. /**
  44395. * Instantiate a new istance of clear coat configuration.
  44396. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44397. */
  44398. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44399. /**
  44400. * Checks to see if a texture is used in the material.
  44401. * @param defines the list of "defines" to update.
  44402. */
  44403. prepareDefines(defines: IMaterialBRDFDefines): void;
  44404. /**
  44405. * Get the current class name of the texture useful for serialization or dynamic coding.
  44406. * @returns "PBRClearCoatConfiguration"
  44407. */
  44408. getClassName(): string;
  44409. /**
  44410. * Makes a duplicate of the current configuration into another one.
  44411. * @param brdfConfiguration define the config where to copy the info
  44412. */
  44413. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44414. /**
  44415. * Serializes this BRDF configuration.
  44416. * @returns - An object with the serialized config.
  44417. */
  44418. serialize(): any;
  44419. /**
  44420. * Parses a BRDF Configuration from a serialized object.
  44421. * @param source - Serialized object.
  44422. */
  44423. parse(source: any): void;
  44424. }
  44425. }
  44426. declare module BABYLON {
  44427. /**
  44428. * @hidden
  44429. */
  44430. export interface IMaterialSheenDefines {
  44431. SHEEN: boolean;
  44432. SHEEN_TEXTURE: boolean;
  44433. SHEEN_TEXTUREDIRECTUV: number;
  44434. SHEEN_LINKWITHALBEDO: boolean;
  44435. /** @hidden */
  44436. _areTexturesDirty: boolean;
  44437. }
  44438. /**
  44439. * Define the code related to the Sheen parameters of the pbr material.
  44440. */
  44441. export class PBRSheenConfiguration {
  44442. private _isEnabled;
  44443. /**
  44444. * Defines if the material uses sheen.
  44445. */
  44446. isEnabled: boolean;
  44447. private _linkSheenWithAlbedo;
  44448. /**
  44449. * Defines if the sheen is linked to the sheen color.
  44450. */
  44451. linkSheenWithAlbedo: boolean;
  44452. /**
  44453. * Defines the sheen intensity.
  44454. */
  44455. intensity: number;
  44456. /**
  44457. * Defines the sheen color.
  44458. */
  44459. color: Color3;
  44460. private _texture;
  44461. /**
  44462. * Stores the sheen tint values in a texture.
  44463. * rgb is tint
  44464. * a is a intensity
  44465. */
  44466. texture: Nullable<BaseTexture>;
  44467. /** @hidden */
  44468. private _internalMarkAllSubMeshesAsTexturesDirty;
  44469. /** @hidden */
  44470. _markAllSubMeshesAsTexturesDirty(): void;
  44471. /**
  44472. * Instantiate a new istance of clear coat configuration.
  44473. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44474. */
  44475. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44476. /**
  44477. * Specifies that the submesh is ready to be used.
  44478. * @param defines the list of "defines" to update.
  44479. * @param scene defines the scene the material belongs to.
  44480. * @returns - boolean indicating that the submesh is ready or not.
  44481. */
  44482. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44483. /**
  44484. * Checks to see if a texture is used in the material.
  44485. * @param defines the list of "defines" to update.
  44486. * @param scene defines the scene the material belongs to.
  44487. */
  44488. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44489. /**
  44490. * Binds the material data.
  44491. * @param uniformBuffer defines the Uniform buffer to fill in.
  44492. * @param scene defines the scene the material belongs to.
  44493. * @param isFrozen defines wether the material is frozen or not.
  44494. */
  44495. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44496. /**
  44497. * Checks to see if a texture is used in the material.
  44498. * @param texture - Base texture to use.
  44499. * @returns - Boolean specifying if a texture is used in the material.
  44500. */
  44501. hasTexture(texture: BaseTexture): boolean;
  44502. /**
  44503. * Returns an array of the actively used textures.
  44504. * @param activeTextures Array of BaseTextures
  44505. */
  44506. getActiveTextures(activeTextures: BaseTexture[]): void;
  44507. /**
  44508. * Returns the animatable textures.
  44509. * @param animatables Array of animatable textures.
  44510. */
  44511. getAnimatables(animatables: IAnimatable[]): void;
  44512. /**
  44513. * Disposes the resources of the material.
  44514. * @param forceDisposeTextures - Forces the disposal of all textures.
  44515. */
  44516. dispose(forceDisposeTextures?: boolean): void;
  44517. /**
  44518. * Get the current class name of the texture useful for serialization or dynamic coding.
  44519. * @returns "PBRSheenConfiguration"
  44520. */
  44521. getClassName(): string;
  44522. /**
  44523. * Add fallbacks to the effect fallbacks list.
  44524. * @param defines defines the Base texture to use.
  44525. * @param fallbacks defines the current fallback list.
  44526. * @param currentRank defines the current fallback rank.
  44527. * @returns the new fallback rank.
  44528. */
  44529. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44530. /**
  44531. * Add the required uniforms to the current list.
  44532. * @param uniforms defines the current uniform list.
  44533. */
  44534. static AddUniforms(uniforms: string[]): void;
  44535. /**
  44536. * Add the required uniforms to the current buffer.
  44537. * @param uniformBuffer defines the current uniform buffer.
  44538. */
  44539. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44540. /**
  44541. * Add the required samplers to the current list.
  44542. * @param samplers defines the current sampler list.
  44543. */
  44544. static AddSamplers(samplers: string[]): void;
  44545. /**
  44546. * Makes a duplicate of the current configuration into another one.
  44547. * @param sheenConfiguration define the config where to copy the info
  44548. */
  44549. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44550. /**
  44551. * Serializes this BRDF configuration.
  44552. * @returns - An object with the serialized config.
  44553. */
  44554. serialize(): any;
  44555. /**
  44556. * Parses a Sheen Configuration from a serialized object.
  44557. * @param source - Serialized object.
  44558. */
  44559. parse(source: any): void;
  44560. }
  44561. }
  44562. declare module BABYLON {
  44563. /**
  44564. * @hidden
  44565. */
  44566. export interface IMaterialSubSurfaceDefines {
  44567. SUBSURFACE: boolean;
  44568. SS_REFRACTION: boolean;
  44569. SS_TRANSLUCENCY: boolean;
  44570. SS_SCATERRING: boolean;
  44571. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44572. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44573. SS_REFRACTIONMAP_3D: boolean;
  44574. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44575. SS_LODINREFRACTIONALPHA: boolean;
  44576. SS_GAMMAREFRACTION: boolean;
  44577. SS_RGBDREFRACTION: boolean;
  44578. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44579. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44580. /** @hidden */
  44581. _areTexturesDirty: boolean;
  44582. }
  44583. /**
  44584. * Define the code related to the sub surface parameters of the pbr material.
  44585. */
  44586. export class PBRSubSurfaceConfiguration {
  44587. private _isRefractionEnabled;
  44588. /**
  44589. * Defines if the refraction is enabled in the material.
  44590. */
  44591. isRefractionEnabled: boolean;
  44592. private _isTranslucencyEnabled;
  44593. /**
  44594. * Defines if the translucency is enabled in the material.
  44595. */
  44596. isTranslucencyEnabled: boolean;
  44597. private _isScatteringEnabled;
  44598. /**
  44599. * Defines the refraction intensity of the material.
  44600. * The refraction when enabled replaces the Diffuse part of the material.
  44601. * The intensity helps transitionning between diffuse and refraction.
  44602. */
  44603. refractionIntensity: number;
  44604. /**
  44605. * Defines the translucency intensity of the material.
  44606. * When translucency has been enabled, this defines how much of the "translucency"
  44607. * is addded to the diffuse part of the material.
  44608. */
  44609. translucencyIntensity: number;
  44610. /**
  44611. * Defines the scattering intensity of the material.
  44612. * When scattering has been enabled, this defines how much of the "scattered light"
  44613. * is addded to the diffuse part of the material.
  44614. */
  44615. scatteringIntensity: number;
  44616. private _thicknessTexture;
  44617. /**
  44618. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  44619. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  44620. * 0 would mean minimumThickness
  44621. * 1 would mean maximumThickness
  44622. * The other channels might be use as a mask to vary the different effects intensity.
  44623. */
  44624. thicknessTexture: Nullable<BaseTexture>;
  44625. private _refractionTexture;
  44626. /**
  44627. * Defines the texture to use for refraction.
  44628. */
  44629. refractionTexture: Nullable<BaseTexture>;
  44630. private _indexOfRefraction;
  44631. /**
  44632. * Defines the indice of refraction used in the material.
  44633. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  44634. */
  44635. indexOfRefraction: number;
  44636. private _invertRefractionY;
  44637. /**
  44638. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44639. */
  44640. invertRefractionY: boolean;
  44641. private _linkRefractionWithTransparency;
  44642. /**
  44643. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44644. * Materials half opaque for instance using refraction could benefit from this control.
  44645. */
  44646. linkRefractionWithTransparency: boolean;
  44647. /**
  44648. * Defines the minimum thickness stored in the thickness map.
  44649. * If no thickness map is defined, this value will be used to simulate thickness.
  44650. */
  44651. minimumThickness: number;
  44652. /**
  44653. * Defines the maximum thickness stored in the thickness map.
  44654. */
  44655. maximumThickness: number;
  44656. /**
  44657. * Defines the volume tint of the material.
  44658. * This is used for both translucency and scattering.
  44659. */
  44660. tintColor: Color3;
  44661. /**
  44662. * Defines the distance at which the tint color should be found in the media.
  44663. * This is used for refraction only.
  44664. */
  44665. tintColorAtDistance: number;
  44666. /**
  44667. * Defines how far each channel transmit through the media.
  44668. * It is defined as a color to simplify it selection.
  44669. */
  44670. diffusionDistance: Color3;
  44671. private _useMaskFromThicknessTexture;
  44672. /**
  44673. * Stores the intensity of the different subsurface effects in the thickness texture.
  44674. * * the green channel is the translucency intensity.
  44675. * * the blue channel is the scattering intensity.
  44676. * * the alpha channel is the refraction intensity.
  44677. */
  44678. useMaskFromThicknessTexture: boolean;
  44679. /** @hidden */
  44680. private _internalMarkAllSubMeshesAsTexturesDirty;
  44681. /** @hidden */
  44682. _markAllSubMeshesAsTexturesDirty(): void;
  44683. /**
  44684. * Instantiate a new istance of sub surface configuration.
  44685. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44686. */
  44687. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44688. /**
  44689. * Gets wehter the submesh is ready to be used or not.
  44690. * @param defines the list of "defines" to update.
  44691. * @param scene defines the scene the material belongs to.
  44692. * @returns - boolean indicating that the submesh is ready or not.
  44693. */
  44694. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  44695. /**
  44696. * Checks to see if a texture is used in the material.
  44697. * @param defines the list of "defines" to update.
  44698. * @param scene defines the scene to the material belongs to.
  44699. */
  44700. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  44701. /**
  44702. * Binds the material data.
  44703. * @param uniformBuffer defines the Uniform buffer to fill in.
  44704. * @param scene defines the scene the material belongs to.
  44705. * @param engine defines the engine the material belongs to.
  44706. * @param isFrozen defines wether the material is frozen or not.
  44707. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  44708. */
  44709. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  44710. /**
  44711. * Unbinds the material from the mesh.
  44712. * @param activeEffect defines the effect that should be unbound from.
  44713. * @returns true if unbound, otherwise false
  44714. */
  44715. unbind(activeEffect: Effect): boolean;
  44716. /**
  44717. * Returns the texture used for refraction or null if none is used.
  44718. * @param scene defines the scene the material belongs to.
  44719. * @returns - Refraction texture if present. If no refraction texture and refraction
  44720. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44721. */
  44722. private _getRefractionTexture;
  44723. /**
  44724. * Returns true if alpha blending should be disabled.
  44725. */
  44726. readonly disableAlphaBlending: boolean;
  44727. /**
  44728. * Fills the list of render target textures.
  44729. * @param renderTargets the list of render targets to update
  44730. */
  44731. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44732. /**
  44733. * Checks to see if a texture is used in the material.
  44734. * @param texture - Base texture to use.
  44735. * @returns - Boolean specifying if a texture is used in the material.
  44736. */
  44737. hasTexture(texture: BaseTexture): boolean;
  44738. /**
  44739. * Gets a boolean indicating that current material needs to register RTT
  44740. * @returns true if this uses a render target otherwise false.
  44741. */
  44742. hasRenderTargetTextures(): boolean;
  44743. /**
  44744. * Returns an array of the actively used textures.
  44745. * @param activeTextures Array of BaseTextures
  44746. */
  44747. getActiveTextures(activeTextures: BaseTexture[]): void;
  44748. /**
  44749. * Returns the animatable textures.
  44750. * @param animatables Array of animatable textures.
  44751. */
  44752. getAnimatables(animatables: IAnimatable[]): void;
  44753. /**
  44754. * Disposes the resources of the material.
  44755. * @param forceDisposeTextures - Forces the disposal of all textures.
  44756. */
  44757. dispose(forceDisposeTextures?: boolean): void;
  44758. /**
  44759. * Get the current class name of the texture useful for serialization or dynamic coding.
  44760. * @returns "PBRSubSurfaceConfiguration"
  44761. */
  44762. getClassName(): string;
  44763. /**
  44764. * Add fallbacks to the effect fallbacks list.
  44765. * @param defines defines the Base texture to use.
  44766. * @param fallbacks defines the current fallback list.
  44767. * @param currentRank defines the current fallback rank.
  44768. * @returns the new fallback rank.
  44769. */
  44770. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44771. /**
  44772. * Add the required uniforms to the current list.
  44773. * @param uniforms defines the current uniform list.
  44774. */
  44775. static AddUniforms(uniforms: string[]): void;
  44776. /**
  44777. * Add the required samplers to the current list.
  44778. * @param samplers defines the current sampler list.
  44779. */
  44780. static AddSamplers(samplers: string[]): void;
  44781. /**
  44782. * Add the required uniforms to the current buffer.
  44783. * @param uniformBuffer defines the current uniform buffer.
  44784. */
  44785. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44786. /**
  44787. * Makes a duplicate of the current configuration into another one.
  44788. * @param configuration define the config where to copy the info
  44789. */
  44790. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44791. /**
  44792. * Serializes this Sub Surface configuration.
  44793. * @returns - An object with the serialized config.
  44794. */
  44795. serialize(): any;
  44796. /**
  44797. * Parses a Sub Surface Configuration from a serialized object.
  44798. * @param source - Serialized object.
  44799. */
  44800. parse(source: any): void;
  44801. }
  44802. }
  44803. declare module BABYLON {
  44804. /** @hidden */
  44805. export var pbrFragmentDeclaration: {
  44806. name: string;
  44807. shader: string;
  44808. };
  44809. }
  44810. declare module BABYLON {
  44811. /** @hidden */
  44812. export var pbrUboDeclaration: {
  44813. name: string;
  44814. shader: string;
  44815. };
  44816. }
  44817. declare module BABYLON {
  44818. /** @hidden */
  44819. export var pbrFragmentExtraDeclaration: {
  44820. name: string;
  44821. shader: string;
  44822. };
  44823. }
  44824. declare module BABYLON {
  44825. /** @hidden */
  44826. export var pbrFragmentSamplersDeclaration: {
  44827. name: string;
  44828. shader: string;
  44829. };
  44830. }
  44831. declare module BABYLON {
  44832. /** @hidden */
  44833. export var pbrHelperFunctions: {
  44834. name: string;
  44835. shader: string;
  44836. };
  44837. }
  44838. declare module BABYLON {
  44839. /** @hidden */
  44840. export var harmonicsFunctions: {
  44841. name: string;
  44842. shader: string;
  44843. };
  44844. }
  44845. declare module BABYLON {
  44846. /** @hidden */
  44847. export var pbrDirectLightingSetupFunctions: {
  44848. name: string;
  44849. shader: string;
  44850. };
  44851. }
  44852. declare module BABYLON {
  44853. /** @hidden */
  44854. export var pbrDirectLightingFalloffFunctions: {
  44855. name: string;
  44856. shader: string;
  44857. };
  44858. }
  44859. declare module BABYLON {
  44860. /** @hidden */
  44861. export var pbrBRDFFunctions: {
  44862. name: string;
  44863. shader: string;
  44864. };
  44865. }
  44866. declare module BABYLON {
  44867. /** @hidden */
  44868. export var pbrDirectLightingFunctions: {
  44869. name: string;
  44870. shader: string;
  44871. };
  44872. }
  44873. declare module BABYLON {
  44874. /** @hidden */
  44875. export var pbrIBLFunctions: {
  44876. name: string;
  44877. shader: string;
  44878. };
  44879. }
  44880. declare module BABYLON {
  44881. /** @hidden */
  44882. export var pbrDebug: {
  44883. name: string;
  44884. shader: string;
  44885. };
  44886. }
  44887. declare module BABYLON {
  44888. /** @hidden */
  44889. export var pbrPixelShader: {
  44890. name: string;
  44891. shader: string;
  44892. };
  44893. }
  44894. declare module BABYLON {
  44895. /** @hidden */
  44896. export var pbrVertexDeclaration: {
  44897. name: string;
  44898. shader: string;
  44899. };
  44900. }
  44901. declare module BABYLON {
  44902. /** @hidden */
  44903. export var pbrVertexShader: {
  44904. name: string;
  44905. shader: string;
  44906. };
  44907. }
  44908. declare module BABYLON {
  44909. /**
  44910. * Manages the defines for the PBR Material.
  44911. * @hidden
  44912. */
  44913. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44914. PBR: boolean;
  44915. MAINUV1: boolean;
  44916. MAINUV2: boolean;
  44917. UV1: boolean;
  44918. UV2: boolean;
  44919. ALBEDO: boolean;
  44920. ALBEDODIRECTUV: number;
  44921. VERTEXCOLOR: boolean;
  44922. AMBIENT: boolean;
  44923. AMBIENTDIRECTUV: number;
  44924. AMBIENTINGRAYSCALE: boolean;
  44925. OPACITY: boolean;
  44926. VERTEXALPHA: boolean;
  44927. OPACITYDIRECTUV: number;
  44928. OPACITYRGB: boolean;
  44929. ALPHATEST: boolean;
  44930. DEPTHPREPASS: boolean;
  44931. ALPHABLEND: boolean;
  44932. ALPHAFROMALBEDO: boolean;
  44933. ALPHATESTVALUE: string;
  44934. SPECULAROVERALPHA: boolean;
  44935. RADIANCEOVERALPHA: boolean;
  44936. ALPHAFRESNEL: boolean;
  44937. LINEARALPHAFRESNEL: boolean;
  44938. PREMULTIPLYALPHA: boolean;
  44939. EMISSIVE: boolean;
  44940. EMISSIVEDIRECTUV: number;
  44941. REFLECTIVITY: boolean;
  44942. REFLECTIVITYDIRECTUV: number;
  44943. SPECULARTERM: boolean;
  44944. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44945. MICROSURFACEAUTOMATIC: boolean;
  44946. LODBASEDMICROSFURACE: boolean;
  44947. MICROSURFACEMAP: boolean;
  44948. MICROSURFACEMAPDIRECTUV: number;
  44949. METALLICWORKFLOW: boolean;
  44950. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44951. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44952. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44953. AOSTOREINMETALMAPRED: boolean;
  44954. ENVIRONMENTBRDF: boolean;
  44955. ENVIRONMENTBRDF_RGBD: boolean;
  44956. NORMAL: boolean;
  44957. TANGENT: boolean;
  44958. BUMP: boolean;
  44959. BUMPDIRECTUV: number;
  44960. OBJECTSPACE_NORMALMAP: boolean;
  44961. PARALLAX: boolean;
  44962. PARALLAXOCCLUSION: boolean;
  44963. NORMALXYSCALE: boolean;
  44964. LIGHTMAP: boolean;
  44965. LIGHTMAPDIRECTUV: number;
  44966. USELIGHTMAPASSHADOWMAP: boolean;
  44967. GAMMALIGHTMAP: boolean;
  44968. REFLECTION: boolean;
  44969. REFLECTIONMAP_3D: boolean;
  44970. REFLECTIONMAP_SPHERICAL: boolean;
  44971. REFLECTIONMAP_PLANAR: boolean;
  44972. REFLECTIONMAP_CUBIC: boolean;
  44973. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44974. REFLECTIONMAP_PROJECTION: boolean;
  44975. REFLECTIONMAP_SKYBOX: boolean;
  44976. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44977. REFLECTIONMAP_EXPLICIT: boolean;
  44978. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44979. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44980. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44981. INVERTCUBICMAP: boolean;
  44982. USESPHERICALFROMREFLECTIONMAP: boolean;
  44983. SPHERICAL_HARMONICS: boolean;
  44984. USESPHERICALINVERTEX: boolean;
  44985. REFLECTIONMAP_OPPOSITEZ: boolean;
  44986. LODINREFLECTIONALPHA: boolean;
  44987. GAMMAREFLECTION: boolean;
  44988. RGBDREFLECTION: boolean;
  44989. RADIANCEOCCLUSION: boolean;
  44990. HORIZONOCCLUSION: boolean;
  44991. INSTANCES: boolean;
  44992. NUM_BONE_INFLUENCERS: number;
  44993. BonesPerMesh: number;
  44994. BONETEXTURE: boolean;
  44995. NONUNIFORMSCALING: boolean;
  44996. MORPHTARGETS: boolean;
  44997. MORPHTARGETS_NORMAL: boolean;
  44998. MORPHTARGETS_TANGENT: boolean;
  44999. NUM_MORPH_INFLUENCERS: number;
  45000. IMAGEPROCESSING: boolean;
  45001. VIGNETTE: boolean;
  45002. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45003. VIGNETTEBLENDMODEOPAQUE: boolean;
  45004. TONEMAPPING: boolean;
  45005. TONEMAPPING_ACES: boolean;
  45006. CONTRAST: boolean;
  45007. COLORCURVES: boolean;
  45008. COLORGRADING: boolean;
  45009. COLORGRADING3D: boolean;
  45010. SAMPLER3DGREENDEPTH: boolean;
  45011. SAMPLER3DBGRMAP: boolean;
  45012. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45013. EXPOSURE: boolean;
  45014. MULTIVIEW: boolean;
  45015. USEPHYSICALLIGHTFALLOFF: boolean;
  45016. USEGLTFLIGHTFALLOFF: boolean;
  45017. TWOSIDEDLIGHTING: boolean;
  45018. SHADOWFLOAT: boolean;
  45019. CLIPPLANE: boolean;
  45020. CLIPPLANE2: boolean;
  45021. CLIPPLANE3: boolean;
  45022. CLIPPLANE4: boolean;
  45023. POINTSIZE: boolean;
  45024. FOG: boolean;
  45025. LOGARITHMICDEPTH: boolean;
  45026. FORCENORMALFORWARD: boolean;
  45027. SPECULARAA: boolean;
  45028. CLEARCOAT: boolean;
  45029. CLEARCOAT_DEFAULTIOR: boolean;
  45030. CLEARCOAT_TEXTURE: boolean;
  45031. CLEARCOAT_TEXTUREDIRECTUV: number;
  45032. CLEARCOAT_BUMP: boolean;
  45033. CLEARCOAT_BUMPDIRECTUV: number;
  45034. CLEARCOAT_TINT: boolean;
  45035. CLEARCOAT_TINT_TEXTURE: boolean;
  45036. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45037. ANISOTROPIC: boolean;
  45038. ANISOTROPIC_TEXTURE: boolean;
  45039. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45040. BRDF_V_HEIGHT_CORRELATED: boolean;
  45041. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45042. SHEEN: boolean;
  45043. SHEEN_TEXTURE: boolean;
  45044. SHEEN_TEXTUREDIRECTUV: number;
  45045. SHEEN_LINKWITHALBEDO: boolean;
  45046. SUBSURFACE: boolean;
  45047. SS_REFRACTION: boolean;
  45048. SS_TRANSLUCENCY: boolean;
  45049. SS_SCATERRING: boolean;
  45050. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45051. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45052. SS_REFRACTIONMAP_3D: boolean;
  45053. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45054. SS_LODINREFRACTIONALPHA: boolean;
  45055. SS_GAMMAREFRACTION: boolean;
  45056. SS_RGBDREFRACTION: boolean;
  45057. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45058. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45059. UNLIT: boolean;
  45060. DEBUGMODE: number;
  45061. /**
  45062. * Initializes the PBR Material defines.
  45063. */
  45064. constructor();
  45065. /**
  45066. * Resets the PBR Material defines.
  45067. */
  45068. reset(): void;
  45069. }
  45070. /**
  45071. * The Physically based material base class of BJS.
  45072. *
  45073. * This offers the main features of a standard PBR material.
  45074. * For more information, please refer to the documentation :
  45075. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45076. */
  45077. export abstract class PBRBaseMaterial extends PushMaterial {
  45078. /**
  45079. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45080. */
  45081. static readonly PBRMATERIAL_OPAQUE: number;
  45082. /**
  45083. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45084. */
  45085. static readonly PBRMATERIAL_ALPHATEST: number;
  45086. /**
  45087. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45088. */
  45089. static readonly PBRMATERIAL_ALPHABLEND: number;
  45090. /**
  45091. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45092. * They are also discarded below the alpha cutoff threshold to improve performances.
  45093. */
  45094. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45095. /**
  45096. * Defines the default value of how much AO map is occluding the analytical lights
  45097. * (point spot...).
  45098. */
  45099. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45100. /**
  45101. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45102. */
  45103. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45104. /**
  45105. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45106. * to enhance interoperability with other engines.
  45107. */
  45108. static readonly LIGHTFALLOFF_GLTF: number;
  45109. /**
  45110. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45111. * to enhance interoperability with other materials.
  45112. */
  45113. static readonly LIGHTFALLOFF_STANDARD: number;
  45114. /**
  45115. * Intensity of the direct lights e.g. the four lights available in your scene.
  45116. * This impacts both the direct diffuse and specular highlights.
  45117. */
  45118. protected _directIntensity: number;
  45119. /**
  45120. * Intensity of the emissive part of the material.
  45121. * This helps controlling the emissive effect without modifying the emissive color.
  45122. */
  45123. protected _emissiveIntensity: number;
  45124. /**
  45125. * Intensity of the environment e.g. how much the environment will light the object
  45126. * either through harmonics for rough material or through the refelction for shiny ones.
  45127. */
  45128. protected _environmentIntensity: number;
  45129. /**
  45130. * This is a special control allowing the reduction of the specular highlights coming from the
  45131. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45132. */
  45133. protected _specularIntensity: number;
  45134. /**
  45135. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45136. */
  45137. private _lightingInfos;
  45138. /**
  45139. * Debug Control allowing disabling the bump map on this material.
  45140. */
  45141. protected _disableBumpMap: boolean;
  45142. /**
  45143. * AKA Diffuse Texture in standard nomenclature.
  45144. */
  45145. protected _albedoTexture: Nullable<BaseTexture>;
  45146. /**
  45147. * AKA Occlusion Texture in other nomenclature.
  45148. */
  45149. protected _ambientTexture: Nullable<BaseTexture>;
  45150. /**
  45151. * AKA Occlusion Texture Intensity in other nomenclature.
  45152. */
  45153. protected _ambientTextureStrength: number;
  45154. /**
  45155. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45156. * 1 means it completely occludes it
  45157. * 0 mean it has no impact
  45158. */
  45159. protected _ambientTextureImpactOnAnalyticalLights: number;
  45160. /**
  45161. * Stores the alpha values in a texture.
  45162. */
  45163. protected _opacityTexture: Nullable<BaseTexture>;
  45164. /**
  45165. * Stores the reflection values in a texture.
  45166. */
  45167. protected _reflectionTexture: Nullable<BaseTexture>;
  45168. /**
  45169. * Stores the emissive values in a texture.
  45170. */
  45171. protected _emissiveTexture: Nullable<BaseTexture>;
  45172. /**
  45173. * AKA Specular texture in other nomenclature.
  45174. */
  45175. protected _reflectivityTexture: Nullable<BaseTexture>;
  45176. /**
  45177. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45178. */
  45179. protected _metallicTexture: Nullable<BaseTexture>;
  45180. /**
  45181. * Specifies the metallic scalar of the metallic/roughness workflow.
  45182. * Can also be used to scale the metalness values of the metallic texture.
  45183. */
  45184. protected _metallic: Nullable<number>;
  45185. /**
  45186. * Specifies the roughness scalar of the metallic/roughness workflow.
  45187. * Can also be used to scale the roughness values of the metallic texture.
  45188. */
  45189. protected _roughness: Nullable<number>;
  45190. /**
  45191. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45192. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45193. */
  45194. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45195. /**
  45196. * Stores surface normal data used to displace a mesh in a texture.
  45197. */
  45198. protected _bumpTexture: Nullable<BaseTexture>;
  45199. /**
  45200. * Stores the pre-calculated light information of a mesh in a texture.
  45201. */
  45202. protected _lightmapTexture: Nullable<BaseTexture>;
  45203. /**
  45204. * The color of a material in ambient lighting.
  45205. */
  45206. protected _ambientColor: Color3;
  45207. /**
  45208. * AKA Diffuse Color in other nomenclature.
  45209. */
  45210. protected _albedoColor: Color3;
  45211. /**
  45212. * AKA Specular Color in other nomenclature.
  45213. */
  45214. protected _reflectivityColor: Color3;
  45215. /**
  45216. * The color applied when light is reflected from a material.
  45217. */
  45218. protected _reflectionColor: Color3;
  45219. /**
  45220. * The color applied when light is emitted from a material.
  45221. */
  45222. protected _emissiveColor: Color3;
  45223. /**
  45224. * AKA Glossiness in other nomenclature.
  45225. */
  45226. protected _microSurface: number;
  45227. /**
  45228. * Specifies that the material will use the light map as a show map.
  45229. */
  45230. protected _useLightmapAsShadowmap: boolean;
  45231. /**
  45232. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45233. * makes the reflect vector face the model (under horizon).
  45234. */
  45235. protected _useHorizonOcclusion: boolean;
  45236. /**
  45237. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45238. * too much the area relying on ambient texture to define their ambient occlusion.
  45239. */
  45240. protected _useRadianceOcclusion: boolean;
  45241. /**
  45242. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45243. */
  45244. protected _useAlphaFromAlbedoTexture: boolean;
  45245. /**
  45246. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45247. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45248. */
  45249. protected _useSpecularOverAlpha: boolean;
  45250. /**
  45251. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45252. */
  45253. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45254. /**
  45255. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45256. */
  45257. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45258. /**
  45259. * Specifies if the metallic texture contains the roughness information in its green channel.
  45260. */
  45261. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45262. /**
  45263. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45264. */
  45265. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45266. /**
  45267. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45268. */
  45269. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45270. /**
  45271. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45272. */
  45273. protected _useAmbientInGrayScale: boolean;
  45274. /**
  45275. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45276. * The material will try to infer what glossiness each pixel should be.
  45277. */
  45278. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45279. /**
  45280. * Defines the falloff type used in this material.
  45281. * It by default is Physical.
  45282. */
  45283. protected _lightFalloff: number;
  45284. /**
  45285. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45286. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45287. */
  45288. protected _useRadianceOverAlpha: boolean;
  45289. /**
  45290. * Allows using an object space normal map (instead of tangent space).
  45291. */
  45292. protected _useObjectSpaceNormalMap: boolean;
  45293. /**
  45294. * Allows using the bump map in parallax mode.
  45295. */
  45296. protected _useParallax: boolean;
  45297. /**
  45298. * Allows using the bump map in parallax occlusion mode.
  45299. */
  45300. protected _useParallaxOcclusion: boolean;
  45301. /**
  45302. * Controls the scale bias of the parallax mode.
  45303. */
  45304. protected _parallaxScaleBias: number;
  45305. /**
  45306. * If sets to true, disables all the lights affecting the material.
  45307. */
  45308. protected _disableLighting: boolean;
  45309. /**
  45310. * Number of Simultaneous lights allowed on the material.
  45311. */
  45312. protected _maxSimultaneousLights: number;
  45313. /**
  45314. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45315. */
  45316. protected _invertNormalMapX: boolean;
  45317. /**
  45318. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45319. */
  45320. protected _invertNormalMapY: boolean;
  45321. /**
  45322. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45323. */
  45324. protected _twoSidedLighting: boolean;
  45325. /**
  45326. * Defines the alpha limits in alpha test mode.
  45327. */
  45328. protected _alphaCutOff: number;
  45329. /**
  45330. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45331. */
  45332. protected _forceAlphaTest: boolean;
  45333. /**
  45334. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45335. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45336. */
  45337. protected _useAlphaFresnel: boolean;
  45338. /**
  45339. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45340. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45341. */
  45342. protected _useLinearAlphaFresnel: boolean;
  45343. /**
  45344. * The transparency mode of the material.
  45345. */
  45346. protected _transparencyMode: Nullable<number>;
  45347. /**
  45348. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45349. * from cos thetav and roughness:
  45350. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45351. */
  45352. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45353. /**
  45354. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45355. */
  45356. protected _forceIrradianceInFragment: boolean;
  45357. /**
  45358. * Force normal to face away from face.
  45359. */
  45360. protected _forceNormalForward: boolean;
  45361. /**
  45362. * Enables specular anti aliasing in the PBR shader.
  45363. * It will both interacts on the Geometry for analytical and IBL lighting.
  45364. * It also prefilter the roughness map based on the bump values.
  45365. */
  45366. protected _enableSpecularAntiAliasing: boolean;
  45367. /**
  45368. * Default configuration related to image processing available in the PBR Material.
  45369. */
  45370. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45371. /**
  45372. * Keep track of the image processing observer to allow dispose and replace.
  45373. */
  45374. private _imageProcessingObserver;
  45375. /**
  45376. * Attaches a new image processing configuration to the PBR Material.
  45377. * @param configuration
  45378. */
  45379. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45380. /**
  45381. * Stores the available render targets.
  45382. */
  45383. private _renderTargets;
  45384. /**
  45385. * Sets the global ambient color for the material used in lighting calculations.
  45386. */
  45387. private _globalAmbientColor;
  45388. /**
  45389. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45390. */
  45391. private _useLogarithmicDepth;
  45392. /**
  45393. * If set to true, no lighting calculations will be applied.
  45394. */
  45395. private _unlit;
  45396. private _debugMode;
  45397. /**
  45398. * @hidden
  45399. * This is reserved for the inspector.
  45400. * Defines the material debug mode.
  45401. * It helps seeing only some components of the material while troubleshooting.
  45402. */
  45403. debugMode: number;
  45404. /**
  45405. * @hidden
  45406. * This is reserved for the inspector.
  45407. * Specify from where on screen the debug mode should start.
  45408. * The value goes from -1 (full screen) to 1 (not visible)
  45409. * It helps with side by side comparison against the final render
  45410. * This defaults to -1
  45411. */
  45412. private debugLimit;
  45413. /**
  45414. * @hidden
  45415. * This is reserved for the inspector.
  45416. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45417. * You can use the factor to better multiply the final value.
  45418. */
  45419. private debugFactor;
  45420. /**
  45421. * Defines the clear coat layer parameters for the material.
  45422. */
  45423. readonly clearCoat: PBRClearCoatConfiguration;
  45424. /**
  45425. * Defines the anisotropic parameters for the material.
  45426. */
  45427. readonly anisotropy: PBRAnisotropicConfiguration;
  45428. /**
  45429. * Defines the BRDF parameters for the material.
  45430. */
  45431. readonly brdf: PBRBRDFConfiguration;
  45432. /**
  45433. * Defines the Sheen parameters for the material.
  45434. */
  45435. readonly sheen: PBRSheenConfiguration;
  45436. /**
  45437. * Defines the SubSurface parameters for the material.
  45438. */
  45439. readonly subSurface: PBRSubSurfaceConfiguration;
  45440. /**
  45441. * Custom callback helping to override the default shader used in the material.
  45442. */
  45443. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45444. /**
  45445. * Instantiates a new PBRMaterial instance.
  45446. *
  45447. * @param name The material name
  45448. * @param scene The scene the material will be use in.
  45449. */
  45450. constructor(name: string, scene: Scene);
  45451. /**
  45452. * Gets a boolean indicating that current material needs to register RTT
  45453. */
  45454. readonly hasRenderTargetTextures: boolean;
  45455. /**
  45456. * Gets the name of the material class.
  45457. */
  45458. getClassName(): string;
  45459. /**
  45460. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45461. */
  45462. /**
  45463. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45464. */
  45465. useLogarithmicDepth: boolean;
  45466. /**
  45467. * Gets the current transparency mode.
  45468. */
  45469. /**
  45470. * Sets the transparency mode of the material.
  45471. *
  45472. * | Value | Type | Description |
  45473. * | ----- | ----------------------------------- | ----------- |
  45474. * | 0 | OPAQUE | |
  45475. * | 1 | ALPHATEST | |
  45476. * | 2 | ALPHABLEND | |
  45477. * | 3 | ALPHATESTANDBLEND | |
  45478. *
  45479. */
  45480. transparencyMode: Nullable<number>;
  45481. /**
  45482. * Returns true if alpha blending should be disabled.
  45483. */
  45484. private readonly _disableAlphaBlending;
  45485. /**
  45486. * Specifies whether or not this material should be rendered in alpha blend mode.
  45487. */
  45488. needAlphaBlending(): boolean;
  45489. /**
  45490. * Specifies if the mesh will require alpha blending.
  45491. * @param mesh - BJS mesh.
  45492. */
  45493. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45494. /**
  45495. * Specifies whether or not this material should be rendered in alpha test mode.
  45496. */
  45497. needAlphaTesting(): boolean;
  45498. /**
  45499. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45500. */
  45501. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45502. /**
  45503. * Gets the texture used for the alpha test.
  45504. */
  45505. getAlphaTestTexture(): Nullable<BaseTexture>;
  45506. /**
  45507. * Specifies that the submesh is ready to be used.
  45508. * @param mesh - BJS mesh.
  45509. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45510. * @param useInstances - Specifies that instances should be used.
  45511. * @returns - boolean indicating that the submesh is ready or not.
  45512. */
  45513. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45514. /**
  45515. * Specifies if the material uses metallic roughness workflow.
  45516. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45517. */
  45518. isMetallicWorkflow(): boolean;
  45519. private _prepareEffect;
  45520. private _prepareDefines;
  45521. /**
  45522. * Force shader compilation
  45523. */
  45524. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45525. clipPlane: boolean;
  45526. }>): void;
  45527. /**
  45528. * Initializes the uniform buffer layout for the shader.
  45529. */
  45530. buildUniformLayout(): void;
  45531. /**
  45532. * Unbinds the material from the mesh
  45533. */
  45534. unbind(): void;
  45535. /**
  45536. * Binds the submesh data.
  45537. * @param world - The world matrix.
  45538. * @param mesh - The BJS mesh.
  45539. * @param subMesh - A submesh of the BJS mesh.
  45540. */
  45541. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45542. /**
  45543. * Returns the animatable textures.
  45544. * @returns - Array of animatable textures.
  45545. */
  45546. getAnimatables(): IAnimatable[];
  45547. /**
  45548. * Returns the texture used for reflections.
  45549. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45550. */
  45551. private _getReflectionTexture;
  45552. /**
  45553. * Returns an array of the actively used textures.
  45554. * @returns - Array of BaseTextures
  45555. */
  45556. getActiveTextures(): BaseTexture[];
  45557. /**
  45558. * Checks to see if a texture is used in the material.
  45559. * @param texture - Base texture to use.
  45560. * @returns - Boolean specifying if a texture is used in the material.
  45561. */
  45562. hasTexture(texture: BaseTexture): boolean;
  45563. /**
  45564. * Disposes the resources of the material.
  45565. * @param forceDisposeEffect - Forces the disposal of effects.
  45566. * @param forceDisposeTextures - Forces the disposal of all textures.
  45567. */
  45568. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45569. }
  45570. }
  45571. declare module BABYLON {
  45572. /**
  45573. * The Physically based material of BJS.
  45574. *
  45575. * This offers the main features of a standard PBR material.
  45576. * For more information, please refer to the documentation :
  45577. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45578. */
  45579. export class PBRMaterial extends PBRBaseMaterial {
  45580. /**
  45581. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45582. */
  45583. static readonly PBRMATERIAL_OPAQUE: number;
  45584. /**
  45585. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45586. */
  45587. static readonly PBRMATERIAL_ALPHATEST: number;
  45588. /**
  45589. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45590. */
  45591. static readonly PBRMATERIAL_ALPHABLEND: number;
  45592. /**
  45593. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45594. * They are also discarded below the alpha cutoff threshold to improve performances.
  45595. */
  45596. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45597. /**
  45598. * Defines the default value of how much AO map is occluding the analytical lights
  45599. * (point spot...).
  45600. */
  45601. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45602. /**
  45603. * Intensity of the direct lights e.g. the four lights available in your scene.
  45604. * This impacts both the direct diffuse and specular highlights.
  45605. */
  45606. directIntensity: number;
  45607. /**
  45608. * Intensity of the emissive part of the material.
  45609. * This helps controlling the emissive effect without modifying the emissive color.
  45610. */
  45611. emissiveIntensity: number;
  45612. /**
  45613. * Intensity of the environment e.g. how much the environment will light the object
  45614. * either through harmonics for rough material or through the refelction for shiny ones.
  45615. */
  45616. environmentIntensity: number;
  45617. /**
  45618. * This is a special control allowing the reduction of the specular highlights coming from the
  45619. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45620. */
  45621. specularIntensity: number;
  45622. /**
  45623. * Debug Control allowing disabling the bump map on this material.
  45624. */
  45625. disableBumpMap: boolean;
  45626. /**
  45627. * AKA Diffuse Texture in standard nomenclature.
  45628. */
  45629. albedoTexture: BaseTexture;
  45630. /**
  45631. * AKA Occlusion Texture in other nomenclature.
  45632. */
  45633. ambientTexture: BaseTexture;
  45634. /**
  45635. * AKA Occlusion Texture Intensity in other nomenclature.
  45636. */
  45637. ambientTextureStrength: number;
  45638. /**
  45639. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45640. * 1 means it completely occludes it
  45641. * 0 mean it has no impact
  45642. */
  45643. ambientTextureImpactOnAnalyticalLights: number;
  45644. /**
  45645. * Stores the alpha values in a texture.
  45646. */
  45647. opacityTexture: BaseTexture;
  45648. /**
  45649. * Stores the reflection values in a texture.
  45650. */
  45651. reflectionTexture: Nullable<BaseTexture>;
  45652. /**
  45653. * Stores the emissive values in a texture.
  45654. */
  45655. emissiveTexture: BaseTexture;
  45656. /**
  45657. * AKA Specular texture in other nomenclature.
  45658. */
  45659. reflectivityTexture: BaseTexture;
  45660. /**
  45661. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45662. */
  45663. metallicTexture: BaseTexture;
  45664. /**
  45665. * Specifies the metallic scalar of the metallic/roughness workflow.
  45666. * Can also be used to scale the metalness values of the metallic texture.
  45667. */
  45668. metallic: Nullable<number>;
  45669. /**
  45670. * Specifies the roughness scalar of the metallic/roughness workflow.
  45671. * Can also be used to scale the roughness values of the metallic texture.
  45672. */
  45673. roughness: Nullable<number>;
  45674. /**
  45675. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45676. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45677. */
  45678. microSurfaceTexture: BaseTexture;
  45679. /**
  45680. * Stores surface normal data used to displace a mesh in a texture.
  45681. */
  45682. bumpTexture: BaseTexture;
  45683. /**
  45684. * Stores the pre-calculated light information of a mesh in a texture.
  45685. */
  45686. lightmapTexture: BaseTexture;
  45687. /**
  45688. * Stores the refracted light information in a texture.
  45689. */
  45690. refractionTexture: Nullable<BaseTexture>;
  45691. /**
  45692. * The color of a material in ambient lighting.
  45693. */
  45694. ambientColor: Color3;
  45695. /**
  45696. * AKA Diffuse Color in other nomenclature.
  45697. */
  45698. albedoColor: Color3;
  45699. /**
  45700. * AKA Specular Color in other nomenclature.
  45701. */
  45702. reflectivityColor: Color3;
  45703. /**
  45704. * The color reflected from the material.
  45705. */
  45706. reflectionColor: Color3;
  45707. /**
  45708. * The color emitted from the material.
  45709. */
  45710. emissiveColor: Color3;
  45711. /**
  45712. * AKA Glossiness in other nomenclature.
  45713. */
  45714. microSurface: number;
  45715. /**
  45716. * source material index of refraction (IOR)' / 'destination material IOR.
  45717. */
  45718. indexOfRefraction: number;
  45719. /**
  45720. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45721. */
  45722. invertRefractionY: boolean;
  45723. /**
  45724. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45725. * Materials half opaque for instance using refraction could benefit from this control.
  45726. */
  45727. linkRefractionWithTransparency: boolean;
  45728. /**
  45729. * If true, the light map contains occlusion information instead of lighting info.
  45730. */
  45731. useLightmapAsShadowmap: boolean;
  45732. /**
  45733. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45734. */
  45735. useAlphaFromAlbedoTexture: boolean;
  45736. /**
  45737. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45738. */
  45739. forceAlphaTest: boolean;
  45740. /**
  45741. * Defines the alpha limits in alpha test mode.
  45742. */
  45743. alphaCutOff: number;
  45744. /**
  45745. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45746. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45747. */
  45748. useSpecularOverAlpha: boolean;
  45749. /**
  45750. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45751. */
  45752. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45753. /**
  45754. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45755. */
  45756. useRoughnessFromMetallicTextureAlpha: boolean;
  45757. /**
  45758. * Specifies if the metallic texture contains the roughness information in its green channel.
  45759. */
  45760. useRoughnessFromMetallicTextureGreen: boolean;
  45761. /**
  45762. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45763. */
  45764. useMetallnessFromMetallicTextureBlue: boolean;
  45765. /**
  45766. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45767. */
  45768. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45769. /**
  45770. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45771. */
  45772. useAmbientInGrayScale: boolean;
  45773. /**
  45774. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45775. * The material will try to infer what glossiness each pixel should be.
  45776. */
  45777. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45778. /**
  45779. * BJS is using an harcoded light falloff based on a manually sets up range.
  45780. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45781. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45782. */
  45783. /**
  45784. * BJS is using an harcoded light falloff based on a manually sets up range.
  45785. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45786. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45787. */
  45788. usePhysicalLightFalloff: boolean;
  45789. /**
  45790. * In order to support the falloff compatibility with gltf, a special mode has been added
  45791. * to reproduce the gltf light falloff.
  45792. */
  45793. /**
  45794. * In order to support the falloff compatibility with gltf, a special mode has been added
  45795. * to reproduce the gltf light falloff.
  45796. */
  45797. useGLTFLightFalloff: boolean;
  45798. /**
  45799. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45800. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45801. */
  45802. useRadianceOverAlpha: boolean;
  45803. /**
  45804. * Allows using an object space normal map (instead of tangent space).
  45805. */
  45806. useObjectSpaceNormalMap: boolean;
  45807. /**
  45808. * Allows using the bump map in parallax mode.
  45809. */
  45810. useParallax: boolean;
  45811. /**
  45812. * Allows using the bump map in parallax occlusion mode.
  45813. */
  45814. useParallaxOcclusion: boolean;
  45815. /**
  45816. * Controls the scale bias of the parallax mode.
  45817. */
  45818. parallaxScaleBias: number;
  45819. /**
  45820. * If sets to true, disables all the lights affecting the material.
  45821. */
  45822. disableLighting: boolean;
  45823. /**
  45824. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45825. */
  45826. forceIrradianceInFragment: boolean;
  45827. /**
  45828. * Number of Simultaneous lights allowed on the material.
  45829. */
  45830. maxSimultaneousLights: number;
  45831. /**
  45832. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45833. */
  45834. invertNormalMapX: boolean;
  45835. /**
  45836. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45837. */
  45838. invertNormalMapY: boolean;
  45839. /**
  45840. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45841. */
  45842. twoSidedLighting: boolean;
  45843. /**
  45844. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45845. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45846. */
  45847. useAlphaFresnel: boolean;
  45848. /**
  45849. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45850. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45851. */
  45852. useLinearAlphaFresnel: boolean;
  45853. /**
  45854. * Let user defines the brdf lookup texture used for IBL.
  45855. * A default 8bit version is embedded but you could point at :
  45856. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45857. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45858. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45859. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45860. */
  45861. environmentBRDFTexture: Nullable<BaseTexture>;
  45862. /**
  45863. * Force normal to face away from face.
  45864. */
  45865. forceNormalForward: boolean;
  45866. /**
  45867. * Enables specular anti aliasing in the PBR shader.
  45868. * It will both interacts on the Geometry for analytical and IBL lighting.
  45869. * It also prefilter the roughness map based on the bump values.
  45870. */
  45871. enableSpecularAntiAliasing: boolean;
  45872. /**
  45873. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45874. * makes the reflect vector face the model (under horizon).
  45875. */
  45876. useHorizonOcclusion: boolean;
  45877. /**
  45878. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45879. * too much the area relying on ambient texture to define their ambient occlusion.
  45880. */
  45881. useRadianceOcclusion: boolean;
  45882. /**
  45883. * If set to true, no lighting calculations will be applied.
  45884. */
  45885. unlit: boolean;
  45886. /**
  45887. * Gets the image processing configuration used either in this material.
  45888. */
  45889. /**
  45890. * Sets the Default image processing configuration used either in the this material.
  45891. *
  45892. * If sets to null, the scene one is in use.
  45893. */
  45894. imageProcessingConfiguration: ImageProcessingConfiguration;
  45895. /**
  45896. * Gets wether the color curves effect is enabled.
  45897. */
  45898. /**
  45899. * Sets wether the color curves effect is enabled.
  45900. */
  45901. cameraColorCurvesEnabled: boolean;
  45902. /**
  45903. * Gets wether the color grading effect is enabled.
  45904. */
  45905. /**
  45906. * Gets wether the color grading effect is enabled.
  45907. */
  45908. cameraColorGradingEnabled: boolean;
  45909. /**
  45910. * Gets wether tonemapping is enabled or not.
  45911. */
  45912. /**
  45913. * Sets wether tonemapping is enabled or not
  45914. */
  45915. cameraToneMappingEnabled: boolean;
  45916. /**
  45917. * The camera exposure used on this material.
  45918. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45919. * This corresponds to a photographic exposure.
  45920. */
  45921. /**
  45922. * The camera exposure used on this material.
  45923. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45924. * This corresponds to a photographic exposure.
  45925. */
  45926. cameraExposure: number;
  45927. /**
  45928. * Gets The camera contrast used on this material.
  45929. */
  45930. /**
  45931. * Sets The camera contrast used on this material.
  45932. */
  45933. cameraContrast: number;
  45934. /**
  45935. * Gets the Color Grading 2D Lookup Texture.
  45936. */
  45937. /**
  45938. * Sets the Color Grading 2D Lookup Texture.
  45939. */
  45940. cameraColorGradingTexture: Nullable<BaseTexture>;
  45941. /**
  45942. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45943. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45944. * 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;
  45945. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45946. */
  45947. /**
  45948. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45949. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45950. * 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;
  45951. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45952. */
  45953. cameraColorCurves: Nullable<ColorCurves>;
  45954. /**
  45955. * Instantiates a new PBRMaterial instance.
  45956. *
  45957. * @param name The material name
  45958. * @param scene The scene the material will be use in.
  45959. */
  45960. constructor(name: string, scene: Scene);
  45961. /**
  45962. * Returns the name of this material class.
  45963. */
  45964. getClassName(): string;
  45965. /**
  45966. * Makes a duplicate of the current material.
  45967. * @param name - name to use for the new material.
  45968. */
  45969. clone(name: string): PBRMaterial;
  45970. /**
  45971. * Serializes this PBR Material.
  45972. * @returns - An object with the serialized material.
  45973. */
  45974. serialize(): any;
  45975. /**
  45976. * Parses a PBR Material from a serialized object.
  45977. * @param source - Serialized object.
  45978. * @param scene - BJS scene instance.
  45979. * @param rootUrl - url for the scene object
  45980. * @returns - PBRMaterial
  45981. */
  45982. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45983. }
  45984. }
  45985. declare module BABYLON {
  45986. /**
  45987. * Direct draw surface info
  45988. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45989. */
  45990. export interface DDSInfo {
  45991. /**
  45992. * Width of the texture
  45993. */
  45994. width: number;
  45995. /**
  45996. * Width of the texture
  45997. */
  45998. height: number;
  45999. /**
  46000. * Number of Mipmaps for the texture
  46001. * @see https://en.wikipedia.org/wiki/Mipmap
  46002. */
  46003. mipmapCount: number;
  46004. /**
  46005. * If the textures format is a known fourCC format
  46006. * @see https://www.fourcc.org/
  46007. */
  46008. isFourCC: boolean;
  46009. /**
  46010. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46011. */
  46012. isRGB: boolean;
  46013. /**
  46014. * If the texture is a lumincance format
  46015. */
  46016. isLuminance: boolean;
  46017. /**
  46018. * If this is a cube texture
  46019. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46020. */
  46021. isCube: boolean;
  46022. /**
  46023. * If the texture is a compressed format eg. FOURCC_DXT1
  46024. */
  46025. isCompressed: boolean;
  46026. /**
  46027. * The dxgiFormat of the texture
  46028. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46029. */
  46030. dxgiFormat: number;
  46031. /**
  46032. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46033. */
  46034. textureType: number;
  46035. /**
  46036. * Sphericle polynomial created for the dds texture
  46037. */
  46038. sphericalPolynomial?: SphericalPolynomial;
  46039. }
  46040. /**
  46041. * Class used to provide DDS decompression tools
  46042. */
  46043. export class DDSTools {
  46044. /**
  46045. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46046. */
  46047. static StoreLODInAlphaChannel: boolean;
  46048. /**
  46049. * Gets DDS information from an array buffer
  46050. * @param arrayBuffer defines the array buffer to read data from
  46051. * @returns the DDS information
  46052. */
  46053. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46054. private static _FloatView;
  46055. private static _Int32View;
  46056. private static _ToHalfFloat;
  46057. private static _FromHalfFloat;
  46058. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46059. private static _GetHalfFloatRGBAArrayBuffer;
  46060. private static _GetFloatRGBAArrayBuffer;
  46061. private static _GetFloatAsUIntRGBAArrayBuffer;
  46062. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46063. private static _GetRGBAArrayBuffer;
  46064. private static _ExtractLongWordOrder;
  46065. private static _GetRGBArrayBuffer;
  46066. private static _GetLuminanceArrayBuffer;
  46067. /**
  46068. * Uploads DDS Levels to a Babylon Texture
  46069. * @hidden
  46070. */
  46071. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46072. }
  46073. interface Engine {
  46074. /**
  46075. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46076. * @param rootUrl defines the url where the file to load is located
  46077. * @param scene defines the current scene
  46078. * @param lodScale defines scale to apply to the mip map selection
  46079. * @param lodOffset defines offset to apply to the mip map selection
  46080. * @param onLoad defines an optional callback raised when the texture is loaded
  46081. * @param onError defines an optional callback raised if there is an issue to load the texture
  46082. * @param format defines the format of the data
  46083. * @param forcedExtension defines the extension to use to pick the right loader
  46084. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46085. * @returns the cube texture as an InternalTexture
  46086. */
  46087. 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;
  46088. }
  46089. }
  46090. declare module BABYLON {
  46091. /**
  46092. * Implementation of the DDS Texture Loader.
  46093. * @hidden
  46094. */
  46095. export class _DDSTextureLoader implements IInternalTextureLoader {
  46096. /**
  46097. * Defines wether the loader supports cascade loading the different faces.
  46098. */
  46099. readonly supportCascades: boolean;
  46100. /**
  46101. * This returns if the loader support the current file information.
  46102. * @param extension defines the file extension of the file being loaded
  46103. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46104. * @param fallback defines the fallback internal texture if any
  46105. * @param isBase64 defines whether the texture is encoded as a base64
  46106. * @param isBuffer defines whether the texture data are stored as a buffer
  46107. * @returns true if the loader can load the specified file
  46108. */
  46109. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46110. /**
  46111. * Transform the url before loading if required.
  46112. * @param rootUrl the url of the texture
  46113. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46114. * @returns the transformed texture
  46115. */
  46116. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46117. /**
  46118. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46119. * @param rootUrl the url of the texture
  46120. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46121. * @returns the fallback texture
  46122. */
  46123. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46124. /**
  46125. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46126. * @param data contains the texture data
  46127. * @param texture defines the BabylonJS internal texture
  46128. * @param createPolynomials will be true if polynomials have been requested
  46129. * @param onLoad defines the callback to trigger once the texture is ready
  46130. * @param onError defines the callback to trigger in case of error
  46131. */
  46132. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46133. /**
  46134. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46135. * @param data contains the texture data
  46136. * @param texture defines the BabylonJS internal texture
  46137. * @param callback defines the method to call once ready to upload
  46138. */
  46139. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46140. }
  46141. }
  46142. declare module BABYLON {
  46143. /** @hidden */
  46144. export var rgbdEncodePixelShader: {
  46145. name: string;
  46146. shader: string;
  46147. };
  46148. }
  46149. declare module BABYLON {
  46150. /**
  46151. * Raw texture data and descriptor sufficient for WebGL texture upload
  46152. */
  46153. export interface EnvironmentTextureInfo {
  46154. /**
  46155. * Version of the environment map
  46156. */
  46157. version: number;
  46158. /**
  46159. * Width of image
  46160. */
  46161. width: number;
  46162. /**
  46163. * Irradiance information stored in the file.
  46164. */
  46165. irradiance: any;
  46166. /**
  46167. * Specular information stored in the file.
  46168. */
  46169. specular: any;
  46170. }
  46171. /**
  46172. * Sets of helpers addressing the serialization and deserialization of environment texture
  46173. * stored in a BabylonJS env file.
  46174. * Those files are usually stored as .env files.
  46175. */
  46176. export class EnvironmentTextureTools {
  46177. /**
  46178. * Magic number identifying the env file.
  46179. */
  46180. private static _MagicBytes;
  46181. /**
  46182. * Gets the environment info from an env file.
  46183. * @param data The array buffer containing the .env bytes.
  46184. * @returns the environment file info (the json header) if successfully parsed.
  46185. */
  46186. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46187. /**
  46188. * Creates an environment texture from a loaded cube texture.
  46189. * @param texture defines the cube texture to convert in env file
  46190. * @return a promise containing the environment data if succesfull.
  46191. */
  46192. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46193. /**
  46194. * Creates a JSON representation of the spherical data.
  46195. * @param texture defines the texture containing the polynomials
  46196. * @return the JSON representation of the spherical info
  46197. */
  46198. private static _CreateEnvTextureIrradiance;
  46199. /**
  46200. * Uploads the texture info contained in the env file to the GPU.
  46201. * @param texture defines the internal texture to upload to
  46202. * @param arrayBuffer defines the buffer cotaining the data to load
  46203. * @param info defines the texture info retrieved through the GetEnvInfo method
  46204. * @returns a promise
  46205. */
  46206. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46207. /**
  46208. * Uploads the levels of image data to the GPU.
  46209. * @param texture defines the internal texture to upload to
  46210. * @param imageData defines the array buffer views of image data [mipmap][face]
  46211. * @returns a promise
  46212. */
  46213. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46214. /**
  46215. * Uploads spherical polynomials information to the texture.
  46216. * @param texture defines the texture we are trying to upload the information to
  46217. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46218. */
  46219. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46220. /** @hidden */
  46221. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46222. }
  46223. }
  46224. declare module BABYLON {
  46225. /**
  46226. * Implementation of the ENV Texture Loader.
  46227. * @hidden
  46228. */
  46229. export class _ENVTextureLoader implements IInternalTextureLoader {
  46230. /**
  46231. * Defines wether the loader supports cascade loading the different faces.
  46232. */
  46233. readonly supportCascades: boolean;
  46234. /**
  46235. * This returns if the loader support the current file information.
  46236. * @param extension defines the file extension of the file being loaded
  46237. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46238. * @param fallback defines the fallback internal texture if any
  46239. * @param isBase64 defines whether the texture is encoded as a base64
  46240. * @param isBuffer defines whether the texture data are stored as a buffer
  46241. * @returns true if the loader can load the specified file
  46242. */
  46243. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46244. /**
  46245. * Transform the url before loading if required.
  46246. * @param rootUrl the url of the texture
  46247. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46248. * @returns the transformed texture
  46249. */
  46250. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46251. /**
  46252. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46253. * @param rootUrl the url of the texture
  46254. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46255. * @returns the fallback texture
  46256. */
  46257. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46258. /**
  46259. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46260. * @param data contains the texture data
  46261. * @param texture defines the BabylonJS internal texture
  46262. * @param createPolynomials will be true if polynomials have been requested
  46263. * @param onLoad defines the callback to trigger once the texture is ready
  46264. * @param onError defines the callback to trigger in case of error
  46265. */
  46266. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46267. /**
  46268. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46269. * @param data contains the texture data
  46270. * @param texture defines the BabylonJS internal texture
  46271. * @param callback defines the method to call once ready to upload
  46272. */
  46273. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46274. }
  46275. }
  46276. declare module BABYLON {
  46277. /**
  46278. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46279. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46280. */
  46281. export class KhronosTextureContainer {
  46282. /** contents of the KTX container file */
  46283. arrayBuffer: any;
  46284. private static HEADER_LEN;
  46285. private static COMPRESSED_2D;
  46286. private static COMPRESSED_3D;
  46287. private static TEX_2D;
  46288. private static TEX_3D;
  46289. /**
  46290. * Gets the openGL type
  46291. */
  46292. glType: number;
  46293. /**
  46294. * Gets the openGL type size
  46295. */
  46296. glTypeSize: number;
  46297. /**
  46298. * Gets the openGL format
  46299. */
  46300. glFormat: number;
  46301. /**
  46302. * Gets the openGL internal format
  46303. */
  46304. glInternalFormat: number;
  46305. /**
  46306. * Gets the base internal format
  46307. */
  46308. glBaseInternalFormat: number;
  46309. /**
  46310. * Gets image width in pixel
  46311. */
  46312. pixelWidth: number;
  46313. /**
  46314. * Gets image height in pixel
  46315. */
  46316. pixelHeight: number;
  46317. /**
  46318. * Gets image depth in pixels
  46319. */
  46320. pixelDepth: number;
  46321. /**
  46322. * Gets the number of array elements
  46323. */
  46324. numberOfArrayElements: number;
  46325. /**
  46326. * Gets the number of faces
  46327. */
  46328. numberOfFaces: number;
  46329. /**
  46330. * Gets the number of mipmap levels
  46331. */
  46332. numberOfMipmapLevels: number;
  46333. /**
  46334. * Gets the bytes of key value data
  46335. */
  46336. bytesOfKeyValueData: number;
  46337. /**
  46338. * Gets the load type
  46339. */
  46340. loadType: number;
  46341. /**
  46342. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46343. */
  46344. isInvalid: boolean;
  46345. /**
  46346. * Creates a new KhronosTextureContainer
  46347. * @param arrayBuffer contents of the KTX container file
  46348. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46349. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46350. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46351. */
  46352. constructor(
  46353. /** contents of the KTX container file */
  46354. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46355. /**
  46356. * Uploads KTX content to a Babylon Texture.
  46357. * It is assumed that the texture has already been created & is currently bound
  46358. * @hidden
  46359. */
  46360. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46361. private _upload2DCompressedLevels;
  46362. }
  46363. }
  46364. declare module BABYLON {
  46365. /**
  46366. * Implementation of the KTX Texture Loader.
  46367. * @hidden
  46368. */
  46369. export class _KTXTextureLoader implements IInternalTextureLoader {
  46370. /**
  46371. * Defines wether the loader supports cascade loading the different faces.
  46372. */
  46373. readonly supportCascades: boolean;
  46374. /**
  46375. * This returns if the loader support the current file information.
  46376. * @param extension defines the file extension of the file being loaded
  46377. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46378. * @param fallback defines the fallback internal texture if any
  46379. * @param isBase64 defines whether the texture is encoded as a base64
  46380. * @param isBuffer defines whether the texture data are stored as a buffer
  46381. * @returns true if the loader can load the specified file
  46382. */
  46383. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46384. /**
  46385. * Transform the url before loading if required.
  46386. * @param rootUrl the url of the texture
  46387. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46388. * @returns the transformed texture
  46389. */
  46390. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46391. /**
  46392. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46393. * @param rootUrl the url of the texture
  46394. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46395. * @returns the fallback texture
  46396. */
  46397. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46398. /**
  46399. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46400. * @param data contains the texture data
  46401. * @param texture defines the BabylonJS internal texture
  46402. * @param createPolynomials will be true if polynomials have been requested
  46403. * @param onLoad defines the callback to trigger once the texture is ready
  46404. * @param onError defines the callback to trigger in case of error
  46405. */
  46406. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46407. /**
  46408. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46409. * @param data contains the texture data
  46410. * @param texture defines the BabylonJS internal texture
  46411. * @param callback defines the method to call once ready to upload
  46412. */
  46413. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46414. }
  46415. }
  46416. declare module BABYLON {
  46417. /** @hidden */
  46418. export var _forceSceneHelpersToBundle: boolean;
  46419. interface Scene {
  46420. /**
  46421. * Creates a default light for the scene.
  46422. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46423. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46424. */
  46425. createDefaultLight(replace?: boolean): void;
  46426. /**
  46427. * Creates a default camera for the scene.
  46428. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46429. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46430. * @param replace has default false, when true replaces the active camera in the scene
  46431. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46432. */
  46433. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46434. /**
  46435. * Creates a default camera and a default light.
  46436. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46437. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46438. * @param replace has the default false, when true replaces the active camera/light in the scene
  46439. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46440. */
  46441. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46442. /**
  46443. * Creates a new sky box
  46444. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46445. * @param environmentTexture defines the texture to use as environment texture
  46446. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46447. * @param scale defines the overall scale of the skybox
  46448. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46449. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46450. * @returns a new mesh holding the sky box
  46451. */
  46452. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46453. /**
  46454. * Creates a new environment
  46455. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46456. * @param options defines the options you can use to configure the environment
  46457. * @returns the new EnvironmentHelper
  46458. */
  46459. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46460. /**
  46461. * Creates a new VREXperienceHelper
  46462. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46463. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46464. * @returns a new VREXperienceHelper
  46465. */
  46466. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46467. /**
  46468. * Creates a new XREXperienceHelper
  46469. * @see http://doc.babylonjs.com/how_to/webxr
  46470. * @returns a promise for a new XREXperienceHelper
  46471. */
  46472. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46473. }
  46474. }
  46475. declare module BABYLON {
  46476. /**
  46477. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46478. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46479. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46480. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46481. */
  46482. export class VideoDome extends TransformNode {
  46483. /**
  46484. * Define the video source as a Monoscopic panoramic 360 video.
  46485. */
  46486. static readonly MODE_MONOSCOPIC: number;
  46487. /**
  46488. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46489. */
  46490. static readonly MODE_TOPBOTTOM: number;
  46491. /**
  46492. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46493. */
  46494. static readonly MODE_SIDEBYSIDE: number;
  46495. private _useDirectMapping;
  46496. /**
  46497. * The video texture being displayed on the sphere
  46498. */
  46499. protected _videoTexture: VideoTexture;
  46500. /**
  46501. * Gets the video texture being displayed on the sphere
  46502. */
  46503. readonly videoTexture: VideoTexture;
  46504. /**
  46505. * The skybox material
  46506. */
  46507. protected _material: BackgroundMaterial;
  46508. /**
  46509. * The surface used for the skybox
  46510. */
  46511. protected _mesh: Mesh;
  46512. /**
  46513. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46514. * Also see the options.resolution property.
  46515. */
  46516. fovMultiplier: number;
  46517. private _videoMode;
  46518. /**
  46519. * Gets or set the current video mode for the video. It can be:
  46520. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46521. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46522. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46523. */
  46524. videoMode: number;
  46525. /**
  46526. * Oberserver used in Stereoscopic VR Mode.
  46527. */
  46528. private _onBeforeCameraRenderObserver;
  46529. /**
  46530. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46531. * @param name Element's name, child elements will append suffixes for their own names.
  46532. * @param urlsOrVideo defines the url(s) or the video element to use
  46533. * @param options An object containing optional or exposed sub element properties
  46534. */
  46535. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46536. resolution?: number;
  46537. clickToPlay?: boolean;
  46538. autoPlay?: boolean;
  46539. loop?: boolean;
  46540. size?: number;
  46541. poster?: string;
  46542. faceForward?: boolean;
  46543. useDirectMapping?: boolean;
  46544. }, scene: Scene);
  46545. private _changeVideoMode;
  46546. /**
  46547. * Releases resources associated with this node.
  46548. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46549. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46550. */
  46551. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46552. }
  46553. }
  46554. declare module BABYLON {
  46555. /**
  46556. * This class can be used to get instrumentation data from a Babylon engine
  46557. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46558. */
  46559. export class EngineInstrumentation implements IDisposable {
  46560. /**
  46561. * Define the instrumented engine.
  46562. */
  46563. engine: Engine;
  46564. private _captureGPUFrameTime;
  46565. private _gpuFrameTimeToken;
  46566. private _gpuFrameTime;
  46567. private _captureShaderCompilationTime;
  46568. private _shaderCompilationTime;
  46569. private _onBeginFrameObserver;
  46570. private _onEndFrameObserver;
  46571. private _onBeforeShaderCompilationObserver;
  46572. private _onAfterShaderCompilationObserver;
  46573. /**
  46574. * Gets the perf counter used for GPU frame time
  46575. */
  46576. readonly gpuFrameTimeCounter: PerfCounter;
  46577. /**
  46578. * Gets the GPU frame time capture status
  46579. */
  46580. /**
  46581. * Enable or disable the GPU frame time capture
  46582. */
  46583. captureGPUFrameTime: boolean;
  46584. /**
  46585. * Gets the perf counter used for shader compilation time
  46586. */
  46587. readonly shaderCompilationTimeCounter: PerfCounter;
  46588. /**
  46589. * Gets the shader compilation time capture status
  46590. */
  46591. /**
  46592. * Enable or disable the shader compilation time capture
  46593. */
  46594. captureShaderCompilationTime: boolean;
  46595. /**
  46596. * Instantiates a new engine instrumentation.
  46597. * This class can be used to get instrumentation data from a Babylon engine
  46598. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46599. * @param engine Defines the engine to instrument
  46600. */
  46601. constructor(
  46602. /**
  46603. * Define the instrumented engine.
  46604. */
  46605. engine: Engine);
  46606. /**
  46607. * Dispose and release associated resources.
  46608. */
  46609. dispose(): void;
  46610. }
  46611. }
  46612. declare module BABYLON {
  46613. /**
  46614. * This class can be used to get instrumentation data from a Babylon engine
  46615. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46616. */
  46617. export class SceneInstrumentation implements IDisposable {
  46618. /**
  46619. * Defines the scene to instrument
  46620. */
  46621. scene: Scene;
  46622. private _captureActiveMeshesEvaluationTime;
  46623. private _activeMeshesEvaluationTime;
  46624. private _captureRenderTargetsRenderTime;
  46625. private _renderTargetsRenderTime;
  46626. private _captureFrameTime;
  46627. private _frameTime;
  46628. private _captureRenderTime;
  46629. private _renderTime;
  46630. private _captureInterFrameTime;
  46631. private _interFrameTime;
  46632. private _captureParticlesRenderTime;
  46633. private _particlesRenderTime;
  46634. private _captureSpritesRenderTime;
  46635. private _spritesRenderTime;
  46636. private _capturePhysicsTime;
  46637. private _physicsTime;
  46638. private _captureAnimationsTime;
  46639. private _animationsTime;
  46640. private _captureCameraRenderTime;
  46641. private _cameraRenderTime;
  46642. private _onBeforeActiveMeshesEvaluationObserver;
  46643. private _onAfterActiveMeshesEvaluationObserver;
  46644. private _onBeforeRenderTargetsRenderObserver;
  46645. private _onAfterRenderTargetsRenderObserver;
  46646. private _onAfterRenderObserver;
  46647. private _onBeforeDrawPhaseObserver;
  46648. private _onAfterDrawPhaseObserver;
  46649. private _onBeforeAnimationsObserver;
  46650. private _onBeforeParticlesRenderingObserver;
  46651. private _onAfterParticlesRenderingObserver;
  46652. private _onBeforeSpritesRenderingObserver;
  46653. private _onAfterSpritesRenderingObserver;
  46654. private _onBeforePhysicsObserver;
  46655. private _onAfterPhysicsObserver;
  46656. private _onAfterAnimationsObserver;
  46657. private _onBeforeCameraRenderObserver;
  46658. private _onAfterCameraRenderObserver;
  46659. /**
  46660. * Gets the perf counter used for active meshes evaluation time
  46661. */
  46662. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46663. /**
  46664. * Gets the active meshes evaluation time capture status
  46665. */
  46666. /**
  46667. * Enable or disable the active meshes evaluation time capture
  46668. */
  46669. captureActiveMeshesEvaluationTime: boolean;
  46670. /**
  46671. * Gets the perf counter used for render targets render time
  46672. */
  46673. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46674. /**
  46675. * Gets the render targets render time capture status
  46676. */
  46677. /**
  46678. * Enable or disable the render targets render time capture
  46679. */
  46680. captureRenderTargetsRenderTime: boolean;
  46681. /**
  46682. * Gets the perf counter used for particles render time
  46683. */
  46684. readonly particlesRenderTimeCounter: PerfCounter;
  46685. /**
  46686. * Gets the particles render time capture status
  46687. */
  46688. /**
  46689. * Enable or disable the particles render time capture
  46690. */
  46691. captureParticlesRenderTime: boolean;
  46692. /**
  46693. * Gets the perf counter used for sprites render time
  46694. */
  46695. readonly spritesRenderTimeCounter: PerfCounter;
  46696. /**
  46697. * Gets the sprites render time capture status
  46698. */
  46699. /**
  46700. * Enable or disable the sprites render time capture
  46701. */
  46702. captureSpritesRenderTime: boolean;
  46703. /**
  46704. * Gets the perf counter used for physics time
  46705. */
  46706. readonly physicsTimeCounter: PerfCounter;
  46707. /**
  46708. * Gets the physics time capture status
  46709. */
  46710. /**
  46711. * Enable or disable the physics time capture
  46712. */
  46713. capturePhysicsTime: boolean;
  46714. /**
  46715. * Gets the perf counter used for animations time
  46716. */
  46717. readonly animationsTimeCounter: PerfCounter;
  46718. /**
  46719. * Gets the animations time capture status
  46720. */
  46721. /**
  46722. * Enable or disable the animations time capture
  46723. */
  46724. captureAnimationsTime: boolean;
  46725. /**
  46726. * Gets the perf counter used for frame time capture
  46727. */
  46728. readonly frameTimeCounter: PerfCounter;
  46729. /**
  46730. * Gets the frame time capture status
  46731. */
  46732. /**
  46733. * Enable or disable the frame time capture
  46734. */
  46735. captureFrameTime: boolean;
  46736. /**
  46737. * Gets the perf counter used for inter-frames time capture
  46738. */
  46739. readonly interFrameTimeCounter: PerfCounter;
  46740. /**
  46741. * Gets the inter-frames time capture status
  46742. */
  46743. /**
  46744. * Enable or disable the inter-frames time capture
  46745. */
  46746. captureInterFrameTime: boolean;
  46747. /**
  46748. * Gets the perf counter used for render time capture
  46749. */
  46750. readonly renderTimeCounter: PerfCounter;
  46751. /**
  46752. * Gets the render time capture status
  46753. */
  46754. /**
  46755. * Enable or disable the render time capture
  46756. */
  46757. captureRenderTime: boolean;
  46758. /**
  46759. * Gets the perf counter used for camera render time capture
  46760. */
  46761. readonly cameraRenderTimeCounter: PerfCounter;
  46762. /**
  46763. * Gets the camera render time capture status
  46764. */
  46765. /**
  46766. * Enable or disable the camera render time capture
  46767. */
  46768. captureCameraRenderTime: boolean;
  46769. /**
  46770. * Gets the perf counter used for draw calls
  46771. */
  46772. readonly drawCallsCounter: PerfCounter;
  46773. /**
  46774. * Instantiates a new scene instrumentation.
  46775. * This class can be used to get instrumentation data from a Babylon engine
  46776. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46777. * @param scene Defines the scene to instrument
  46778. */
  46779. constructor(
  46780. /**
  46781. * Defines the scene to instrument
  46782. */
  46783. scene: Scene);
  46784. /**
  46785. * Dispose and release associated resources.
  46786. */
  46787. dispose(): void;
  46788. }
  46789. }
  46790. declare module BABYLON {
  46791. /** @hidden */
  46792. export var glowMapGenerationPixelShader: {
  46793. name: string;
  46794. shader: string;
  46795. };
  46796. }
  46797. declare module BABYLON {
  46798. /** @hidden */
  46799. export var glowMapGenerationVertexShader: {
  46800. name: string;
  46801. shader: string;
  46802. };
  46803. }
  46804. declare module BABYLON {
  46805. /**
  46806. * Effect layer options. This helps customizing the behaviour
  46807. * of the effect layer.
  46808. */
  46809. export interface IEffectLayerOptions {
  46810. /**
  46811. * Multiplication factor apply to the canvas size to compute the render target size
  46812. * used to generated the objects (the smaller the faster).
  46813. */
  46814. mainTextureRatio: number;
  46815. /**
  46816. * Enforces a fixed size texture to ensure effect stability across devices.
  46817. */
  46818. mainTextureFixedSize?: number;
  46819. /**
  46820. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46821. */
  46822. alphaBlendingMode: number;
  46823. /**
  46824. * The camera attached to the layer.
  46825. */
  46826. camera: Nullable<Camera>;
  46827. /**
  46828. * The rendering group to draw the layer in.
  46829. */
  46830. renderingGroupId: number;
  46831. }
  46832. /**
  46833. * The effect layer Helps adding post process effect blended with the main pass.
  46834. *
  46835. * This can be for instance use to generate glow or higlight effects on the scene.
  46836. *
  46837. * The effect layer class can not be used directly and is intented to inherited from to be
  46838. * customized per effects.
  46839. */
  46840. export abstract class EffectLayer {
  46841. private _vertexBuffers;
  46842. private _indexBuffer;
  46843. private _cachedDefines;
  46844. private _effectLayerMapGenerationEffect;
  46845. private _effectLayerOptions;
  46846. private _mergeEffect;
  46847. protected _scene: Scene;
  46848. protected _engine: Engine;
  46849. protected _maxSize: number;
  46850. protected _mainTextureDesiredSize: ISize;
  46851. protected _mainTexture: RenderTargetTexture;
  46852. protected _shouldRender: boolean;
  46853. protected _postProcesses: PostProcess[];
  46854. protected _textures: BaseTexture[];
  46855. protected _emissiveTextureAndColor: {
  46856. texture: Nullable<BaseTexture>;
  46857. color: Color4;
  46858. };
  46859. /**
  46860. * The name of the layer
  46861. */
  46862. name: string;
  46863. /**
  46864. * The clear color of the texture used to generate the glow map.
  46865. */
  46866. neutralColor: Color4;
  46867. /**
  46868. * Specifies wether the highlight layer is enabled or not.
  46869. */
  46870. isEnabled: boolean;
  46871. /**
  46872. * Gets the camera attached to the layer.
  46873. */
  46874. readonly camera: Nullable<Camera>;
  46875. /**
  46876. * Gets the rendering group id the layer should render in.
  46877. */
  46878. readonly renderingGroupId: number;
  46879. /**
  46880. * An event triggered when the effect layer has been disposed.
  46881. */
  46882. onDisposeObservable: Observable<EffectLayer>;
  46883. /**
  46884. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46885. */
  46886. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46887. /**
  46888. * An event triggered when the generated texture is being merged in the scene.
  46889. */
  46890. onBeforeComposeObservable: Observable<EffectLayer>;
  46891. /**
  46892. * An event triggered when the generated texture has been merged in the scene.
  46893. */
  46894. onAfterComposeObservable: Observable<EffectLayer>;
  46895. /**
  46896. * An event triggered when the efffect layer changes its size.
  46897. */
  46898. onSizeChangedObservable: Observable<EffectLayer>;
  46899. /** @hidden */
  46900. static _SceneComponentInitialization: (scene: Scene) => void;
  46901. /**
  46902. * Instantiates a new effect Layer and references it in the scene.
  46903. * @param name The name of the layer
  46904. * @param scene The scene to use the layer in
  46905. */
  46906. constructor(
  46907. /** The Friendly of the effect in the scene */
  46908. name: string, scene: Scene);
  46909. /**
  46910. * Get the effect name of the layer.
  46911. * @return The effect name
  46912. */
  46913. abstract getEffectName(): string;
  46914. /**
  46915. * Checks for the readiness of the element composing the layer.
  46916. * @param subMesh the mesh to check for
  46917. * @param useInstances specify wether or not to use instances to render the mesh
  46918. * @return true if ready otherwise, false
  46919. */
  46920. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46921. /**
  46922. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46923. * @returns true if the effect requires stencil during the main canvas render pass.
  46924. */
  46925. abstract needStencil(): boolean;
  46926. /**
  46927. * Create the merge effect. This is the shader use to blit the information back
  46928. * to the main canvas at the end of the scene rendering.
  46929. * @returns The effect containing the shader used to merge the effect on the main canvas
  46930. */
  46931. protected abstract _createMergeEffect(): Effect;
  46932. /**
  46933. * Creates the render target textures and post processes used in the effect layer.
  46934. */
  46935. protected abstract _createTextureAndPostProcesses(): void;
  46936. /**
  46937. * Implementation specific of rendering the generating effect on the main canvas.
  46938. * @param effect The effect used to render through
  46939. */
  46940. protected abstract _internalRender(effect: Effect): void;
  46941. /**
  46942. * Sets the required values for both the emissive texture and and the main color.
  46943. */
  46944. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46945. /**
  46946. * Free any resources and references associated to a mesh.
  46947. * Internal use
  46948. * @param mesh The mesh to free.
  46949. */
  46950. abstract _disposeMesh(mesh: Mesh): void;
  46951. /**
  46952. * Serializes this layer (Glow or Highlight for example)
  46953. * @returns a serialized layer object
  46954. */
  46955. abstract serialize?(): any;
  46956. /**
  46957. * Initializes the effect layer with the required options.
  46958. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46959. */
  46960. protected _init(options: Partial<IEffectLayerOptions>): void;
  46961. /**
  46962. * Generates the index buffer of the full screen quad blending to the main canvas.
  46963. */
  46964. private _generateIndexBuffer;
  46965. /**
  46966. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46967. */
  46968. private _generateVertexBuffer;
  46969. /**
  46970. * Sets the main texture desired size which is the closest power of two
  46971. * of the engine canvas size.
  46972. */
  46973. private _setMainTextureSize;
  46974. /**
  46975. * Creates the main texture for the effect layer.
  46976. */
  46977. protected _createMainTexture(): void;
  46978. /**
  46979. * Adds specific effects defines.
  46980. * @param defines The defines to add specifics to.
  46981. */
  46982. protected _addCustomEffectDefines(defines: string[]): void;
  46983. /**
  46984. * Checks for the readiness of the element composing the layer.
  46985. * @param subMesh the mesh to check for
  46986. * @param useInstances specify wether or not to use instances to render the mesh
  46987. * @param emissiveTexture the associated emissive texture used to generate the glow
  46988. * @return true if ready otherwise, false
  46989. */
  46990. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46991. /**
  46992. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46993. */
  46994. render(): void;
  46995. /**
  46996. * Determine if a given mesh will be used in the current effect.
  46997. * @param mesh mesh to test
  46998. * @returns true if the mesh will be used
  46999. */
  47000. hasMesh(mesh: AbstractMesh): boolean;
  47001. /**
  47002. * Returns true if the layer contains information to display, otherwise false.
  47003. * @returns true if the glow layer should be rendered
  47004. */
  47005. shouldRender(): boolean;
  47006. /**
  47007. * Returns true if the mesh should render, otherwise false.
  47008. * @param mesh The mesh to render
  47009. * @returns true if it should render otherwise false
  47010. */
  47011. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47012. /**
  47013. * Returns true if the mesh can be rendered, otherwise false.
  47014. * @param mesh The mesh to render
  47015. * @param material The material used on the mesh
  47016. * @returns true if it can be rendered otherwise false
  47017. */
  47018. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47019. /**
  47020. * Returns true if the mesh should render, otherwise false.
  47021. * @param mesh The mesh to render
  47022. * @returns true if it should render otherwise false
  47023. */
  47024. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47025. /**
  47026. * Renders the submesh passed in parameter to the generation map.
  47027. */
  47028. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47029. /**
  47030. * Rebuild the required buffers.
  47031. * @hidden Internal use only.
  47032. */
  47033. _rebuild(): void;
  47034. /**
  47035. * Dispose only the render target textures and post process.
  47036. */
  47037. private _disposeTextureAndPostProcesses;
  47038. /**
  47039. * Dispose the highlight layer and free resources.
  47040. */
  47041. dispose(): void;
  47042. /**
  47043. * Gets the class name of the effect layer
  47044. * @returns the string with the class name of the effect layer
  47045. */
  47046. getClassName(): string;
  47047. /**
  47048. * Creates an effect layer from parsed effect layer data
  47049. * @param parsedEffectLayer defines effect layer data
  47050. * @param scene defines the current scene
  47051. * @param rootUrl defines the root URL containing the effect layer information
  47052. * @returns a parsed effect Layer
  47053. */
  47054. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47055. }
  47056. }
  47057. declare module BABYLON {
  47058. interface AbstractScene {
  47059. /**
  47060. * The list of effect layers (highlights/glow) added to the scene
  47061. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47062. * @see http://doc.babylonjs.com/how_to/glow_layer
  47063. */
  47064. effectLayers: Array<EffectLayer>;
  47065. /**
  47066. * Removes the given effect layer from this scene.
  47067. * @param toRemove defines the effect layer to remove
  47068. * @returns the index of the removed effect layer
  47069. */
  47070. removeEffectLayer(toRemove: EffectLayer): number;
  47071. /**
  47072. * Adds the given effect layer to this scene
  47073. * @param newEffectLayer defines the effect layer to add
  47074. */
  47075. addEffectLayer(newEffectLayer: EffectLayer): void;
  47076. }
  47077. /**
  47078. * Defines the layer scene component responsible to manage any effect layers
  47079. * in a given scene.
  47080. */
  47081. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47082. /**
  47083. * The component name helpfull to identify the component in the list of scene components.
  47084. */
  47085. readonly name: string;
  47086. /**
  47087. * The scene the component belongs to.
  47088. */
  47089. scene: Scene;
  47090. private _engine;
  47091. private _renderEffects;
  47092. private _needStencil;
  47093. private _previousStencilState;
  47094. /**
  47095. * Creates a new instance of the component for the given scene
  47096. * @param scene Defines the scene to register the component in
  47097. */
  47098. constructor(scene: Scene);
  47099. /**
  47100. * Registers the component in a given scene
  47101. */
  47102. register(): void;
  47103. /**
  47104. * Rebuilds the elements related to this component in case of
  47105. * context lost for instance.
  47106. */
  47107. rebuild(): void;
  47108. /**
  47109. * Serializes the component data to the specified json object
  47110. * @param serializationObject The object to serialize to
  47111. */
  47112. serialize(serializationObject: any): void;
  47113. /**
  47114. * Adds all the element from the container to the scene
  47115. * @param container the container holding the elements
  47116. */
  47117. addFromContainer(container: AbstractScene): void;
  47118. /**
  47119. * Removes all the elements in the container from the scene
  47120. * @param container contains the elements to remove
  47121. * @param dispose if the removed element should be disposed (default: false)
  47122. */
  47123. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47124. /**
  47125. * Disposes the component and the associated ressources.
  47126. */
  47127. dispose(): void;
  47128. private _isReadyForMesh;
  47129. private _renderMainTexture;
  47130. private _setStencil;
  47131. private _setStencilBack;
  47132. private _draw;
  47133. private _drawCamera;
  47134. private _drawRenderingGroup;
  47135. }
  47136. }
  47137. declare module BABYLON {
  47138. /** @hidden */
  47139. export var glowMapMergePixelShader: {
  47140. name: string;
  47141. shader: string;
  47142. };
  47143. }
  47144. declare module BABYLON {
  47145. /** @hidden */
  47146. export var glowMapMergeVertexShader: {
  47147. name: string;
  47148. shader: string;
  47149. };
  47150. }
  47151. declare module BABYLON {
  47152. interface AbstractScene {
  47153. /**
  47154. * Return a the first highlight layer of the scene with a given name.
  47155. * @param name The name of the highlight layer to look for.
  47156. * @return The highlight layer if found otherwise null.
  47157. */
  47158. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47159. }
  47160. /**
  47161. * Glow layer options. This helps customizing the behaviour
  47162. * of the glow layer.
  47163. */
  47164. export interface IGlowLayerOptions {
  47165. /**
  47166. * Multiplication factor apply to the canvas size to compute the render target size
  47167. * used to generated the glowing objects (the smaller the faster).
  47168. */
  47169. mainTextureRatio: number;
  47170. /**
  47171. * Enforces a fixed size texture to ensure resize independant blur.
  47172. */
  47173. mainTextureFixedSize?: number;
  47174. /**
  47175. * How big is the kernel of the blur texture.
  47176. */
  47177. blurKernelSize: number;
  47178. /**
  47179. * The camera attached to the layer.
  47180. */
  47181. camera: Nullable<Camera>;
  47182. /**
  47183. * Enable MSAA by chosing the number of samples.
  47184. */
  47185. mainTextureSamples?: number;
  47186. /**
  47187. * The rendering group to draw the layer in.
  47188. */
  47189. renderingGroupId: number;
  47190. }
  47191. /**
  47192. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47193. *
  47194. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47195. * glowy meshes to your scene.
  47196. *
  47197. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47198. */
  47199. export class GlowLayer extends EffectLayer {
  47200. /**
  47201. * Effect Name of the layer.
  47202. */
  47203. static readonly EffectName: string;
  47204. /**
  47205. * The default blur kernel size used for the glow.
  47206. */
  47207. static DefaultBlurKernelSize: number;
  47208. /**
  47209. * The default texture size ratio used for the glow.
  47210. */
  47211. static DefaultTextureRatio: number;
  47212. /**
  47213. * Sets the kernel size of the blur.
  47214. */
  47215. /**
  47216. * Gets the kernel size of the blur.
  47217. */
  47218. blurKernelSize: number;
  47219. /**
  47220. * Sets the glow intensity.
  47221. */
  47222. /**
  47223. * Gets the glow intensity.
  47224. */
  47225. intensity: number;
  47226. private _options;
  47227. private _intensity;
  47228. private _horizontalBlurPostprocess1;
  47229. private _verticalBlurPostprocess1;
  47230. private _horizontalBlurPostprocess2;
  47231. private _verticalBlurPostprocess2;
  47232. private _blurTexture1;
  47233. private _blurTexture2;
  47234. private _postProcesses1;
  47235. private _postProcesses2;
  47236. private _includedOnlyMeshes;
  47237. private _excludedMeshes;
  47238. /**
  47239. * Callback used to let the user override the color selection on a per mesh basis
  47240. */
  47241. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47242. /**
  47243. * Callback used to let the user override the texture selection on a per mesh basis
  47244. */
  47245. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47246. /**
  47247. * Instantiates a new glow Layer and references it to the scene.
  47248. * @param name The name of the layer
  47249. * @param scene The scene to use the layer in
  47250. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47251. */
  47252. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47253. /**
  47254. * Get the effect name of the layer.
  47255. * @return The effect name
  47256. */
  47257. getEffectName(): string;
  47258. /**
  47259. * Create the merge effect. This is the shader use to blit the information back
  47260. * to the main canvas at the end of the scene rendering.
  47261. */
  47262. protected _createMergeEffect(): Effect;
  47263. /**
  47264. * Creates the render target textures and post processes used in the glow layer.
  47265. */
  47266. protected _createTextureAndPostProcesses(): void;
  47267. /**
  47268. * Checks for the readiness of the element composing the layer.
  47269. * @param subMesh the mesh to check for
  47270. * @param useInstances specify wether or not to use instances to render the mesh
  47271. * @param emissiveTexture the associated emissive texture used to generate the glow
  47272. * @return true if ready otherwise, false
  47273. */
  47274. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47275. /**
  47276. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47277. */
  47278. needStencil(): boolean;
  47279. /**
  47280. * Returns true if the mesh can be rendered, otherwise false.
  47281. * @param mesh The mesh to render
  47282. * @param material The material used on the mesh
  47283. * @returns true if it can be rendered otherwise false
  47284. */
  47285. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47286. /**
  47287. * Implementation specific of rendering the generating effect on the main canvas.
  47288. * @param effect The effect used to render through
  47289. */
  47290. protected _internalRender(effect: Effect): void;
  47291. /**
  47292. * Sets the required values for both the emissive texture and and the main color.
  47293. */
  47294. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47295. /**
  47296. * Returns true if the mesh should render, otherwise false.
  47297. * @param mesh The mesh to render
  47298. * @returns true if it should render otherwise false
  47299. */
  47300. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47301. /**
  47302. * Adds specific effects defines.
  47303. * @param defines The defines to add specifics to.
  47304. */
  47305. protected _addCustomEffectDefines(defines: string[]): void;
  47306. /**
  47307. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47308. * @param mesh The mesh to exclude from the glow layer
  47309. */
  47310. addExcludedMesh(mesh: Mesh): void;
  47311. /**
  47312. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47313. * @param mesh The mesh to remove
  47314. */
  47315. removeExcludedMesh(mesh: Mesh): void;
  47316. /**
  47317. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47318. * @param mesh The mesh to include in the glow layer
  47319. */
  47320. addIncludedOnlyMesh(mesh: Mesh): void;
  47321. /**
  47322. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47323. * @param mesh The mesh to remove
  47324. */
  47325. removeIncludedOnlyMesh(mesh: Mesh): void;
  47326. /**
  47327. * Determine if a given mesh will be used in the glow layer
  47328. * @param mesh The mesh to test
  47329. * @returns true if the mesh will be highlighted by the current glow layer
  47330. */
  47331. hasMesh(mesh: AbstractMesh): boolean;
  47332. /**
  47333. * Free any resources and references associated to a mesh.
  47334. * Internal use
  47335. * @param mesh The mesh to free.
  47336. * @hidden
  47337. */
  47338. _disposeMesh(mesh: Mesh): void;
  47339. /**
  47340. * Gets the class name of the effect layer
  47341. * @returns the string with the class name of the effect layer
  47342. */
  47343. getClassName(): string;
  47344. /**
  47345. * Serializes this glow layer
  47346. * @returns a serialized glow layer object
  47347. */
  47348. serialize(): any;
  47349. /**
  47350. * Creates a Glow Layer from parsed glow layer data
  47351. * @param parsedGlowLayer defines glow layer data
  47352. * @param scene defines the current scene
  47353. * @param rootUrl defines the root URL containing the glow layer information
  47354. * @returns a parsed Glow Layer
  47355. */
  47356. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47357. }
  47358. }
  47359. declare module BABYLON {
  47360. /** @hidden */
  47361. export var glowBlurPostProcessPixelShader: {
  47362. name: string;
  47363. shader: string;
  47364. };
  47365. }
  47366. declare module BABYLON {
  47367. interface AbstractScene {
  47368. /**
  47369. * Return a the first highlight layer of the scene with a given name.
  47370. * @param name The name of the highlight layer to look for.
  47371. * @return The highlight layer if found otherwise null.
  47372. */
  47373. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47374. }
  47375. /**
  47376. * Highlight layer options. This helps customizing the behaviour
  47377. * of the highlight layer.
  47378. */
  47379. export interface IHighlightLayerOptions {
  47380. /**
  47381. * Multiplication factor apply to the canvas size to compute the render target size
  47382. * used to generated the glowing objects (the smaller the faster).
  47383. */
  47384. mainTextureRatio: number;
  47385. /**
  47386. * Enforces a fixed size texture to ensure resize independant blur.
  47387. */
  47388. mainTextureFixedSize?: number;
  47389. /**
  47390. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47391. * of the picture to blur (the smaller the faster).
  47392. */
  47393. blurTextureSizeRatio: number;
  47394. /**
  47395. * How big in texel of the blur texture is the vertical blur.
  47396. */
  47397. blurVerticalSize: number;
  47398. /**
  47399. * How big in texel of the blur texture is the horizontal blur.
  47400. */
  47401. blurHorizontalSize: number;
  47402. /**
  47403. * Alpha blending mode used to apply the blur. Default is combine.
  47404. */
  47405. alphaBlendingMode: number;
  47406. /**
  47407. * The camera attached to the layer.
  47408. */
  47409. camera: Nullable<Camera>;
  47410. /**
  47411. * Should we display highlight as a solid stroke?
  47412. */
  47413. isStroke?: boolean;
  47414. /**
  47415. * The rendering group to draw the layer in.
  47416. */
  47417. renderingGroupId: number;
  47418. }
  47419. /**
  47420. * The highlight layer Helps adding a glow effect around a mesh.
  47421. *
  47422. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47423. * glowy meshes to your scene.
  47424. *
  47425. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47426. */
  47427. export class HighlightLayer extends EffectLayer {
  47428. name: string;
  47429. /**
  47430. * Effect Name of the highlight layer.
  47431. */
  47432. static readonly EffectName: string;
  47433. /**
  47434. * The neutral color used during the preparation of the glow effect.
  47435. * This is black by default as the blend operation is a blend operation.
  47436. */
  47437. static NeutralColor: Color4;
  47438. /**
  47439. * Stencil value used for glowing meshes.
  47440. */
  47441. static GlowingMeshStencilReference: number;
  47442. /**
  47443. * Stencil value used for the other meshes in the scene.
  47444. */
  47445. static NormalMeshStencilReference: number;
  47446. /**
  47447. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47448. */
  47449. innerGlow: boolean;
  47450. /**
  47451. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47452. */
  47453. outerGlow: boolean;
  47454. /**
  47455. * Specifies the horizontal size of the blur.
  47456. */
  47457. /**
  47458. * Gets the horizontal size of the blur.
  47459. */
  47460. blurHorizontalSize: number;
  47461. /**
  47462. * Specifies the vertical size of the blur.
  47463. */
  47464. /**
  47465. * Gets the vertical size of the blur.
  47466. */
  47467. blurVerticalSize: number;
  47468. /**
  47469. * An event triggered when the highlight layer is being blurred.
  47470. */
  47471. onBeforeBlurObservable: Observable<HighlightLayer>;
  47472. /**
  47473. * An event triggered when the highlight layer has been blurred.
  47474. */
  47475. onAfterBlurObservable: Observable<HighlightLayer>;
  47476. private _instanceGlowingMeshStencilReference;
  47477. private _options;
  47478. private _downSamplePostprocess;
  47479. private _horizontalBlurPostprocess;
  47480. private _verticalBlurPostprocess;
  47481. private _blurTexture;
  47482. private _meshes;
  47483. private _excludedMeshes;
  47484. /**
  47485. * Instantiates a new highlight Layer and references it to the scene..
  47486. * @param name The name of the layer
  47487. * @param scene The scene to use the layer in
  47488. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47489. */
  47490. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47491. /**
  47492. * Get the effect name of the layer.
  47493. * @return The effect name
  47494. */
  47495. getEffectName(): string;
  47496. /**
  47497. * Create the merge effect. This is the shader use to blit the information back
  47498. * to the main canvas at the end of the scene rendering.
  47499. */
  47500. protected _createMergeEffect(): Effect;
  47501. /**
  47502. * Creates the render target textures and post processes used in the highlight layer.
  47503. */
  47504. protected _createTextureAndPostProcesses(): void;
  47505. /**
  47506. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47507. */
  47508. needStencil(): boolean;
  47509. /**
  47510. * Checks for the readiness of the element composing the layer.
  47511. * @param subMesh the mesh to check for
  47512. * @param useInstances specify wether or not to use instances to render the mesh
  47513. * @param emissiveTexture the associated emissive texture used to generate the glow
  47514. * @return true if ready otherwise, false
  47515. */
  47516. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47517. /**
  47518. * Implementation specific of rendering the generating effect on the main canvas.
  47519. * @param effect The effect used to render through
  47520. */
  47521. protected _internalRender(effect: Effect): void;
  47522. /**
  47523. * Returns true if the layer contains information to display, otherwise false.
  47524. */
  47525. shouldRender(): boolean;
  47526. /**
  47527. * Returns true if the mesh should render, otherwise false.
  47528. * @param mesh The mesh to render
  47529. * @returns true if it should render otherwise false
  47530. */
  47531. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47532. /**
  47533. * Sets the required values for both the emissive texture and and the main color.
  47534. */
  47535. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47536. /**
  47537. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47538. * @param mesh The mesh to exclude from the highlight layer
  47539. */
  47540. addExcludedMesh(mesh: Mesh): void;
  47541. /**
  47542. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47543. * @param mesh The mesh to highlight
  47544. */
  47545. removeExcludedMesh(mesh: Mesh): void;
  47546. /**
  47547. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47548. * @param mesh mesh to test
  47549. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47550. */
  47551. hasMesh(mesh: AbstractMesh): boolean;
  47552. /**
  47553. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47554. * @param mesh The mesh to highlight
  47555. * @param color The color of the highlight
  47556. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47557. */
  47558. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47559. /**
  47560. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47561. * @param mesh The mesh to highlight
  47562. */
  47563. removeMesh(mesh: Mesh): void;
  47564. /**
  47565. * Force the stencil to the normal expected value for none glowing parts
  47566. */
  47567. private _defaultStencilReference;
  47568. /**
  47569. * Free any resources and references associated to a mesh.
  47570. * Internal use
  47571. * @param mesh The mesh to free.
  47572. * @hidden
  47573. */
  47574. _disposeMesh(mesh: Mesh): void;
  47575. /**
  47576. * Dispose the highlight layer and free resources.
  47577. */
  47578. dispose(): void;
  47579. /**
  47580. * Gets the class name of the effect layer
  47581. * @returns the string with the class name of the effect layer
  47582. */
  47583. getClassName(): string;
  47584. /**
  47585. * Serializes this Highlight layer
  47586. * @returns a serialized Highlight layer object
  47587. */
  47588. serialize(): any;
  47589. /**
  47590. * Creates a Highlight layer from parsed Highlight layer data
  47591. * @param parsedHightlightLayer defines the Highlight layer data
  47592. * @param scene defines the current scene
  47593. * @param rootUrl defines the root URL containing the Highlight layer information
  47594. * @returns a parsed Highlight layer
  47595. */
  47596. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47597. }
  47598. }
  47599. declare module BABYLON {
  47600. /** @hidden */
  47601. export var lensFlarePixelShader: {
  47602. name: string;
  47603. shader: string;
  47604. };
  47605. }
  47606. declare module BABYLON {
  47607. /** @hidden */
  47608. export var lensFlareVertexShader: {
  47609. name: string;
  47610. shader: string;
  47611. };
  47612. }
  47613. declare module BABYLON {
  47614. /**
  47615. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47616. * It is usually composed of several `lensFlare`.
  47617. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47618. */
  47619. export class LensFlareSystem {
  47620. /**
  47621. * Define the name of the lens flare system
  47622. */
  47623. name: string;
  47624. /**
  47625. * List of lens flares used in this system.
  47626. */
  47627. lensFlares: LensFlare[];
  47628. /**
  47629. * Define a limit from the border the lens flare can be visible.
  47630. */
  47631. borderLimit: number;
  47632. /**
  47633. * Define a viewport border we do not want to see the lens flare in.
  47634. */
  47635. viewportBorder: number;
  47636. /**
  47637. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47638. */
  47639. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47640. /**
  47641. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47642. */
  47643. layerMask: number;
  47644. /**
  47645. * Define the id of the lens flare system in the scene.
  47646. * (equal to name by default)
  47647. */
  47648. id: string;
  47649. private _scene;
  47650. private _emitter;
  47651. private _vertexBuffers;
  47652. private _indexBuffer;
  47653. private _effect;
  47654. private _positionX;
  47655. private _positionY;
  47656. private _isEnabled;
  47657. /** @hidden */
  47658. static _SceneComponentInitialization: (scene: Scene) => void;
  47659. /**
  47660. * Instantiates a lens flare system.
  47661. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47662. * It is usually composed of several `lensFlare`.
  47663. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47664. * @param name Define the name of the lens flare system in the scene
  47665. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47666. * @param scene Define the scene the lens flare system belongs to
  47667. */
  47668. constructor(
  47669. /**
  47670. * Define the name of the lens flare system
  47671. */
  47672. name: string, emitter: any, scene: Scene);
  47673. /**
  47674. * Define if the lens flare system is enabled.
  47675. */
  47676. isEnabled: boolean;
  47677. /**
  47678. * Get the scene the effects belongs to.
  47679. * @returns the scene holding the lens flare system
  47680. */
  47681. getScene(): Scene;
  47682. /**
  47683. * Get the emitter of the lens flare system.
  47684. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47685. * @returns the emitter of the lens flare system
  47686. */
  47687. getEmitter(): any;
  47688. /**
  47689. * Set the emitter of the lens flare system.
  47690. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47691. * @param newEmitter Define the new emitter of the system
  47692. */
  47693. setEmitter(newEmitter: any): void;
  47694. /**
  47695. * Get the lens flare system emitter position.
  47696. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47697. * @returns the position
  47698. */
  47699. getEmitterPosition(): Vector3;
  47700. /**
  47701. * @hidden
  47702. */
  47703. computeEffectivePosition(globalViewport: Viewport): boolean;
  47704. /** @hidden */
  47705. _isVisible(): boolean;
  47706. /**
  47707. * @hidden
  47708. */
  47709. render(): boolean;
  47710. /**
  47711. * Dispose and release the lens flare with its associated resources.
  47712. */
  47713. dispose(): void;
  47714. /**
  47715. * Parse a lens flare system from a JSON repressentation
  47716. * @param parsedLensFlareSystem Define the JSON to parse
  47717. * @param scene Define the scene the parsed system should be instantiated in
  47718. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47719. * @returns the parsed system
  47720. */
  47721. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47722. /**
  47723. * Serialize the current Lens Flare System into a JSON representation.
  47724. * @returns the serialized JSON
  47725. */
  47726. serialize(): any;
  47727. }
  47728. }
  47729. declare module BABYLON {
  47730. /**
  47731. * This represents one of the lens effect in a `lensFlareSystem`.
  47732. * It controls one of the indiviual texture used in the effect.
  47733. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47734. */
  47735. export class LensFlare {
  47736. /**
  47737. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47738. */
  47739. size: number;
  47740. /**
  47741. * 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.
  47742. */
  47743. position: number;
  47744. /**
  47745. * Define the lens color.
  47746. */
  47747. color: Color3;
  47748. /**
  47749. * Define the lens texture.
  47750. */
  47751. texture: Nullable<Texture>;
  47752. /**
  47753. * Define the alpha mode to render this particular lens.
  47754. */
  47755. alphaMode: number;
  47756. private _system;
  47757. /**
  47758. * Creates a new Lens Flare.
  47759. * This represents one of the lens effect in a `lensFlareSystem`.
  47760. * It controls one of the indiviual texture used in the effect.
  47761. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47762. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47763. * @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.
  47764. * @param color Define the lens color
  47765. * @param imgUrl Define the lens texture url
  47766. * @param system Define the `lensFlareSystem` this flare is part of
  47767. * @returns The newly created Lens Flare
  47768. */
  47769. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47770. /**
  47771. * Instantiates a new Lens Flare.
  47772. * This represents one of the lens effect in a `lensFlareSystem`.
  47773. * It controls one of the indiviual texture used in the effect.
  47774. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47775. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47776. * @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.
  47777. * @param color Define the lens color
  47778. * @param imgUrl Define the lens texture url
  47779. * @param system Define the `lensFlareSystem` this flare is part of
  47780. */
  47781. constructor(
  47782. /**
  47783. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47784. */
  47785. size: number,
  47786. /**
  47787. * 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.
  47788. */
  47789. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47790. /**
  47791. * Dispose and release the lens flare with its associated resources.
  47792. */
  47793. dispose(): void;
  47794. }
  47795. }
  47796. declare module BABYLON {
  47797. interface AbstractScene {
  47798. /**
  47799. * The list of lens flare system added to the scene
  47800. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47801. */
  47802. lensFlareSystems: Array<LensFlareSystem>;
  47803. /**
  47804. * Removes the given lens flare system from this scene.
  47805. * @param toRemove The lens flare system to remove
  47806. * @returns The index of the removed lens flare system
  47807. */
  47808. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47809. /**
  47810. * Adds the given lens flare system to this scene
  47811. * @param newLensFlareSystem The lens flare system to add
  47812. */
  47813. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47814. /**
  47815. * Gets a lens flare system using its name
  47816. * @param name defines the name to look for
  47817. * @returns the lens flare system or null if not found
  47818. */
  47819. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47820. /**
  47821. * Gets a lens flare system using its id
  47822. * @param id defines the id to look for
  47823. * @returns the lens flare system or null if not found
  47824. */
  47825. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47826. }
  47827. /**
  47828. * Defines the lens flare scene component responsible to manage any lens flares
  47829. * in a given scene.
  47830. */
  47831. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47832. /**
  47833. * The component name helpfull to identify the component in the list of scene components.
  47834. */
  47835. readonly name: string;
  47836. /**
  47837. * The scene the component belongs to.
  47838. */
  47839. scene: Scene;
  47840. /**
  47841. * Creates a new instance of the component for the given scene
  47842. * @param scene Defines the scene to register the component in
  47843. */
  47844. constructor(scene: Scene);
  47845. /**
  47846. * Registers the component in a given scene
  47847. */
  47848. register(): void;
  47849. /**
  47850. * Rebuilds the elements related to this component in case of
  47851. * context lost for instance.
  47852. */
  47853. rebuild(): void;
  47854. /**
  47855. * Adds all the element from the container to the scene
  47856. * @param container the container holding the elements
  47857. */
  47858. addFromContainer(container: AbstractScene): void;
  47859. /**
  47860. * Removes all the elements in the container from the scene
  47861. * @param container contains the elements to remove
  47862. * @param dispose if the removed element should be disposed (default: false)
  47863. */
  47864. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47865. /**
  47866. * Serializes the component data to the specified json object
  47867. * @param serializationObject The object to serialize to
  47868. */
  47869. serialize(serializationObject: any): void;
  47870. /**
  47871. * Disposes the component and the associated ressources.
  47872. */
  47873. dispose(): void;
  47874. private _draw;
  47875. }
  47876. }
  47877. declare module BABYLON {
  47878. /**
  47879. * Defines the shadow generator component responsible to manage any shadow generators
  47880. * in a given scene.
  47881. */
  47882. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47883. /**
  47884. * The component name helpfull to identify the component in the list of scene components.
  47885. */
  47886. readonly name: string;
  47887. /**
  47888. * The scene the component belongs to.
  47889. */
  47890. scene: Scene;
  47891. /**
  47892. * Creates a new instance of the component for the given scene
  47893. * @param scene Defines the scene to register the component in
  47894. */
  47895. constructor(scene: Scene);
  47896. /**
  47897. * Registers the component in a given scene
  47898. */
  47899. register(): void;
  47900. /**
  47901. * Rebuilds the elements related to this component in case of
  47902. * context lost for instance.
  47903. */
  47904. rebuild(): void;
  47905. /**
  47906. * Serializes the component data to the specified json object
  47907. * @param serializationObject The object to serialize to
  47908. */
  47909. serialize(serializationObject: any): void;
  47910. /**
  47911. * Adds all the element from the container to the scene
  47912. * @param container the container holding the elements
  47913. */
  47914. addFromContainer(container: AbstractScene): void;
  47915. /**
  47916. * Removes all the elements in the container from the scene
  47917. * @param container contains the elements to remove
  47918. * @param dispose if the removed element should be disposed (default: false)
  47919. */
  47920. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47921. /**
  47922. * Rebuilds the elements related to this component in case of
  47923. * context lost for instance.
  47924. */
  47925. dispose(): void;
  47926. private _gatherRenderTargets;
  47927. }
  47928. }
  47929. declare module BABYLON {
  47930. /**
  47931. * A point light is a light defined by an unique point in world space.
  47932. * The light is emitted in every direction from this point.
  47933. * A good example of a point light is a standard light bulb.
  47934. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47935. */
  47936. export class PointLight extends ShadowLight {
  47937. private _shadowAngle;
  47938. /**
  47939. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47940. * This specifies what angle the shadow will use to be created.
  47941. *
  47942. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47943. */
  47944. /**
  47945. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47946. * This specifies what angle the shadow will use to be created.
  47947. *
  47948. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47949. */
  47950. shadowAngle: number;
  47951. /**
  47952. * Gets the direction if it has been set.
  47953. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47954. */
  47955. /**
  47956. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47957. */
  47958. direction: Vector3;
  47959. /**
  47960. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47961. * A PointLight emits the light in every direction.
  47962. * It can cast shadows.
  47963. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47964. * ```javascript
  47965. * var pointLight = new PointLight("pl", camera.position, scene);
  47966. * ```
  47967. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47968. * @param name The light friendly name
  47969. * @param position The position of the point light in the scene
  47970. * @param scene The scene the lights belongs to
  47971. */
  47972. constructor(name: string, position: Vector3, scene: Scene);
  47973. /**
  47974. * Returns the string "PointLight"
  47975. * @returns the class name
  47976. */
  47977. getClassName(): string;
  47978. /**
  47979. * Returns the integer 0.
  47980. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47981. */
  47982. getTypeID(): number;
  47983. /**
  47984. * Specifies wether or not the shadowmap should be a cube texture.
  47985. * @returns true if the shadowmap needs to be a cube texture.
  47986. */
  47987. needCube(): boolean;
  47988. /**
  47989. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47990. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47991. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47992. */
  47993. getShadowDirection(faceIndex?: number): Vector3;
  47994. /**
  47995. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47996. * - fov = PI / 2
  47997. * - aspect ratio : 1.0
  47998. * - z-near and far equal to the active camera minZ and maxZ.
  47999. * Returns the PointLight.
  48000. */
  48001. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48002. protected _buildUniformLayout(): void;
  48003. /**
  48004. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48005. * @param effect The effect to update
  48006. * @param lightIndex The index of the light in the effect to update
  48007. * @returns The point light
  48008. */
  48009. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48010. /**
  48011. * Prepares the list of defines specific to the light type.
  48012. * @param defines the list of defines
  48013. * @param lightIndex defines the index of the light for the effect
  48014. */
  48015. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48016. }
  48017. }
  48018. declare module BABYLON {
  48019. /**
  48020. * Header information of HDR texture files.
  48021. */
  48022. export interface HDRInfo {
  48023. /**
  48024. * The height of the texture in pixels.
  48025. */
  48026. height: number;
  48027. /**
  48028. * The width of the texture in pixels.
  48029. */
  48030. width: number;
  48031. /**
  48032. * The index of the beginning of the data in the binary file.
  48033. */
  48034. dataPosition: number;
  48035. }
  48036. /**
  48037. * This groups tools to convert HDR texture to native colors array.
  48038. */
  48039. export class HDRTools {
  48040. private static Ldexp;
  48041. private static Rgbe2float;
  48042. private static readStringLine;
  48043. /**
  48044. * Reads header information from an RGBE texture stored in a native array.
  48045. * More information on this format are available here:
  48046. * https://en.wikipedia.org/wiki/RGBE_image_format
  48047. *
  48048. * @param uint8array The binary file stored in native array.
  48049. * @return The header information.
  48050. */
  48051. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48052. /**
  48053. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48054. * This RGBE texture needs to store the information as a panorama.
  48055. *
  48056. * More information on this format are available here:
  48057. * https://en.wikipedia.org/wiki/RGBE_image_format
  48058. *
  48059. * @param buffer The binary file stored in an array buffer.
  48060. * @param size The expected size of the extracted cubemap.
  48061. * @return The Cube Map information.
  48062. */
  48063. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48064. /**
  48065. * Returns the pixels data extracted from an RGBE texture.
  48066. * This pixels will be stored left to right up to down in the R G B order in one array.
  48067. *
  48068. * More information on this format are available here:
  48069. * https://en.wikipedia.org/wiki/RGBE_image_format
  48070. *
  48071. * @param uint8array The binary file stored in an array buffer.
  48072. * @param hdrInfo The header information of the file.
  48073. * @return The pixels data in RGB right to left up to down order.
  48074. */
  48075. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48076. private static RGBE_ReadPixels_RLE;
  48077. }
  48078. }
  48079. declare module BABYLON {
  48080. /**
  48081. * This represents a texture coming from an HDR input.
  48082. *
  48083. * The only supported format is currently panorama picture stored in RGBE format.
  48084. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48085. */
  48086. export class HDRCubeTexture extends BaseTexture {
  48087. private static _facesMapping;
  48088. private _generateHarmonics;
  48089. private _noMipmap;
  48090. private _textureMatrix;
  48091. private _size;
  48092. private _onLoad;
  48093. private _onError;
  48094. /**
  48095. * The texture URL.
  48096. */
  48097. url: string;
  48098. /**
  48099. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48100. */
  48101. coordinatesMode: number;
  48102. protected _isBlocking: boolean;
  48103. /**
  48104. * Sets wether or not the texture is blocking during loading.
  48105. */
  48106. /**
  48107. * Gets wether or not the texture is blocking during loading.
  48108. */
  48109. isBlocking: boolean;
  48110. protected _rotationY: number;
  48111. /**
  48112. * Sets texture matrix rotation angle around Y axis in radians.
  48113. */
  48114. /**
  48115. * Gets texture matrix rotation angle around Y axis radians.
  48116. */
  48117. rotationY: number;
  48118. /**
  48119. * Gets or sets the center of the bounding box associated with the cube texture
  48120. * It must define where the camera used to render the texture was set
  48121. */
  48122. boundingBoxPosition: Vector3;
  48123. private _boundingBoxSize;
  48124. /**
  48125. * Gets or sets the size of the bounding box associated with the cube texture
  48126. * When defined, the cubemap will switch to local mode
  48127. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48128. * @example https://www.babylonjs-playground.com/#RNASML
  48129. */
  48130. boundingBoxSize: Vector3;
  48131. /**
  48132. * Instantiates an HDRTexture from the following parameters.
  48133. *
  48134. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48135. * @param scene The scene the texture will be used in
  48136. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48137. * @param noMipmap Forces to not generate the mipmap if true
  48138. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48139. * @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)
  48140. * @param reserved Reserved flag for internal use.
  48141. */
  48142. 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>);
  48143. /**
  48144. * Get the current class name of the texture useful for serialization or dynamic coding.
  48145. * @returns "HDRCubeTexture"
  48146. */
  48147. getClassName(): string;
  48148. /**
  48149. * Occurs when the file is raw .hdr file.
  48150. */
  48151. private loadTexture;
  48152. clone(): HDRCubeTexture;
  48153. delayLoad(): void;
  48154. /**
  48155. * Get the texture reflection matrix used to rotate/transform the reflection.
  48156. * @returns the reflection matrix
  48157. */
  48158. getReflectionTextureMatrix(): Matrix;
  48159. /**
  48160. * Set the texture reflection matrix used to rotate/transform the reflection.
  48161. * @param value Define the reflection matrix to set
  48162. */
  48163. setReflectionTextureMatrix(value: Matrix): void;
  48164. /**
  48165. * Parses a JSON representation of an HDR Texture in order to create the texture
  48166. * @param parsedTexture Define the JSON representation
  48167. * @param scene Define the scene the texture should be created in
  48168. * @param rootUrl Define the root url in case we need to load relative dependencies
  48169. * @returns the newly created texture after parsing
  48170. */
  48171. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48172. serialize(): any;
  48173. }
  48174. }
  48175. declare module BABYLON {
  48176. /**
  48177. * Class used to control physics engine
  48178. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48179. */
  48180. export class PhysicsEngine implements IPhysicsEngine {
  48181. private _physicsPlugin;
  48182. /**
  48183. * Global value used to control the smallest number supported by the simulation
  48184. */
  48185. static Epsilon: number;
  48186. private _impostors;
  48187. private _joints;
  48188. /**
  48189. * Gets the gravity vector used by the simulation
  48190. */
  48191. gravity: Vector3;
  48192. /**
  48193. * Factory used to create the default physics plugin.
  48194. * @returns The default physics plugin
  48195. */
  48196. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48197. /**
  48198. * Creates a new Physics Engine
  48199. * @param gravity defines the gravity vector used by the simulation
  48200. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48201. */
  48202. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48203. /**
  48204. * Sets the gravity vector used by the simulation
  48205. * @param gravity defines the gravity vector to use
  48206. */
  48207. setGravity(gravity: Vector3): void;
  48208. /**
  48209. * Set the time step of the physics engine.
  48210. * Default is 1/60.
  48211. * To slow it down, enter 1/600 for example.
  48212. * To speed it up, 1/30
  48213. * @param newTimeStep defines the new timestep to apply to this world.
  48214. */
  48215. setTimeStep(newTimeStep?: number): void;
  48216. /**
  48217. * Get the time step of the physics engine.
  48218. * @returns the current time step
  48219. */
  48220. getTimeStep(): number;
  48221. /**
  48222. * Release all resources
  48223. */
  48224. dispose(): void;
  48225. /**
  48226. * Gets the name of the current physics plugin
  48227. * @returns the name of the plugin
  48228. */
  48229. getPhysicsPluginName(): string;
  48230. /**
  48231. * Adding a new impostor for the impostor tracking.
  48232. * This will be done by the impostor itself.
  48233. * @param impostor the impostor to add
  48234. */
  48235. addImpostor(impostor: PhysicsImpostor): void;
  48236. /**
  48237. * Remove an impostor from the engine.
  48238. * This impostor and its mesh will not longer be updated by the physics engine.
  48239. * @param impostor the impostor to remove
  48240. */
  48241. removeImpostor(impostor: PhysicsImpostor): void;
  48242. /**
  48243. * Add a joint to the physics engine
  48244. * @param mainImpostor defines the main impostor to which the joint is added.
  48245. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48246. * @param joint defines the joint that will connect both impostors.
  48247. */
  48248. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48249. /**
  48250. * Removes a joint from the simulation
  48251. * @param mainImpostor defines the impostor used with the joint
  48252. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48253. * @param joint defines the joint to remove
  48254. */
  48255. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48256. /**
  48257. * Called by the scene. No need to call it.
  48258. * @param delta defines the timespam between frames
  48259. */
  48260. _step(delta: number): void;
  48261. /**
  48262. * Gets the current plugin used to run the simulation
  48263. * @returns current plugin
  48264. */
  48265. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48266. /**
  48267. * Gets the list of physic impostors
  48268. * @returns an array of PhysicsImpostor
  48269. */
  48270. getImpostors(): Array<PhysicsImpostor>;
  48271. /**
  48272. * Gets the impostor for a physics enabled object
  48273. * @param object defines the object impersonated by the impostor
  48274. * @returns the PhysicsImpostor or null if not found
  48275. */
  48276. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48277. /**
  48278. * Gets the impostor for a physics body object
  48279. * @param body defines physics body used by the impostor
  48280. * @returns the PhysicsImpostor or null if not found
  48281. */
  48282. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48283. /**
  48284. * Does a raycast in the physics world
  48285. * @param from when should the ray start?
  48286. * @param to when should the ray end?
  48287. * @returns PhysicsRaycastResult
  48288. */
  48289. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48290. }
  48291. }
  48292. declare module BABYLON {
  48293. /** @hidden */
  48294. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48295. private _useDeltaForWorldStep;
  48296. world: any;
  48297. name: string;
  48298. private _physicsMaterials;
  48299. private _fixedTimeStep;
  48300. private _cannonRaycastResult;
  48301. private _raycastResult;
  48302. private _removeAfterStep;
  48303. BJSCANNON: any;
  48304. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48305. setGravity(gravity: Vector3): void;
  48306. setTimeStep(timeStep: number): void;
  48307. getTimeStep(): number;
  48308. executeStep(delta: number): void;
  48309. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48310. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48311. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48312. private _processChildMeshes;
  48313. removePhysicsBody(impostor: PhysicsImpostor): void;
  48314. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48315. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48316. private _addMaterial;
  48317. private _checkWithEpsilon;
  48318. private _createShape;
  48319. private _createHeightmap;
  48320. private _minus90X;
  48321. private _plus90X;
  48322. private _tmpPosition;
  48323. private _tmpDeltaPosition;
  48324. private _tmpUnityRotation;
  48325. private _updatePhysicsBodyTransformation;
  48326. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48327. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48328. isSupported(): boolean;
  48329. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48330. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48331. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48332. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48333. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48334. getBodyMass(impostor: PhysicsImpostor): number;
  48335. getBodyFriction(impostor: PhysicsImpostor): number;
  48336. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48337. getBodyRestitution(impostor: PhysicsImpostor): number;
  48338. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48339. sleepBody(impostor: PhysicsImpostor): void;
  48340. wakeUpBody(impostor: PhysicsImpostor): void;
  48341. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48342. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48343. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48344. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48345. getRadius(impostor: PhysicsImpostor): number;
  48346. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48347. dispose(): void;
  48348. private _extendNamespace;
  48349. /**
  48350. * Does a raycast in the physics world
  48351. * @param from when should the ray start?
  48352. * @param to when should the ray end?
  48353. * @returns PhysicsRaycastResult
  48354. */
  48355. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48356. }
  48357. }
  48358. declare module BABYLON {
  48359. /** @hidden */
  48360. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48361. world: any;
  48362. name: string;
  48363. BJSOIMO: any;
  48364. private _raycastResult;
  48365. constructor(iterations?: number, oimoInjection?: any);
  48366. setGravity(gravity: Vector3): void;
  48367. setTimeStep(timeStep: number): void;
  48368. getTimeStep(): number;
  48369. private _tmpImpostorsArray;
  48370. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48371. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48372. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48373. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48374. private _tmpPositionVector;
  48375. removePhysicsBody(impostor: PhysicsImpostor): void;
  48376. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48377. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48378. isSupported(): boolean;
  48379. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48380. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48381. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48382. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48383. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48384. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48385. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48386. getBodyMass(impostor: PhysicsImpostor): number;
  48387. getBodyFriction(impostor: PhysicsImpostor): number;
  48388. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48389. getBodyRestitution(impostor: PhysicsImpostor): number;
  48390. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48391. sleepBody(impostor: PhysicsImpostor): void;
  48392. wakeUpBody(impostor: PhysicsImpostor): void;
  48393. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48394. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48395. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48396. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48397. getRadius(impostor: PhysicsImpostor): number;
  48398. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48399. dispose(): void;
  48400. /**
  48401. * Does a raycast in the physics world
  48402. * @param from when should the ray start?
  48403. * @param to when should the ray end?
  48404. * @returns PhysicsRaycastResult
  48405. */
  48406. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48407. }
  48408. }
  48409. declare module BABYLON {
  48410. /**
  48411. * Class containing static functions to help procedurally build meshes
  48412. */
  48413. export class RibbonBuilder {
  48414. /**
  48415. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48416. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48417. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48418. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48419. * * 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
  48420. * * 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
  48421. * * 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
  48422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48423. * * 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
  48424. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48425. * * 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
  48426. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48427. * * 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
  48428. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48430. * @param name defines the name of the mesh
  48431. * @param options defines the options used to create the mesh
  48432. * @param scene defines the hosting scene
  48433. * @returns the ribbon mesh
  48434. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48435. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48436. */
  48437. static CreateRibbon(name: string, options: {
  48438. pathArray: Vector3[][];
  48439. closeArray?: boolean;
  48440. closePath?: boolean;
  48441. offset?: number;
  48442. updatable?: boolean;
  48443. sideOrientation?: number;
  48444. frontUVs?: Vector4;
  48445. backUVs?: Vector4;
  48446. instance?: Mesh;
  48447. invertUV?: boolean;
  48448. uvs?: Vector2[];
  48449. colors?: Color4[];
  48450. }, scene?: Nullable<Scene>): Mesh;
  48451. }
  48452. }
  48453. declare module BABYLON {
  48454. /**
  48455. * Class containing static functions to help procedurally build meshes
  48456. */
  48457. export class ShapeBuilder {
  48458. /**
  48459. * 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.
  48460. * * 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.
  48461. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48462. * * 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.
  48463. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48464. * * 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
  48465. * * 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
  48466. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48468. * * 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
  48469. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48471. * @param name defines the name of the mesh
  48472. * @param options defines the options used to create the mesh
  48473. * @param scene defines the hosting scene
  48474. * @returns the extruded shape mesh
  48475. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48476. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48477. */
  48478. static ExtrudeShape(name: string, options: {
  48479. shape: Vector3[];
  48480. path: Vector3[];
  48481. scale?: number;
  48482. rotation?: number;
  48483. cap?: number;
  48484. updatable?: boolean;
  48485. sideOrientation?: number;
  48486. frontUVs?: Vector4;
  48487. backUVs?: Vector4;
  48488. instance?: Mesh;
  48489. invertUV?: boolean;
  48490. }, scene?: Nullable<Scene>): Mesh;
  48491. /**
  48492. * Creates an custom extruded shape mesh.
  48493. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48494. * * 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.
  48495. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48496. * * 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
  48497. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48498. * * 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
  48499. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48500. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48501. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48502. * * 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
  48503. * * 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
  48504. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48506. * * 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
  48507. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48509. * @param name defines the name of the mesh
  48510. * @param options defines the options used to create the mesh
  48511. * @param scene defines the hosting scene
  48512. * @returns the custom extruded shape mesh
  48513. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48514. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48515. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48516. */
  48517. static ExtrudeShapeCustom(name: string, options: {
  48518. shape: Vector3[];
  48519. path: Vector3[];
  48520. scaleFunction?: any;
  48521. rotationFunction?: any;
  48522. ribbonCloseArray?: boolean;
  48523. ribbonClosePath?: boolean;
  48524. cap?: number;
  48525. updatable?: boolean;
  48526. sideOrientation?: number;
  48527. frontUVs?: Vector4;
  48528. backUVs?: Vector4;
  48529. instance?: Mesh;
  48530. invertUV?: boolean;
  48531. }, scene?: Nullable<Scene>): Mesh;
  48532. private static _ExtrudeShapeGeneric;
  48533. }
  48534. }
  48535. declare module BABYLON {
  48536. /**
  48537. * AmmoJS Physics plugin
  48538. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48539. * @see https://github.com/kripken/ammo.js/
  48540. */
  48541. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48542. private _useDeltaForWorldStep;
  48543. /**
  48544. * Reference to the Ammo library
  48545. */
  48546. bjsAMMO: any;
  48547. /**
  48548. * Created ammoJS world which physics bodies are added to
  48549. */
  48550. world: any;
  48551. /**
  48552. * Name of the plugin
  48553. */
  48554. name: string;
  48555. private _timeStep;
  48556. private _fixedTimeStep;
  48557. private _maxSteps;
  48558. private _tmpQuaternion;
  48559. private _tmpAmmoTransform;
  48560. private _tmpAmmoQuaternion;
  48561. private _tmpAmmoConcreteContactResultCallback;
  48562. private _collisionConfiguration;
  48563. private _dispatcher;
  48564. private _overlappingPairCache;
  48565. private _solver;
  48566. private _softBodySolver;
  48567. private _tmpAmmoVectorA;
  48568. private _tmpAmmoVectorB;
  48569. private _tmpAmmoVectorC;
  48570. private _tmpAmmoVectorD;
  48571. private _tmpContactCallbackResult;
  48572. private _tmpAmmoVectorRCA;
  48573. private _tmpAmmoVectorRCB;
  48574. private _raycastResult;
  48575. private static readonly DISABLE_COLLISION_FLAG;
  48576. private static readonly KINEMATIC_FLAG;
  48577. private static readonly DISABLE_DEACTIVATION_FLAG;
  48578. /**
  48579. * Initializes the ammoJS plugin
  48580. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48581. * @param ammoInjection can be used to inject your own ammo reference
  48582. */
  48583. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48584. /**
  48585. * Sets the gravity of the physics world (m/(s^2))
  48586. * @param gravity Gravity to set
  48587. */
  48588. setGravity(gravity: Vector3): void;
  48589. /**
  48590. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48591. * @param timeStep timestep to use in seconds
  48592. */
  48593. setTimeStep(timeStep: number): void;
  48594. /**
  48595. * 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)
  48596. * @param fixedTimeStep fixedTimeStep to use in seconds
  48597. */
  48598. setFixedTimeStep(fixedTimeStep: number): void;
  48599. /**
  48600. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48601. * @param maxSteps the maximum number of steps by the physics engine per frame
  48602. */
  48603. setMaxSteps(maxSteps: number): void;
  48604. /**
  48605. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48606. * @returns the current timestep in seconds
  48607. */
  48608. getTimeStep(): number;
  48609. private _isImpostorInContact;
  48610. private _isImpostorPairInContact;
  48611. private _stepSimulation;
  48612. /**
  48613. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48614. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48615. * After the step the babylon meshes are set to the position of the physics imposters
  48616. * @param delta amount of time to step forward
  48617. * @param impostors array of imposters to update before/after the step
  48618. */
  48619. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48620. /**
  48621. * Update babylon mesh to match physics world object
  48622. * @param impostor imposter to match
  48623. */
  48624. private _afterSoftStep;
  48625. /**
  48626. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48627. * @param impostor imposter to match
  48628. */
  48629. private _ropeStep;
  48630. /**
  48631. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48632. * @param impostor imposter to match
  48633. */
  48634. private _softbodyOrClothStep;
  48635. private _tmpVector;
  48636. private _tmpMatrix;
  48637. /**
  48638. * Applies an impulse on the imposter
  48639. * @param impostor imposter to apply impulse to
  48640. * @param force amount of force to be applied to the imposter
  48641. * @param contactPoint the location to apply the impulse on the imposter
  48642. */
  48643. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48644. /**
  48645. * Applies a force on the imposter
  48646. * @param impostor imposter to apply force
  48647. * @param force amount of force to be applied to the imposter
  48648. * @param contactPoint the location to apply the force on the imposter
  48649. */
  48650. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48651. /**
  48652. * Creates a physics body using the plugin
  48653. * @param impostor the imposter to create the physics body on
  48654. */
  48655. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48656. /**
  48657. * Removes the physics body from the imposter and disposes of the body's memory
  48658. * @param impostor imposter to remove the physics body from
  48659. */
  48660. removePhysicsBody(impostor: PhysicsImpostor): void;
  48661. /**
  48662. * Generates a joint
  48663. * @param impostorJoint the imposter joint to create the joint with
  48664. */
  48665. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48666. /**
  48667. * Removes a joint
  48668. * @param impostorJoint the imposter joint to remove the joint from
  48669. */
  48670. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48671. private _addMeshVerts;
  48672. /**
  48673. * Initialise the soft body vertices to match its object's (mesh) vertices
  48674. * Softbody vertices (nodes) are in world space and to match this
  48675. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48676. * @param impostor to create the softbody for
  48677. */
  48678. private _softVertexData;
  48679. /**
  48680. * Create an impostor's soft body
  48681. * @param impostor to create the softbody for
  48682. */
  48683. private _createSoftbody;
  48684. /**
  48685. * Create cloth for an impostor
  48686. * @param impostor to create the softbody for
  48687. */
  48688. private _createCloth;
  48689. /**
  48690. * Create rope for an impostor
  48691. * @param impostor to create the softbody for
  48692. */
  48693. private _createRope;
  48694. private _addHullVerts;
  48695. private _createShape;
  48696. /**
  48697. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48698. * @param impostor imposter containing the physics body and babylon object
  48699. */
  48700. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48701. /**
  48702. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48703. * @param impostor imposter containing the physics body and babylon object
  48704. * @param newPosition new position
  48705. * @param newRotation new rotation
  48706. */
  48707. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48708. /**
  48709. * If this plugin is supported
  48710. * @returns true if its supported
  48711. */
  48712. isSupported(): boolean;
  48713. /**
  48714. * Sets the linear velocity of the physics body
  48715. * @param impostor imposter to set the velocity on
  48716. * @param velocity velocity to set
  48717. */
  48718. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48719. /**
  48720. * Sets the angular velocity of the physics body
  48721. * @param impostor imposter to set the velocity on
  48722. * @param velocity velocity to set
  48723. */
  48724. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48725. /**
  48726. * gets the linear velocity
  48727. * @param impostor imposter to get linear velocity from
  48728. * @returns linear velocity
  48729. */
  48730. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48731. /**
  48732. * gets the angular velocity
  48733. * @param impostor imposter to get angular velocity from
  48734. * @returns angular velocity
  48735. */
  48736. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48737. /**
  48738. * Sets the mass of physics body
  48739. * @param impostor imposter to set the mass on
  48740. * @param mass mass to set
  48741. */
  48742. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48743. /**
  48744. * Gets the mass of the physics body
  48745. * @param impostor imposter to get the mass from
  48746. * @returns mass
  48747. */
  48748. getBodyMass(impostor: PhysicsImpostor): number;
  48749. /**
  48750. * Gets friction of the impostor
  48751. * @param impostor impostor to get friction from
  48752. * @returns friction value
  48753. */
  48754. getBodyFriction(impostor: PhysicsImpostor): number;
  48755. /**
  48756. * Sets friction of the impostor
  48757. * @param impostor impostor to set friction on
  48758. * @param friction friction value
  48759. */
  48760. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48761. /**
  48762. * Gets restitution of the impostor
  48763. * @param impostor impostor to get restitution from
  48764. * @returns restitution value
  48765. */
  48766. getBodyRestitution(impostor: PhysicsImpostor): number;
  48767. /**
  48768. * Sets resitution of the impostor
  48769. * @param impostor impostor to set resitution on
  48770. * @param restitution resitution value
  48771. */
  48772. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48773. /**
  48774. * Gets pressure inside the impostor
  48775. * @param impostor impostor to get pressure from
  48776. * @returns pressure value
  48777. */
  48778. getBodyPressure(impostor: PhysicsImpostor): number;
  48779. /**
  48780. * Sets pressure inside a soft body impostor
  48781. * Cloth and rope must remain 0 pressure
  48782. * @param impostor impostor to set pressure on
  48783. * @param pressure pressure value
  48784. */
  48785. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48786. /**
  48787. * Gets stiffness of the impostor
  48788. * @param impostor impostor to get stiffness from
  48789. * @returns pressure value
  48790. */
  48791. getBodyStiffness(impostor: PhysicsImpostor): number;
  48792. /**
  48793. * Sets stiffness of the impostor
  48794. * @param impostor impostor to set stiffness on
  48795. * @param stiffness stiffness value from 0 to 1
  48796. */
  48797. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48798. /**
  48799. * Gets velocityIterations of the impostor
  48800. * @param impostor impostor to get velocity iterations from
  48801. * @returns velocityIterations value
  48802. */
  48803. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48804. /**
  48805. * Sets velocityIterations of the impostor
  48806. * @param impostor impostor to set velocity iterations on
  48807. * @param velocityIterations velocityIterations value
  48808. */
  48809. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48810. /**
  48811. * Gets positionIterations of the impostor
  48812. * @param impostor impostor to get position iterations from
  48813. * @returns positionIterations value
  48814. */
  48815. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48816. /**
  48817. * Sets positionIterations of the impostor
  48818. * @param impostor impostor to set position on
  48819. * @param positionIterations positionIterations value
  48820. */
  48821. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48822. /**
  48823. * Append an anchor to a cloth object
  48824. * @param impostor is the cloth impostor to add anchor to
  48825. * @param otherImpostor is the rigid impostor to anchor to
  48826. * @param width ratio across width from 0 to 1
  48827. * @param height ratio up height from 0 to 1
  48828. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48829. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48830. */
  48831. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48832. /**
  48833. * Append an hook to a rope object
  48834. * @param impostor is the rope impostor to add hook to
  48835. * @param otherImpostor is the rigid impostor to hook to
  48836. * @param length ratio along the rope from 0 to 1
  48837. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48838. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48839. */
  48840. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48841. /**
  48842. * Sleeps the physics body and stops it from being active
  48843. * @param impostor impostor to sleep
  48844. */
  48845. sleepBody(impostor: PhysicsImpostor): void;
  48846. /**
  48847. * Activates the physics body
  48848. * @param impostor impostor to activate
  48849. */
  48850. wakeUpBody(impostor: PhysicsImpostor): void;
  48851. /**
  48852. * Updates the distance parameters of the joint
  48853. * @param joint joint to update
  48854. * @param maxDistance maximum distance of the joint
  48855. * @param minDistance minimum distance of the joint
  48856. */
  48857. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48858. /**
  48859. * Sets a motor on the joint
  48860. * @param joint joint to set motor on
  48861. * @param speed speed of the motor
  48862. * @param maxForce maximum force of the motor
  48863. * @param motorIndex index of the motor
  48864. */
  48865. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48866. /**
  48867. * Sets the motors limit
  48868. * @param joint joint to set limit on
  48869. * @param upperLimit upper limit
  48870. * @param lowerLimit lower limit
  48871. */
  48872. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48873. /**
  48874. * Syncs the position and rotation of a mesh with the impostor
  48875. * @param mesh mesh to sync
  48876. * @param impostor impostor to update the mesh with
  48877. */
  48878. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48879. /**
  48880. * Gets the radius of the impostor
  48881. * @param impostor impostor to get radius from
  48882. * @returns the radius
  48883. */
  48884. getRadius(impostor: PhysicsImpostor): number;
  48885. /**
  48886. * Gets the box size of the impostor
  48887. * @param impostor impostor to get box size from
  48888. * @param result the resulting box size
  48889. */
  48890. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48891. /**
  48892. * Disposes of the impostor
  48893. */
  48894. dispose(): void;
  48895. /**
  48896. * Does a raycast in the physics world
  48897. * @param from when should the ray start?
  48898. * @param to when should the ray end?
  48899. * @returns PhysicsRaycastResult
  48900. */
  48901. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48902. }
  48903. }
  48904. declare module BABYLON {
  48905. interface AbstractScene {
  48906. /**
  48907. * The list of reflection probes added to the scene
  48908. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48909. */
  48910. reflectionProbes: Array<ReflectionProbe>;
  48911. /**
  48912. * Removes the given reflection probe from this scene.
  48913. * @param toRemove The reflection probe to remove
  48914. * @returns The index of the removed reflection probe
  48915. */
  48916. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48917. /**
  48918. * Adds the given reflection probe to this scene.
  48919. * @param newReflectionProbe The reflection probe to add
  48920. */
  48921. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48922. }
  48923. /**
  48924. * Class used to generate realtime reflection / refraction cube textures
  48925. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48926. */
  48927. export class ReflectionProbe {
  48928. /** defines the name of the probe */
  48929. name: string;
  48930. private _scene;
  48931. private _renderTargetTexture;
  48932. private _projectionMatrix;
  48933. private _viewMatrix;
  48934. private _target;
  48935. private _add;
  48936. private _attachedMesh;
  48937. private _invertYAxis;
  48938. /** Gets or sets probe position (center of the cube map) */
  48939. position: Vector3;
  48940. /**
  48941. * Creates a new reflection probe
  48942. * @param name defines the name of the probe
  48943. * @param size defines the texture resolution (for each face)
  48944. * @param scene defines the hosting scene
  48945. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48946. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48947. */
  48948. constructor(
  48949. /** defines the name of the probe */
  48950. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48951. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48952. samples: number;
  48953. /** Gets or sets the refresh rate to use (on every frame by default) */
  48954. refreshRate: number;
  48955. /**
  48956. * Gets the hosting scene
  48957. * @returns a Scene
  48958. */
  48959. getScene(): Scene;
  48960. /** Gets the internal CubeTexture used to render to */
  48961. readonly cubeTexture: RenderTargetTexture;
  48962. /** Gets the list of meshes to render */
  48963. readonly renderList: Nullable<AbstractMesh[]>;
  48964. /**
  48965. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48966. * @param mesh defines the mesh to attach to
  48967. */
  48968. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48969. /**
  48970. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48971. * @param renderingGroupId The rendering group id corresponding to its index
  48972. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48973. */
  48974. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48975. /**
  48976. * Clean all associated resources
  48977. */
  48978. dispose(): void;
  48979. /**
  48980. * Converts the reflection probe information to a readable string for debug purpose.
  48981. * @param fullDetails Supports for multiple levels of logging within scene loading
  48982. * @returns the human readable reflection probe info
  48983. */
  48984. toString(fullDetails?: boolean): string;
  48985. /**
  48986. * Get the class name of the relfection probe.
  48987. * @returns "ReflectionProbe"
  48988. */
  48989. getClassName(): string;
  48990. /**
  48991. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48992. * @returns The JSON representation of the texture
  48993. */
  48994. serialize(): any;
  48995. /**
  48996. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48997. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48998. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48999. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49000. * @returns The parsed reflection probe if successful
  49001. */
  49002. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49003. }
  49004. }
  49005. declare module BABYLON {
  49006. /** @hidden */
  49007. export var _BabylonLoaderRegistered: boolean;
  49008. }
  49009. declare module BABYLON {
  49010. /**
  49011. * The Physically based simple base material of BJS.
  49012. *
  49013. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49014. * It is used as the base class for both the specGloss and metalRough conventions.
  49015. */
  49016. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49017. /**
  49018. * Number of Simultaneous lights allowed on the material.
  49019. */
  49020. maxSimultaneousLights: number;
  49021. /**
  49022. * If sets to true, disables all the lights affecting the material.
  49023. */
  49024. disableLighting: boolean;
  49025. /**
  49026. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49027. */
  49028. environmentTexture: BaseTexture;
  49029. /**
  49030. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49031. */
  49032. invertNormalMapX: boolean;
  49033. /**
  49034. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49035. */
  49036. invertNormalMapY: boolean;
  49037. /**
  49038. * Normal map used in the model.
  49039. */
  49040. normalTexture: BaseTexture;
  49041. /**
  49042. * Emissivie color used to self-illuminate the model.
  49043. */
  49044. emissiveColor: Color3;
  49045. /**
  49046. * Emissivie texture used to self-illuminate the model.
  49047. */
  49048. emissiveTexture: BaseTexture;
  49049. /**
  49050. * Occlusion Channel Strenght.
  49051. */
  49052. occlusionStrength: number;
  49053. /**
  49054. * Occlusion Texture of the material (adding extra occlusion effects).
  49055. */
  49056. occlusionTexture: BaseTexture;
  49057. /**
  49058. * Defines the alpha limits in alpha test mode.
  49059. */
  49060. alphaCutOff: number;
  49061. /**
  49062. * Gets the current double sided mode.
  49063. */
  49064. /**
  49065. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49066. */
  49067. doubleSided: boolean;
  49068. /**
  49069. * Stores the pre-calculated light information of a mesh in a texture.
  49070. */
  49071. lightmapTexture: BaseTexture;
  49072. /**
  49073. * If true, the light map contains occlusion information instead of lighting info.
  49074. */
  49075. useLightmapAsShadowmap: boolean;
  49076. /**
  49077. * Instantiates a new PBRMaterial instance.
  49078. *
  49079. * @param name The material name
  49080. * @param scene The scene the material will be use in.
  49081. */
  49082. constructor(name: string, scene: Scene);
  49083. getClassName(): string;
  49084. }
  49085. }
  49086. declare module BABYLON {
  49087. /**
  49088. * The PBR material of BJS following the metal roughness convention.
  49089. *
  49090. * This fits to the PBR convention in the GLTF definition:
  49091. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49092. */
  49093. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49094. /**
  49095. * The base color has two different interpretations depending on the value of metalness.
  49096. * When the material is a metal, the base color is the specific measured reflectance value
  49097. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49098. * of the material.
  49099. */
  49100. baseColor: Color3;
  49101. /**
  49102. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49103. * well as opacity information in the alpha channel.
  49104. */
  49105. baseTexture: BaseTexture;
  49106. /**
  49107. * Specifies the metallic scalar value of the material.
  49108. * Can also be used to scale the metalness values of the metallic texture.
  49109. */
  49110. metallic: number;
  49111. /**
  49112. * Specifies the roughness scalar value of the material.
  49113. * Can also be used to scale the roughness values of the metallic texture.
  49114. */
  49115. roughness: number;
  49116. /**
  49117. * Texture containing both the metallic value in the B channel and the
  49118. * roughness value in the G channel to keep better precision.
  49119. */
  49120. metallicRoughnessTexture: BaseTexture;
  49121. /**
  49122. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49123. *
  49124. * @param name The material name
  49125. * @param scene The scene the material will be use in.
  49126. */
  49127. constructor(name: string, scene: Scene);
  49128. /**
  49129. * Return the currrent class name of the material.
  49130. */
  49131. getClassName(): string;
  49132. /**
  49133. * Makes a duplicate of the current material.
  49134. * @param name - name to use for the new material.
  49135. */
  49136. clone(name: string): PBRMetallicRoughnessMaterial;
  49137. /**
  49138. * Serialize the material to a parsable JSON object.
  49139. */
  49140. serialize(): any;
  49141. /**
  49142. * Parses a JSON object correponding to the serialize function.
  49143. */
  49144. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49145. }
  49146. }
  49147. declare module BABYLON {
  49148. /**
  49149. * The PBR material of BJS following the specular glossiness convention.
  49150. *
  49151. * This fits to the PBR convention in the GLTF definition:
  49152. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49153. */
  49154. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49155. /**
  49156. * Specifies the diffuse color of the material.
  49157. */
  49158. diffuseColor: Color3;
  49159. /**
  49160. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49161. * channel.
  49162. */
  49163. diffuseTexture: BaseTexture;
  49164. /**
  49165. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49166. */
  49167. specularColor: Color3;
  49168. /**
  49169. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49170. */
  49171. glossiness: number;
  49172. /**
  49173. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49174. */
  49175. specularGlossinessTexture: BaseTexture;
  49176. /**
  49177. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49178. *
  49179. * @param name The material name
  49180. * @param scene The scene the material will be use in.
  49181. */
  49182. constructor(name: string, scene: Scene);
  49183. /**
  49184. * Return the currrent class name of the material.
  49185. */
  49186. getClassName(): string;
  49187. /**
  49188. * Makes a duplicate of the current material.
  49189. * @param name - name to use for the new material.
  49190. */
  49191. clone(name: string): PBRSpecularGlossinessMaterial;
  49192. /**
  49193. * Serialize the material to a parsable JSON object.
  49194. */
  49195. serialize(): any;
  49196. /**
  49197. * Parses a JSON object correponding to the serialize function.
  49198. */
  49199. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49200. }
  49201. }
  49202. declare module BABYLON {
  49203. /**
  49204. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49205. * It can help converting any input color in a desired output one. This can then be used to create effects
  49206. * from sepia, black and white to sixties or futuristic rendering...
  49207. *
  49208. * The only supported format is currently 3dl.
  49209. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49210. */
  49211. export class ColorGradingTexture extends BaseTexture {
  49212. /**
  49213. * The current texture matrix. (will always be identity in color grading texture)
  49214. */
  49215. private _textureMatrix;
  49216. /**
  49217. * The texture URL.
  49218. */
  49219. url: string;
  49220. /**
  49221. * Empty line regex stored for GC.
  49222. */
  49223. private static _noneEmptyLineRegex;
  49224. private _engine;
  49225. /**
  49226. * Instantiates a ColorGradingTexture from the following parameters.
  49227. *
  49228. * @param url The location of the color gradind data (currently only supporting 3dl)
  49229. * @param scene The scene the texture will be used in
  49230. */
  49231. constructor(url: string, scene: Scene);
  49232. /**
  49233. * Returns the texture matrix used in most of the material.
  49234. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49235. */
  49236. getTextureMatrix(): Matrix;
  49237. /**
  49238. * Occurs when the file being loaded is a .3dl LUT file.
  49239. */
  49240. private load3dlTexture;
  49241. /**
  49242. * Starts the loading process of the texture.
  49243. */
  49244. private loadTexture;
  49245. /**
  49246. * Clones the color gradind texture.
  49247. */
  49248. clone(): ColorGradingTexture;
  49249. /**
  49250. * Called during delayed load for textures.
  49251. */
  49252. delayLoad(): void;
  49253. /**
  49254. * Parses a color grading texture serialized by Babylon.
  49255. * @param parsedTexture The texture information being parsedTexture
  49256. * @param scene The scene to load the texture in
  49257. * @param rootUrl The root url of the data assets to load
  49258. * @return A color gradind texture
  49259. */
  49260. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49261. /**
  49262. * Serializes the LUT texture to json format.
  49263. */
  49264. serialize(): any;
  49265. }
  49266. }
  49267. declare module BABYLON {
  49268. /**
  49269. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49270. */
  49271. export class EquiRectangularCubeTexture extends BaseTexture {
  49272. /** The six faces of the cube. */
  49273. private static _FacesMapping;
  49274. private _noMipmap;
  49275. private _onLoad;
  49276. private _onError;
  49277. /** The size of the cubemap. */
  49278. private _size;
  49279. /** The buffer of the image. */
  49280. private _buffer;
  49281. /** The width of the input image. */
  49282. private _width;
  49283. /** The height of the input image. */
  49284. private _height;
  49285. /** The URL to the image. */
  49286. url: string;
  49287. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49288. coordinatesMode: number;
  49289. /**
  49290. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49291. * @param url The location of the image
  49292. * @param scene The scene the texture will be used in
  49293. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49294. * @param noMipmap Forces to not generate the mipmap if true
  49295. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49296. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49297. * @param onLoad — defines a callback called when texture is loaded
  49298. * @param onError — defines a callback called if there is an error
  49299. */
  49300. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49301. /**
  49302. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49303. */
  49304. private loadImage;
  49305. /**
  49306. * Convert the image buffer into a cubemap and create a CubeTexture.
  49307. */
  49308. private loadTexture;
  49309. /**
  49310. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49311. * @param buffer The ArrayBuffer that should be converted.
  49312. * @returns The buffer as Float32Array.
  49313. */
  49314. private getFloat32ArrayFromArrayBuffer;
  49315. /**
  49316. * Get the current class name of the texture useful for serialization or dynamic coding.
  49317. * @returns "EquiRectangularCubeTexture"
  49318. */
  49319. getClassName(): string;
  49320. /**
  49321. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49322. * @returns A clone of the current EquiRectangularCubeTexture.
  49323. */
  49324. clone(): EquiRectangularCubeTexture;
  49325. }
  49326. }
  49327. declare module BABYLON {
  49328. /**
  49329. * Based on jsTGALoader - Javascript loader for TGA file
  49330. * By Vincent Thibault
  49331. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49332. */
  49333. export class TGATools {
  49334. private static _TYPE_INDEXED;
  49335. private static _TYPE_RGB;
  49336. private static _TYPE_GREY;
  49337. private static _TYPE_RLE_INDEXED;
  49338. private static _TYPE_RLE_RGB;
  49339. private static _TYPE_RLE_GREY;
  49340. private static _ORIGIN_MASK;
  49341. private static _ORIGIN_SHIFT;
  49342. private static _ORIGIN_BL;
  49343. private static _ORIGIN_BR;
  49344. private static _ORIGIN_UL;
  49345. private static _ORIGIN_UR;
  49346. /**
  49347. * Gets the header of a TGA file
  49348. * @param data defines the TGA data
  49349. * @returns the header
  49350. */
  49351. static GetTGAHeader(data: Uint8Array): any;
  49352. /**
  49353. * Uploads TGA content to a Babylon Texture
  49354. * @hidden
  49355. */
  49356. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49357. /** @hidden */
  49358. 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;
  49359. /** @hidden */
  49360. 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;
  49361. /** @hidden */
  49362. 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;
  49363. /** @hidden */
  49364. 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;
  49365. /** @hidden */
  49366. 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;
  49367. /** @hidden */
  49368. 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;
  49369. }
  49370. }
  49371. declare module BABYLON {
  49372. /**
  49373. * Implementation of the TGA Texture Loader.
  49374. * @hidden
  49375. */
  49376. export class _TGATextureLoader implements IInternalTextureLoader {
  49377. /**
  49378. * Defines wether the loader supports cascade loading the different faces.
  49379. */
  49380. readonly supportCascades: boolean;
  49381. /**
  49382. * This returns if the loader support the current file information.
  49383. * @param extension defines the file extension of the file being loaded
  49384. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49385. * @param fallback defines the fallback internal texture if any
  49386. * @param isBase64 defines whether the texture is encoded as a base64
  49387. * @param isBuffer defines whether the texture data are stored as a buffer
  49388. * @returns true if the loader can load the specified file
  49389. */
  49390. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49391. /**
  49392. * Transform the url before loading if required.
  49393. * @param rootUrl the url of the texture
  49394. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49395. * @returns the transformed texture
  49396. */
  49397. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49398. /**
  49399. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49400. * @param rootUrl the url of the texture
  49401. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49402. * @returns the fallback texture
  49403. */
  49404. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49405. /**
  49406. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49407. * @param data contains the texture data
  49408. * @param texture defines the BabylonJS internal texture
  49409. * @param createPolynomials will be true if polynomials have been requested
  49410. * @param onLoad defines the callback to trigger once the texture is ready
  49411. * @param onError defines the callback to trigger in case of error
  49412. */
  49413. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49414. /**
  49415. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49416. * @param data contains the texture data
  49417. * @param texture defines the BabylonJS internal texture
  49418. * @param callback defines the method to call once ready to upload
  49419. */
  49420. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49421. }
  49422. }
  49423. declare module BABYLON {
  49424. /**
  49425. * 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.
  49426. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49427. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49428. */
  49429. export class CustomProceduralTexture extends ProceduralTexture {
  49430. private _animate;
  49431. private _time;
  49432. private _config;
  49433. private _texturePath;
  49434. /**
  49435. * Instantiates a new Custom Procedural Texture.
  49436. * 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.
  49437. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49438. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49439. * @param name Define the name of the texture
  49440. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49441. * @param size Define the size of the texture to create
  49442. * @param scene Define the scene the texture belongs to
  49443. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49444. * @param generateMipMaps Define if the texture should creates mip maps or not
  49445. */
  49446. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49447. private _loadJson;
  49448. /**
  49449. * Is the texture ready to be used ? (rendered at least once)
  49450. * @returns true if ready, otherwise, false.
  49451. */
  49452. isReady(): boolean;
  49453. /**
  49454. * Render the texture to its associated render target.
  49455. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49456. */
  49457. render(useCameraPostProcess?: boolean): void;
  49458. /**
  49459. * Update the list of dependant textures samplers in the shader.
  49460. */
  49461. updateTextures(): void;
  49462. /**
  49463. * Update the uniform values of the procedural texture in the shader.
  49464. */
  49465. updateShaderUniforms(): void;
  49466. /**
  49467. * Define if the texture animates or not.
  49468. */
  49469. animate: boolean;
  49470. }
  49471. }
  49472. declare module BABYLON {
  49473. /** @hidden */
  49474. export var noisePixelShader: {
  49475. name: string;
  49476. shader: string;
  49477. };
  49478. }
  49479. declare module BABYLON {
  49480. /**
  49481. * Class used to generate noise procedural textures
  49482. */
  49483. export class NoiseProceduralTexture extends ProceduralTexture {
  49484. private _time;
  49485. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49486. brightness: number;
  49487. /** Defines the number of octaves to process */
  49488. octaves: number;
  49489. /** Defines the level of persistence (0.8 by default) */
  49490. persistence: number;
  49491. /** Gets or sets animation speed factor (default is 1) */
  49492. animationSpeedFactor: number;
  49493. /**
  49494. * Creates a new NoiseProceduralTexture
  49495. * @param name defines the name fo the texture
  49496. * @param size defines the size of the texture (default is 256)
  49497. * @param scene defines the hosting scene
  49498. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49499. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49500. */
  49501. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49502. private _updateShaderUniforms;
  49503. protected _getDefines(): string;
  49504. /** Generate the current state of the procedural texture */
  49505. render(useCameraPostProcess?: boolean): void;
  49506. /**
  49507. * Serializes this noise procedural texture
  49508. * @returns a serialized noise procedural texture object
  49509. */
  49510. serialize(): any;
  49511. /**
  49512. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49513. * @param parsedTexture defines parsed texture data
  49514. * @param scene defines the current scene
  49515. * @param rootUrl defines the root URL containing noise procedural texture information
  49516. * @returns a parsed NoiseProceduralTexture
  49517. */
  49518. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49519. }
  49520. }
  49521. declare module BABYLON {
  49522. /**
  49523. * Raw cube texture where the raw buffers are passed in
  49524. */
  49525. export class RawCubeTexture extends CubeTexture {
  49526. /**
  49527. * Creates a cube texture where the raw buffers are passed in.
  49528. * @param scene defines the scene the texture is attached to
  49529. * @param data defines the array of data to use to create each face
  49530. * @param size defines the size of the textures
  49531. * @param format defines the format of the data
  49532. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49533. * @param generateMipMaps defines if the engine should generate the mip levels
  49534. * @param invertY defines if data must be stored with Y axis inverted
  49535. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49536. * @param compression defines the compression used (null by default)
  49537. */
  49538. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49539. /**
  49540. * Updates the raw cube texture.
  49541. * @param data defines the data to store
  49542. * @param format defines the data format
  49543. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49544. * @param invertY defines if data must be stored with Y axis inverted
  49545. * @param compression defines the compression used (null by default)
  49546. * @param level defines which level of the texture to update
  49547. */
  49548. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49549. /**
  49550. * Updates a raw cube texture with RGBD encoded data.
  49551. * @param data defines the array of data [mipmap][face] to use to create each face
  49552. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49553. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49554. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49555. * @returns a promsie that resolves when the operation is complete
  49556. */
  49557. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49558. /**
  49559. * Clones the raw cube texture.
  49560. * @return a new cube texture
  49561. */
  49562. clone(): CubeTexture;
  49563. /** @hidden */
  49564. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49565. }
  49566. }
  49567. declare module BABYLON {
  49568. /**
  49569. * Class used to store 3D textures containing user data
  49570. */
  49571. export class RawTexture3D extends Texture {
  49572. /** Gets or sets the texture format to use */
  49573. format: number;
  49574. private _engine;
  49575. /**
  49576. * Create a new RawTexture3D
  49577. * @param data defines the data of the texture
  49578. * @param width defines the width of the texture
  49579. * @param height defines the height of the texture
  49580. * @param depth defines the depth of the texture
  49581. * @param format defines the texture format to use
  49582. * @param scene defines the hosting scene
  49583. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49584. * @param invertY defines if texture must be stored with Y axis inverted
  49585. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49586. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49587. */
  49588. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49589. /** Gets or sets the texture format to use */
  49590. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49591. /**
  49592. * Update the texture with new data
  49593. * @param data defines the data to store in the texture
  49594. */
  49595. update(data: ArrayBufferView): void;
  49596. }
  49597. }
  49598. declare module BABYLON {
  49599. /**
  49600. * Creates a refraction texture used by refraction channel of the standard material.
  49601. * It is like a mirror but to see through a material.
  49602. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49603. */
  49604. export class RefractionTexture extends RenderTargetTexture {
  49605. /**
  49606. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49607. * 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.
  49608. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49609. */
  49610. refractionPlane: Plane;
  49611. /**
  49612. * Define how deep under the surface we should see.
  49613. */
  49614. depth: number;
  49615. /**
  49616. * Creates a refraction texture used by refraction channel of the standard material.
  49617. * It is like a mirror but to see through a material.
  49618. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49619. * @param name Define the texture name
  49620. * @param size Define the size of the underlying texture
  49621. * @param scene Define the scene the refraction belongs to
  49622. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49623. */
  49624. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49625. /**
  49626. * Clone the refraction texture.
  49627. * @returns the cloned texture
  49628. */
  49629. clone(): RefractionTexture;
  49630. /**
  49631. * Serialize the texture to a JSON representation you could use in Parse later on
  49632. * @returns the serialized JSON representation
  49633. */
  49634. serialize(): any;
  49635. }
  49636. }
  49637. declare module BABYLON {
  49638. /**
  49639. * Defines the options related to the creation of an HtmlElementTexture
  49640. */
  49641. export interface IHtmlElementTextureOptions {
  49642. /**
  49643. * Defines wether mip maps should be created or not.
  49644. */
  49645. generateMipMaps?: boolean;
  49646. /**
  49647. * Defines the sampling mode of the texture.
  49648. */
  49649. samplingMode?: number;
  49650. /**
  49651. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  49652. */
  49653. engine: Nullable<Engine>;
  49654. /**
  49655. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  49656. */
  49657. scene: Nullable<Scene>;
  49658. }
  49659. /**
  49660. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  49661. * To be as efficient as possible depending on your constraints nothing aside the first upload
  49662. * is automatically managed.
  49663. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  49664. * in your application.
  49665. *
  49666. * As the update is not automatic, you need to call them manually.
  49667. */
  49668. export class HtmlElementTexture extends BaseTexture {
  49669. /**
  49670. * The texture URL.
  49671. */
  49672. element: HTMLVideoElement | HTMLCanvasElement;
  49673. private static readonly DefaultOptions;
  49674. private _textureMatrix;
  49675. private _engine;
  49676. private _isVideo;
  49677. private _generateMipMaps;
  49678. private _samplingMode;
  49679. /**
  49680. * Instantiates a HtmlElementTexture from the following parameters.
  49681. *
  49682. * @param name Defines the name of the texture
  49683. * @param element Defines the video or canvas the texture is filled with
  49684. * @param options Defines the other none mandatory texture creation options
  49685. */
  49686. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  49687. private _createInternalTexture;
  49688. /**
  49689. * Returns the texture matrix used in most of the material.
  49690. */
  49691. getTextureMatrix(): Matrix;
  49692. /**
  49693. * Updates the content of the texture.
  49694. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  49695. */
  49696. update(invertY?: Nullable<boolean>): void;
  49697. }
  49698. }
  49699. declare module BABYLON {
  49700. /**
  49701. * Helper class to push actions to a pool of workers.
  49702. */
  49703. export class WorkerPool implements IDisposable {
  49704. private _workerInfos;
  49705. private _pendingActions;
  49706. /**
  49707. * Constructor
  49708. * @param workers Array of workers to use for actions
  49709. */
  49710. constructor(workers: Array<Worker>);
  49711. /**
  49712. * Terminates all workers and clears any pending actions.
  49713. */
  49714. dispose(): void;
  49715. /**
  49716. * Pushes an action to the worker pool. If all the workers are active, the action will be
  49717. * pended until a worker has completed its action.
  49718. * @param action The action to perform. Call onComplete when the action is complete.
  49719. */
  49720. push(action: (worker: Worker, onComplete: () => void) => void): void;
  49721. private _execute;
  49722. }
  49723. }
  49724. declare module BABYLON {
  49725. /**
  49726. * Configuration for Draco compression
  49727. */
  49728. export interface IDracoCompressionConfiguration {
  49729. /**
  49730. * Configuration for the decoder.
  49731. */
  49732. decoder: {
  49733. /**
  49734. * The url to the WebAssembly module.
  49735. */
  49736. wasmUrl?: string;
  49737. /**
  49738. * The url to the WebAssembly binary.
  49739. */
  49740. wasmBinaryUrl?: string;
  49741. /**
  49742. * The url to the fallback JavaScript module.
  49743. */
  49744. fallbackUrl?: string;
  49745. };
  49746. }
  49747. /**
  49748. * Draco compression (https://google.github.io/draco/)
  49749. *
  49750. * This class wraps the Draco module.
  49751. *
  49752. * **Encoder**
  49753. *
  49754. * The encoder is not currently implemented.
  49755. *
  49756. * **Decoder**
  49757. *
  49758. * 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.
  49759. *
  49760. * To update the configuration, use the following code:
  49761. * ```javascript
  49762. * DracoCompression.Configuration = {
  49763. * decoder: {
  49764. * wasmUrl: "<url to the WebAssembly library>",
  49765. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49766. * fallbackUrl: "<url to the fallback JavaScript library>",
  49767. * }
  49768. * };
  49769. * ```
  49770. *
  49771. * 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.
  49772. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49773. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  49774. *
  49775. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  49776. * ```javascript
  49777. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  49778. * ```
  49779. *
  49780. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49781. */
  49782. export class DracoCompression implements IDisposable {
  49783. private _workerPoolPromise?;
  49784. private _decoderModulePromise?;
  49785. /**
  49786. * The configuration. Defaults to the following urls:
  49787. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49788. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49789. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49790. */
  49791. static Configuration: IDracoCompressionConfiguration;
  49792. /**
  49793. * Returns true if the decoder configuration is available.
  49794. */
  49795. static readonly DecoderAvailable: boolean;
  49796. /**
  49797. * Default number of workers to create when creating the draco compression object.
  49798. */
  49799. static DefaultNumWorkers: number;
  49800. private static GetDefaultNumWorkers;
  49801. private static _Default;
  49802. /**
  49803. * Default instance for the draco compression object.
  49804. */
  49805. static readonly Default: DracoCompression;
  49806. /**
  49807. * Constructor
  49808. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  49809. */
  49810. constructor(numWorkers?: number);
  49811. /**
  49812. * Stop all async operations and release resources.
  49813. */
  49814. dispose(): void;
  49815. /**
  49816. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  49817. * @returns a promise that resolves when ready
  49818. */
  49819. whenReadyAsync(): Promise<void>;
  49820. /**
  49821. * Decode Draco compressed mesh data to vertex data.
  49822. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49823. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49824. * @returns A promise that resolves with the decoded vertex data
  49825. */
  49826. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  49827. [kind: string]: number;
  49828. }): Promise<VertexData>;
  49829. }
  49830. }
  49831. declare module BABYLON {
  49832. /**
  49833. * Class for building Constructive Solid Geometry
  49834. */
  49835. export class CSG {
  49836. private polygons;
  49837. /**
  49838. * The world matrix
  49839. */
  49840. matrix: Matrix;
  49841. /**
  49842. * Stores the position
  49843. */
  49844. position: Vector3;
  49845. /**
  49846. * Stores the rotation
  49847. */
  49848. rotation: Vector3;
  49849. /**
  49850. * Stores the rotation quaternion
  49851. */
  49852. rotationQuaternion: Nullable<Quaternion>;
  49853. /**
  49854. * Stores the scaling vector
  49855. */
  49856. scaling: Vector3;
  49857. /**
  49858. * Convert the Mesh to CSG
  49859. * @param mesh The Mesh to convert to CSG
  49860. * @returns A new CSG from the Mesh
  49861. */
  49862. static FromMesh(mesh: Mesh): CSG;
  49863. /**
  49864. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49865. * @param polygons Polygons used to construct a CSG solid
  49866. */
  49867. private static FromPolygons;
  49868. /**
  49869. * Clones, or makes a deep copy, of the CSG
  49870. * @returns A new CSG
  49871. */
  49872. clone(): CSG;
  49873. /**
  49874. * Unions this CSG with another CSG
  49875. * @param csg The CSG to union against this CSG
  49876. * @returns The unioned CSG
  49877. */
  49878. union(csg: CSG): CSG;
  49879. /**
  49880. * Unions this CSG with another CSG in place
  49881. * @param csg The CSG to union against this CSG
  49882. */
  49883. unionInPlace(csg: CSG): void;
  49884. /**
  49885. * Subtracts this CSG with another CSG
  49886. * @param csg The CSG to subtract against this CSG
  49887. * @returns A new CSG
  49888. */
  49889. subtract(csg: CSG): CSG;
  49890. /**
  49891. * Subtracts this CSG with another CSG in place
  49892. * @param csg The CSG to subtact against this CSG
  49893. */
  49894. subtractInPlace(csg: CSG): void;
  49895. /**
  49896. * Intersect this CSG with another CSG
  49897. * @param csg The CSG to intersect against this CSG
  49898. * @returns A new CSG
  49899. */
  49900. intersect(csg: CSG): CSG;
  49901. /**
  49902. * Intersects this CSG with another CSG in place
  49903. * @param csg The CSG to intersect against this CSG
  49904. */
  49905. intersectInPlace(csg: CSG): void;
  49906. /**
  49907. * Return a new CSG solid with solid and empty space switched. This solid is
  49908. * not modified.
  49909. * @returns A new CSG solid with solid and empty space switched
  49910. */
  49911. inverse(): CSG;
  49912. /**
  49913. * Inverses the CSG in place
  49914. */
  49915. inverseInPlace(): void;
  49916. /**
  49917. * This is used to keep meshes transformations so they can be restored
  49918. * when we build back a Babylon Mesh
  49919. * NB : All CSG operations are performed in world coordinates
  49920. * @param csg The CSG to copy the transform attributes from
  49921. * @returns This CSG
  49922. */
  49923. copyTransformAttributes(csg: CSG): CSG;
  49924. /**
  49925. * Build Raw mesh from CSG
  49926. * Coordinates here are in world space
  49927. * @param name The name of the mesh geometry
  49928. * @param scene The Scene
  49929. * @param keepSubMeshes Specifies if the submeshes should be kept
  49930. * @returns A new Mesh
  49931. */
  49932. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49933. /**
  49934. * Build Mesh from CSG taking material and transforms into account
  49935. * @param name The name of the Mesh
  49936. * @param material The material of the Mesh
  49937. * @param scene The Scene
  49938. * @param keepSubMeshes Specifies if submeshes should be kept
  49939. * @returns The new Mesh
  49940. */
  49941. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49942. }
  49943. }
  49944. declare module BABYLON {
  49945. /**
  49946. * Class used to create a trail following a mesh
  49947. */
  49948. export class TrailMesh extends Mesh {
  49949. private _generator;
  49950. private _autoStart;
  49951. private _running;
  49952. private _diameter;
  49953. private _length;
  49954. private _sectionPolygonPointsCount;
  49955. private _sectionVectors;
  49956. private _sectionNormalVectors;
  49957. private _beforeRenderObserver;
  49958. /**
  49959. * @constructor
  49960. * @param name The value used by scene.getMeshByName() to do a lookup.
  49961. * @param generator The mesh to generate a trail.
  49962. * @param scene The scene to add this mesh to.
  49963. * @param diameter Diameter of trailing mesh. Default is 1.
  49964. * @param length Length of trailing mesh. Default is 60.
  49965. * @param autoStart Automatically start trailing mesh. Default true.
  49966. */
  49967. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49968. /**
  49969. * "TrailMesh"
  49970. * @returns "TrailMesh"
  49971. */
  49972. getClassName(): string;
  49973. private _createMesh;
  49974. /**
  49975. * Start trailing mesh.
  49976. */
  49977. start(): void;
  49978. /**
  49979. * Stop trailing mesh.
  49980. */
  49981. stop(): void;
  49982. /**
  49983. * Update trailing mesh geometry.
  49984. */
  49985. update(): void;
  49986. /**
  49987. * Returns a new TrailMesh object.
  49988. * @param name is a string, the name given to the new mesh
  49989. * @param newGenerator use new generator object for cloned trail mesh
  49990. * @returns a new mesh
  49991. */
  49992. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49993. /**
  49994. * Serializes this trail mesh
  49995. * @param serializationObject object to write serialization to
  49996. */
  49997. serialize(serializationObject: any): void;
  49998. /**
  49999. * Parses a serialized trail mesh
  50000. * @param parsedMesh the serialized mesh
  50001. * @param scene the scene to create the trail mesh in
  50002. * @returns the created trail mesh
  50003. */
  50004. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50005. }
  50006. }
  50007. declare module BABYLON {
  50008. /**
  50009. * Class containing static functions to help procedurally build meshes
  50010. */
  50011. export class TorusKnotBuilder {
  50012. /**
  50013. * Creates a torus knot mesh
  50014. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50015. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50016. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50017. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50019. * * 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
  50020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50021. * @param name defines the name of the mesh
  50022. * @param options defines the options used to create the mesh
  50023. * @param scene defines the hosting scene
  50024. * @returns the torus knot mesh
  50025. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50026. */
  50027. static CreateTorusKnot(name: string, options: {
  50028. radius?: number;
  50029. tube?: number;
  50030. radialSegments?: number;
  50031. tubularSegments?: number;
  50032. p?: number;
  50033. q?: number;
  50034. updatable?: boolean;
  50035. sideOrientation?: number;
  50036. frontUVs?: Vector4;
  50037. backUVs?: Vector4;
  50038. }, scene: any): Mesh;
  50039. }
  50040. }
  50041. declare module BABYLON {
  50042. /**
  50043. * Polygon
  50044. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50045. */
  50046. export class Polygon {
  50047. /**
  50048. * Creates a rectangle
  50049. * @param xmin bottom X coord
  50050. * @param ymin bottom Y coord
  50051. * @param xmax top X coord
  50052. * @param ymax top Y coord
  50053. * @returns points that make the resulting rectation
  50054. */
  50055. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50056. /**
  50057. * Creates a circle
  50058. * @param radius radius of circle
  50059. * @param cx scale in x
  50060. * @param cy scale in y
  50061. * @param numberOfSides number of sides that make up the circle
  50062. * @returns points that make the resulting circle
  50063. */
  50064. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50065. /**
  50066. * Creates a polygon from input string
  50067. * @param input Input polygon data
  50068. * @returns the parsed points
  50069. */
  50070. static Parse(input: string): Vector2[];
  50071. /**
  50072. * Starts building a polygon from x and y coordinates
  50073. * @param x x coordinate
  50074. * @param y y coordinate
  50075. * @returns the started path2
  50076. */
  50077. static StartingAt(x: number, y: number): Path2;
  50078. }
  50079. /**
  50080. * Builds a polygon
  50081. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50082. */
  50083. export class PolygonMeshBuilder {
  50084. private _points;
  50085. private _outlinepoints;
  50086. private _holes;
  50087. private _name;
  50088. private _scene;
  50089. private _epoints;
  50090. private _eholes;
  50091. private _addToepoint;
  50092. /**
  50093. * Babylon reference to the earcut plugin.
  50094. */
  50095. bjsEarcut: any;
  50096. /**
  50097. * Creates a PolygonMeshBuilder
  50098. * @param name name of the builder
  50099. * @param contours Path of the polygon
  50100. * @param scene scene to add to when creating the mesh
  50101. * @param earcutInjection can be used to inject your own earcut reference
  50102. */
  50103. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  50104. /**
  50105. * Adds a whole within the polygon
  50106. * @param hole Array of points defining the hole
  50107. * @returns this
  50108. */
  50109. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50110. /**
  50111. * Creates the polygon
  50112. * @param updatable If the mesh should be updatable
  50113. * @param depth The depth of the mesh created
  50114. * @returns the created mesh
  50115. */
  50116. build(updatable?: boolean, depth?: number): Mesh;
  50117. /**
  50118. * Creates the polygon
  50119. * @param depth The depth of the mesh created
  50120. * @returns the created VertexData
  50121. */
  50122. buildVertexData(depth?: number): VertexData;
  50123. /**
  50124. * Adds a side to the polygon
  50125. * @param positions points that make the polygon
  50126. * @param normals normals of the polygon
  50127. * @param uvs uvs of the polygon
  50128. * @param indices indices of the polygon
  50129. * @param bounds bounds of the polygon
  50130. * @param points points of the polygon
  50131. * @param depth depth of the polygon
  50132. * @param flip flip of the polygon
  50133. */
  50134. private addSide;
  50135. }
  50136. }
  50137. declare module BABYLON {
  50138. /**
  50139. * Class containing static functions to help procedurally build meshes
  50140. */
  50141. export class PolygonBuilder {
  50142. /**
  50143. * Creates a polygon mesh
  50144. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50145. * * 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
  50146. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50148. * * 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)
  50149. * * Remember you can only change the shape positions, not their number when updating a polygon
  50150. * @param name defines the name of the mesh
  50151. * @param options defines the options used to create the mesh
  50152. * @param scene defines the hosting scene
  50153. * @param earcutInjection can be used to inject your own earcut reference
  50154. * @returns the polygon mesh
  50155. */
  50156. static CreatePolygon(name: string, options: {
  50157. shape: Vector3[];
  50158. holes?: Vector3[][];
  50159. depth?: number;
  50160. faceUV?: Vector4[];
  50161. faceColors?: Color4[];
  50162. updatable?: boolean;
  50163. sideOrientation?: number;
  50164. frontUVs?: Vector4;
  50165. backUVs?: Vector4;
  50166. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50167. /**
  50168. * Creates an extruded polygon mesh, with depth in the Y direction.
  50169. * * 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)
  50170. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50171. * @param name defines the name of the mesh
  50172. * @param options defines the options used to create the mesh
  50173. * @param scene defines the hosting scene
  50174. * @param earcutInjection can be used to inject your own earcut reference
  50175. * @returns the polygon mesh
  50176. */
  50177. static ExtrudePolygon(name: string, options: {
  50178. shape: Vector3[];
  50179. holes?: Vector3[][];
  50180. depth?: number;
  50181. faceUV?: Vector4[];
  50182. faceColors?: Color4[];
  50183. updatable?: boolean;
  50184. sideOrientation?: number;
  50185. frontUVs?: Vector4;
  50186. backUVs?: Vector4;
  50187. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50188. }
  50189. }
  50190. declare module BABYLON {
  50191. /**
  50192. * Class containing static functions to help procedurally build meshes
  50193. */
  50194. export class LatheBuilder {
  50195. /**
  50196. * Creates lathe mesh.
  50197. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50198. * * 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
  50199. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50200. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50201. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50202. * * 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
  50203. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50204. * * 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
  50205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50206. * * 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
  50207. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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. * @returns the lathe mesh
  50213. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50214. */
  50215. static CreateLathe(name: string, options: {
  50216. shape: Vector3[];
  50217. radius?: number;
  50218. tessellation?: number;
  50219. clip?: number;
  50220. arc?: number;
  50221. closed?: boolean;
  50222. updatable?: boolean;
  50223. sideOrientation?: number;
  50224. frontUVs?: Vector4;
  50225. backUVs?: Vector4;
  50226. cap?: number;
  50227. invertUV?: boolean;
  50228. }, scene?: Nullable<Scene>): Mesh;
  50229. }
  50230. }
  50231. declare module BABYLON {
  50232. /**
  50233. * Class containing static functions to help procedurally build meshes
  50234. */
  50235. export class TubeBuilder {
  50236. /**
  50237. * Creates a tube mesh.
  50238. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50239. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50240. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50241. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50242. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50243. * * 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)
  50244. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50245. * * 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
  50246. * * 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
  50247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50248. * * 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
  50249. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50251. * @param name defines the name of the mesh
  50252. * @param options defines the options used to create the mesh
  50253. * @param scene defines the hosting scene
  50254. * @returns the tube mesh
  50255. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50256. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50257. */
  50258. static CreateTube(name: string, options: {
  50259. path: Vector3[];
  50260. radius?: number;
  50261. tessellation?: number;
  50262. radiusFunction?: {
  50263. (i: number, distance: number): number;
  50264. };
  50265. cap?: number;
  50266. arc?: number;
  50267. updatable?: boolean;
  50268. sideOrientation?: number;
  50269. frontUVs?: Vector4;
  50270. backUVs?: Vector4;
  50271. instance?: Mesh;
  50272. invertUV?: boolean;
  50273. }, scene?: Nullable<Scene>): Mesh;
  50274. }
  50275. }
  50276. declare module BABYLON {
  50277. /**
  50278. * Class containing static functions to help procedurally build meshes
  50279. */
  50280. export class IcoSphereBuilder {
  50281. /**
  50282. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50283. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50284. * * 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`)
  50285. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50286. * * 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
  50287. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50288. * * 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
  50289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50290. * @param name defines the name of the mesh
  50291. * @param options defines the options used to create the mesh
  50292. * @param scene defines the hosting scene
  50293. * @returns the icosahedron mesh
  50294. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50295. */
  50296. static CreateIcoSphere(name: string, options: {
  50297. radius?: number;
  50298. radiusX?: number;
  50299. radiusY?: number;
  50300. radiusZ?: number;
  50301. flat?: boolean;
  50302. subdivisions?: number;
  50303. sideOrientation?: number;
  50304. frontUVs?: Vector4;
  50305. backUVs?: Vector4;
  50306. updatable?: boolean;
  50307. }, scene?: Nullable<Scene>): Mesh;
  50308. }
  50309. }
  50310. declare module BABYLON {
  50311. /**
  50312. * Class containing static functions to help procedurally build meshes
  50313. */
  50314. export class DecalBuilder {
  50315. /**
  50316. * Creates a decal mesh.
  50317. * 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
  50318. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50319. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50320. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50321. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50322. * @param name defines the name of the mesh
  50323. * @param sourceMesh defines the mesh where the decal must be applied
  50324. * @param options defines the options used to create the mesh
  50325. * @param scene defines the hosting scene
  50326. * @returns the decal mesh
  50327. * @see https://doc.babylonjs.com/how_to/decals
  50328. */
  50329. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50330. position?: Vector3;
  50331. normal?: Vector3;
  50332. size?: Vector3;
  50333. angle?: number;
  50334. }): Mesh;
  50335. }
  50336. }
  50337. declare module BABYLON {
  50338. /**
  50339. * Class containing static functions to help procedurally build meshes
  50340. */
  50341. export class MeshBuilder {
  50342. /**
  50343. * Creates a box mesh
  50344. * * The parameter `size` sets the size (float) of each box side (default 1)
  50345. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50346. * * 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)
  50347. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50349. * * 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
  50350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50351. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50352. * @param name defines the name of the mesh
  50353. * @param options defines the options used to create the mesh
  50354. * @param scene defines the hosting scene
  50355. * @returns the box mesh
  50356. */
  50357. static CreateBox(name: string, options: {
  50358. size?: number;
  50359. width?: number;
  50360. height?: number;
  50361. depth?: number;
  50362. faceUV?: Vector4[];
  50363. faceColors?: Color4[];
  50364. sideOrientation?: number;
  50365. frontUVs?: Vector4;
  50366. backUVs?: Vector4;
  50367. updatable?: boolean;
  50368. }, scene?: Nullable<Scene>): Mesh;
  50369. /**
  50370. * Creates a sphere mesh
  50371. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50372. * * 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`)
  50373. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50374. * * 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
  50375. * * 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)
  50376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50377. * * 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
  50378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50379. * @param name defines the name of the mesh
  50380. * @param options defines the options used to create the mesh
  50381. * @param scene defines the hosting scene
  50382. * @returns the sphere mesh
  50383. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50384. */
  50385. static CreateSphere(name: string, options: {
  50386. segments?: number;
  50387. diameter?: number;
  50388. diameterX?: number;
  50389. diameterY?: number;
  50390. diameterZ?: number;
  50391. arc?: number;
  50392. slice?: number;
  50393. sideOrientation?: number;
  50394. frontUVs?: Vector4;
  50395. backUVs?: Vector4;
  50396. updatable?: boolean;
  50397. }, scene?: Nullable<Scene>): Mesh;
  50398. /**
  50399. * Creates a plane polygonal mesh. By default, this is a disc
  50400. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50401. * * 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
  50402. * * 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
  50403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50404. * * 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
  50405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50406. * @param name defines the name of the mesh
  50407. * @param options defines the options used to create the mesh
  50408. * @param scene defines the hosting scene
  50409. * @returns the plane polygonal mesh
  50410. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50411. */
  50412. static CreateDisc(name: string, options: {
  50413. radius?: number;
  50414. tessellation?: number;
  50415. arc?: number;
  50416. updatable?: boolean;
  50417. sideOrientation?: number;
  50418. frontUVs?: Vector4;
  50419. backUVs?: Vector4;
  50420. }, scene?: Nullable<Scene>): Mesh;
  50421. /**
  50422. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50423. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50424. * * 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`)
  50425. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50426. * * 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
  50427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50428. * * 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
  50429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50430. * @param name defines the name of the mesh
  50431. * @param options defines the options used to create the mesh
  50432. * @param scene defines the hosting scene
  50433. * @returns the icosahedron mesh
  50434. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50435. */
  50436. static CreateIcoSphere(name: string, options: {
  50437. radius?: number;
  50438. radiusX?: number;
  50439. radiusY?: number;
  50440. radiusZ?: number;
  50441. flat?: boolean;
  50442. subdivisions?: number;
  50443. sideOrientation?: number;
  50444. frontUVs?: Vector4;
  50445. backUVs?: Vector4;
  50446. updatable?: boolean;
  50447. }, scene?: Nullable<Scene>): Mesh;
  50448. /**
  50449. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50450. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50451. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50452. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50453. * * 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
  50454. * * 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
  50455. * * 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
  50456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50457. * * 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
  50458. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50459. * * 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
  50460. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50461. * * 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
  50462. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50464. * @param name defines the name of the mesh
  50465. * @param options defines the options used to create the mesh
  50466. * @param scene defines the hosting scene
  50467. * @returns the ribbon mesh
  50468. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50469. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50470. */
  50471. static CreateRibbon(name: string, options: {
  50472. pathArray: Vector3[][];
  50473. closeArray?: boolean;
  50474. closePath?: boolean;
  50475. offset?: number;
  50476. updatable?: boolean;
  50477. sideOrientation?: number;
  50478. frontUVs?: Vector4;
  50479. backUVs?: Vector4;
  50480. instance?: Mesh;
  50481. invertUV?: boolean;
  50482. uvs?: Vector2[];
  50483. colors?: Color4[];
  50484. }, scene?: Nullable<Scene>): Mesh;
  50485. /**
  50486. * Creates a cylinder or a cone mesh
  50487. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50488. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50489. * * 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.
  50490. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50491. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50492. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50493. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50494. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50495. * * 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).
  50496. * * 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
  50497. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50498. * * 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
  50499. * * 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.
  50500. * * If `enclose` is false, a ring surface is one element.
  50501. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50502. * * 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
  50503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50504. * * 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
  50505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50506. * @param name defines the name of the mesh
  50507. * @param options defines the options used to create the mesh
  50508. * @param scene defines the hosting scene
  50509. * @returns the cylinder mesh
  50510. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50511. */
  50512. static CreateCylinder(name: string, options: {
  50513. height?: number;
  50514. diameterTop?: number;
  50515. diameterBottom?: number;
  50516. diameter?: number;
  50517. tessellation?: number;
  50518. subdivisions?: number;
  50519. arc?: number;
  50520. faceColors?: Color4[];
  50521. faceUV?: Vector4[];
  50522. updatable?: boolean;
  50523. hasRings?: boolean;
  50524. enclose?: boolean;
  50525. sideOrientation?: number;
  50526. frontUVs?: Vector4;
  50527. backUVs?: Vector4;
  50528. }, scene?: Nullable<Scene>): Mesh;
  50529. /**
  50530. * Creates a torus mesh
  50531. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50532. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50533. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50535. * * 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
  50536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50537. * @param name defines the name of the mesh
  50538. * @param options defines the options used to create the mesh
  50539. * @param scene defines the hosting scene
  50540. * @returns the torus mesh
  50541. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50542. */
  50543. static CreateTorus(name: string, options: {
  50544. diameter?: number;
  50545. thickness?: number;
  50546. tessellation?: number;
  50547. updatable?: boolean;
  50548. sideOrientation?: number;
  50549. frontUVs?: Vector4;
  50550. backUVs?: Vector4;
  50551. }, scene?: Nullable<Scene>): Mesh;
  50552. /**
  50553. * Creates a torus knot mesh
  50554. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50555. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50556. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50557. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50558. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50559. * * 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
  50560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50561. * @param name defines the name of the mesh
  50562. * @param options defines the options used to create the mesh
  50563. * @param scene defines the hosting scene
  50564. * @returns the torus knot mesh
  50565. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50566. */
  50567. static CreateTorusKnot(name: string, options: {
  50568. radius?: number;
  50569. tube?: number;
  50570. radialSegments?: number;
  50571. tubularSegments?: number;
  50572. p?: number;
  50573. q?: number;
  50574. updatable?: boolean;
  50575. sideOrientation?: number;
  50576. frontUVs?: Vector4;
  50577. backUVs?: Vector4;
  50578. }, scene?: Nullable<Scene>): Mesh;
  50579. /**
  50580. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50581. * * 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
  50582. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50583. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50584. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50585. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50586. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50587. * * 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
  50588. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50590. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50591. * @param name defines the name of the new line system
  50592. * @param options defines the options used to create the line system
  50593. * @param scene defines the hosting scene
  50594. * @returns a new line system mesh
  50595. */
  50596. static CreateLineSystem(name: string, options: {
  50597. lines: Vector3[][];
  50598. updatable?: boolean;
  50599. instance?: Nullable<LinesMesh>;
  50600. colors?: Nullable<Color4[][]>;
  50601. useVertexAlpha?: boolean;
  50602. }, scene: Nullable<Scene>): LinesMesh;
  50603. /**
  50604. * Creates a line mesh
  50605. * 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
  50606. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50607. * * The parameter `points` is an array successive Vector3
  50608. * * 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
  50609. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50610. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50611. * * When updating an instance, remember that only point positions can change, not the number of points
  50612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50613. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50614. * @param name defines the name of the new line system
  50615. * @param options defines the options used to create the line system
  50616. * @param scene defines the hosting scene
  50617. * @returns a new line mesh
  50618. */
  50619. static CreateLines(name: string, options: {
  50620. points: Vector3[];
  50621. updatable?: boolean;
  50622. instance?: Nullable<LinesMesh>;
  50623. colors?: Color4[];
  50624. useVertexAlpha?: boolean;
  50625. }, scene?: Nullable<Scene>): LinesMesh;
  50626. /**
  50627. * Creates a dashed line mesh
  50628. * * 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
  50629. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50630. * * The parameter `points` is an array successive Vector3
  50631. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50632. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50633. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50634. * * 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
  50635. * * When updating an instance, remember that only point positions can change, not the number of points
  50636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50637. * @param name defines the name of the mesh
  50638. * @param options defines the options used to create the mesh
  50639. * @param scene defines the hosting scene
  50640. * @returns the dashed line mesh
  50641. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50642. */
  50643. static CreateDashedLines(name: string, options: {
  50644. points: Vector3[];
  50645. dashSize?: number;
  50646. gapSize?: number;
  50647. dashNb?: number;
  50648. updatable?: boolean;
  50649. instance?: LinesMesh;
  50650. }, scene?: Nullable<Scene>): LinesMesh;
  50651. /**
  50652. * 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.
  50653. * * 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.
  50654. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50655. * * 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.
  50656. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50657. * * 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
  50658. * * 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
  50659. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50661. * * 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
  50662. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50664. * @param name defines the name of the mesh
  50665. * @param options defines the options used to create the mesh
  50666. * @param scene defines the hosting scene
  50667. * @returns the extruded shape mesh
  50668. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50669. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50670. */
  50671. static ExtrudeShape(name: string, options: {
  50672. shape: Vector3[];
  50673. path: Vector3[];
  50674. scale?: number;
  50675. rotation?: number;
  50676. cap?: number;
  50677. updatable?: boolean;
  50678. sideOrientation?: number;
  50679. frontUVs?: Vector4;
  50680. backUVs?: Vector4;
  50681. instance?: Mesh;
  50682. invertUV?: boolean;
  50683. }, scene?: Nullable<Scene>): Mesh;
  50684. /**
  50685. * Creates an custom extruded shape mesh.
  50686. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50687. * * 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.
  50688. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50689. * * 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
  50690. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50691. * * 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
  50692. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50693. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50694. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50695. * * 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
  50696. * * 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
  50697. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50699. * * 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
  50700. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50702. * @param name defines the name of the mesh
  50703. * @param options defines the options used to create the mesh
  50704. * @param scene defines the hosting scene
  50705. * @returns the custom extruded shape mesh
  50706. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50707. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50708. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50709. */
  50710. static ExtrudeShapeCustom(name: string, options: {
  50711. shape: Vector3[];
  50712. path: Vector3[];
  50713. scaleFunction?: any;
  50714. rotationFunction?: any;
  50715. ribbonCloseArray?: boolean;
  50716. ribbonClosePath?: boolean;
  50717. cap?: number;
  50718. updatable?: boolean;
  50719. sideOrientation?: number;
  50720. frontUVs?: Vector4;
  50721. backUVs?: Vector4;
  50722. instance?: Mesh;
  50723. invertUV?: boolean;
  50724. }, scene?: Nullable<Scene>): Mesh;
  50725. /**
  50726. * Creates lathe mesh.
  50727. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50728. * * 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
  50729. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50730. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50731. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50732. * * 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
  50733. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50734. * * 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
  50735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50736. * * 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
  50737. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50739. * @param name defines the name of the mesh
  50740. * @param options defines the options used to create the mesh
  50741. * @param scene defines the hosting scene
  50742. * @returns the lathe mesh
  50743. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50744. */
  50745. static CreateLathe(name: string, options: {
  50746. shape: Vector3[];
  50747. radius?: number;
  50748. tessellation?: number;
  50749. clip?: number;
  50750. arc?: number;
  50751. closed?: boolean;
  50752. updatable?: boolean;
  50753. sideOrientation?: number;
  50754. frontUVs?: Vector4;
  50755. backUVs?: Vector4;
  50756. cap?: number;
  50757. invertUV?: boolean;
  50758. }, scene?: Nullable<Scene>): Mesh;
  50759. /**
  50760. * Creates a plane mesh
  50761. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50762. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50763. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50765. * * 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
  50766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50767. * @param name defines the name of the mesh
  50768. * @param options defines the options used to create the mesh
  50769. * @param scene defines the hosting scene
  50770. * @returns the plane mesh
  50771. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50772. */
  50773. static CreatePlane(name: string, options: {
  50774. size?: number;
  50775. width?: number;
  50776. height?: number;
  50777. sideOrientation?: number;
  50778. frontUVs?: Vector4;
  50779. backUVs?: Vector4;
  50780. updatable?: boolean;
  50781. sourcePlane?: Plane;
  50782. }, scene?: Nullable<Scene>): Mesh;
  50783. /**
  50784. * Creates a ground mesh
  50785. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50786. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50788. * @param name defines the name of the mesh
  50789. * @param options defines the options used to create the mesh
  50790. * @param scene defines the hosting scene
  50791. * @returns the ground mesh
  50792. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50793. */
  50794. static CreateGround(name: string, options: {
  50795. width?: number;
  50796. height?: number;
  50797. subdivisions?: number;
  50798. subdivisionsX?: number;
  50799. subdivisionsY?: number;
  50800. updatable?: boolean;
  50801. }, scene?: Nullable<Scene>): Mesh;
  50802. /**
  50803. * Creates a tiled ground mesh
  50804. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50805. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50806. * * 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
  50807. * * 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
  50808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50809. * @param name defines the name of the mesh
  50810. * @param options defines the options used to create the mesh
  50811. * @param scene defines the hosting scene
  50812. * @returns the tiled ground mesh
  50813. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50814. */
  50815. static CreateTiledGround(name: string, options: {
  50816. xmin: number;
  50817. zmin: number;
  50818. xmax: number;
  50819. zmax: number;
  50820. subdivisions?: {
  50821. w: number;
  50822. h: number;
  50823. };
  50824. precision?: {
  50825. w: number;
  50826. h: number;
  50827. };
  50828. updatable?: boolean;
  50829. }, scene?: Nullable<Scene>): Mesh;
  50830. /**
  50831. * Creates a ground mesh from a height map
  50832. * * The parameter `url` sets the URL of the height map image resource.
  50833. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50834. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50835. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50836. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50837. * * 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.
  50838. * * 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).
  50839. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50841. * @param name defines the name of the mesh
  50842. * @param url defines the url to the height map
  50843. * @param options defines the options used to create the mesh
  50844. * @param scene defines the hosting scene
  50845. * @returns the ground mesh
  50846. * @see https://doc.babylonjs.com/babylon101/height_map
  50847. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50848. */
  50849. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50850. width?: number;
  50851. height?: number;
  50852. subdivisions?: number;
  50853. minHeight?: number;
  50854. maxHeight?: number;
  50855. colorFilter?: Color3;
  50856. alphaFilter?: number;
  50857. updatable?: boolean;
  50858. onReady?: (mesh: GroundMesh) => void;
  50859. }, scene?: Nullable<Scene>): GroundMesh;
  50860. /**
  50861. * Creates a polygon mesh
  50862. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50863. * * 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
  50864. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50866. * * 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)
  50867. * * Remember you can only change the shape positions, not their number when updating a polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  50872. * @returns the polygon mesh
  50873. */
  50874. static CreatePolygon(name: string, options: {
  50875. shape: Vector3[];
  50876. holes?: Vector3[][];
  50877. depth?: number;
  50878. faceUV?: Vector4[];
  50879. faceColors?: Color4[];
  50880. updatable?: boolean;
  50881. sideOrientation?: number;
  50882. frontUVs?: Vector4;
  50883. backUVs?: Vector4;
  50884. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50885. /**
  50886. * Creates an extruded polygon mesh, with depth in the Y direction.
  50887. * * 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)
  50888. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50889. * @param name defines the name of the mesh
  50890. * @param options defines the options used to create the mesh
  50891. * @param scene defines the hosting scene
  50892. * @param earcutInjection can be used to inject your own earcut reference
  50893. * @returns the polygon mesh
  50894. */
  50895. static ExtrudePolygon(name: string, options: {
  50896. shape: Vector3[];
  50897. holes?: Vector3[][];
  50898. depth?: number;
  50899. faceUV?: Vector4[];
  50900. faceColors?: Color4[];
  50901. updatable?: boolean;
  50902. sideOrientation?: number;
  50903. frontUVs?: Vector4;
  50904. backUVs?: Vector4;
  50905. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50906. /**
  50907. * Creates a tube mesh.
  50908. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50909. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50910. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50911. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50912. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50913. * * 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)
  50914. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50915. * * 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
  50916. * * 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
  50917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50918. * * 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
  50919. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50921. * @param name defines the name of the mesh
  50922. * @param options defines the options used to create the mesh
  50923. * @param scene defines the hosting scene
  50924. * @returns the tube mesh
  50925. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50926. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50927. */
  50928. static CreateTube(name: string, options: {
  50929. path: Vector3[];
  50930. radius?: number;
  50931. tessellation?: number;
  50932. radiusFunction?: {
  50933. (i: number, distance: number): number;
  50934. };
  50935. cap?: number;
  50936. arc?: number;
  50937. updatable?: boolean;
  50938. sideOrientation?: number;
  50939. frontUVs?: Vector4;
  50940. backUVs?: Vector4;
  50941. instance?: Mesh;
  50942. invertUV?: boolean;
  50943. }, scene?: Nullable<Scene>): Mesh;
  50944. /**
  50945. * Creates a polyhedron mesh
  50946. * * 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
  50947. * * The parameter `size` (positive float, default 1) sets the polygon size
  50948. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50949. * * 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`
  50950. * * 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
  50951. * * 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)`)
  50952. * * 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
  50953. * * 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
  50954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50955. * * 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
  50956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50957. * @param name defines the name of the mesh
  50958. * @param options defines the options used to create the mesh
  50959. * @param scene defines the hosting scene
  50960. * @returns the polyhedron mesh
  50961. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50962. */
  50963. static CreatePolyhedron(name: string, options: {
  50964. type?: number;
  50965. size?: number;
  50966. sizeX?: number;
  50967. sizeY?: number;
  50968. sizeZ?: number;
  50969. custom?: any;
  50970. faceUV?: Vector4[];
  50971. faceColors?: Color4[];
  50972. flat?: boolean;
  50973. updatable?: boolean;
  50974. sideOrientation?: number;
  50975. frontUVs?: Vector4;
  50976. backUVs?: Vector4;
  50977. }, scene?: Nullable<Scene>): Mesh;
  50978. /**
  50979. * Creates a decal mesh.
  50980. * 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
  50981. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50982. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50983. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50984. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50985. * @param name defines the name of the mesh
  50986. * @param sourceMesh defines the mesh where the decal must be applied
  50987. * @param options defines the options used to create the mesh
  50988. * @param scene defines the hosting scene
  50989. * @returns the decal mesh
  50990. * @see https://doc.babylonjs.com/how_to/decals
  50991. */
  50992. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50993. position?: Vector3;
  50994. normal?: Vector3;
  50995. size?: Vector3;
  50996. angle?: number;
  50997. }): Mesh;
  50998. }
  50999. }
  51000. declare module BABYLON {
  51001. /**
  51002. * A simplifier interface for future simplification implementations
  51003. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51004. */
  51005. export interface ISimplifier {
  51006. /**
  51007. * Simplification of a given mesh according to the given settings.
  51008. * Since this requires computation, it is assumed that the function runs async.
  51009. * @param settings The settings of the simplification, including quality and distance
  51010. * @param successCallback A callback that will be called after the mesh was simplified.
  51011. * @param errorCallback in case of an error, this callback will be called. optional.
  51012. */
  51013. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51014. }
  51015. /**
  51016. * Expected simplification settings.
  51017. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51018. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51019. */
  51020. export interface ISimplificationSettings {
  51021. /**
  51022. * Gets or sets the expected quality
  51023. */
  51024. quality: number;
  51025. /**
  51026. * Gets or sets the distance when this optimized version should be used
  51027. */
  51028. distance: number;
  51029. /**
  51030. * Gets an already optimized mesh
  51031. */
  51032. optimizeMesh?: boolean;
  51033. }
  51034. /**
  51035. * Class used to specify simplification options
  51036. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51037. */
  51038. export class SimplificationSettings implements ISimplificationSettings {
  51039. /** expected quality */
  51040. quality: number;
  51041. /** distance when this optimized version should be used */
  51042. distance: number;
  51043. /** already optimized mesh */
  51044. optimizeMesh?: boolean | undefined;
  51045. /**
  51046. * Creates a SimplificationSettings
  51047. * @param quality expected quality
  51048. * @param distance distance when this optimized version should be used
  51049. * @param optimizeMesh already optimized mesh
  51050. */
  51051. constructor(
  51052. /** expected quality */
  51053. quality: number,
  51054. /** distance when this optimized version should be used */
  51055. distance: number,
  51056. /** already optimized mesh */
  51057. optimizeMesh?: boolean | undefined);
  51058. }
  51059. /**
  51060. * Interface used to define a simplification task
  51061. */
  51062. export interface ISimplificationTask {
  51063. /**
  51064. * Array of settings
  51065. */
  51066. settings: Array<ISimplificationSettings>;
  51067. /**
  51068. * Simplification type
  51069. */
  51070. simplificationType: SimplificationType;
  51071. /**
  51072. * Mesh to simplify
  51073. */
  51074. mesh: Mesh;
  51075. /**
  51076. * Callback called on success
  51077. */
  51078. successCallback?: () => void;
  51079. /**
  51080. * Defines if parallel processing can be used
  51081. */
  51082. parallelProcessing: boolean;
  51083. }
  51084. /**
  51085. * Queue used to order the simplification tasks
  51086. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51087. */
  51088. export class SimplificationQueue {
  51089. private _simplificationArray;
  51090. /**
  51091. * Gets a boolean indicating that the process is still running
  51092. */
  51093. running: boolean;
  51094. /**
  51095. * Creates a new queue
  51096. */
  51097. constructor();
  51098. /**
  51099. * Adds a new simplification task
  51100. * @param task defines a task to add
  51101. */
  51102. addTask(task: ISimplificationTask): void;
  51103. /**
  51104. * Execute next task
  51105. */
  51106. executeNext(): void;
  51107. /**
  51108. * Execute a simplification task
  51109. * @param task defines the task to run
  51110. */
  51111. runSimplification(task: ISimplificationTask): void;
  51112. private getSimplifier;
  51113. }
  51114. /**
  51115. * The implemented types of simplification
  51116. * At the moment only Quadratic Error Decimation is implemented
  51117. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51118. */
  51119. export enum SimplificationType {
  51120. /** Quadratic error decimation */
  51121. QUADRATIC = 0
  51122. }
  51123. }
  51124. declare module BABYLON {
  51125. interface Scene {
  51126. /** @hidden (Backing field) */
  51127. _simplificationQueue: SimplificationQueue;
  51128. /**
  51129. * Gets or sets the simplification queue attached to the scene
  51130. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51131. */
  51132. simplificationQueue: SimplificationQueue;
  51133. }
  51134. interface Mesh {
  51135. /**
  51136. * Simplify the mesh according to the given array of settings.
  51137. * Function will return immediately and will simplify async
  51138. * @param settings a collection of simplification settings
  51139. * @param parallelProcessing should all levels calculate parallel or one after the other
  51140. * @param simplificationType the type of simplification to run
  51141. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51142. * @returns the current mesh
  51143. */
  51144. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51145. }
  51146. /**
  51147. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51148. * created in a scene
  51149. */
  51150. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51151. /**
  51152. * The component name helpfull to identify the component in the list of scene components.
  51153. */
  51154. readonly name: string;
  51155. /**
  51156. * The scene the component belongs to.
  51157. */
  51158. scene: Scene;
  51159. /**
  51160. * Creates a new instance of the component for the given scene
  51161. * @param scene Defines the scene to register the component in
  51162. */
  51163. constructor(scene: Scene);
  51164. /**
  51165. * Registers the component in a given scene
  51166. */
  51167. register(): void;
  51168. /**
  51169. * Rebuilds the elements related to this component in case of
  51170. * context lost for instance.
  51171. */
  51172. rebuild(): void;
  51173. /**
  51174. * Disposes the component and the associated ressources
  51175. */
  51176. dispose(): void;
  51177. private _beforeCameraUpdate;
  51178. }
  51179. }
  51180. declare module BABYLON {
  51181. /**
  51182. * Class used to enable access to IndexedDB
  51183. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51184. */
  51185. export class Database implements IOfflineProvider {
  51186. private _callbackManifestChecked;
  51187. private _currentSceneUrl;
  51188. private _db;
  51189. private _enableSceneOffline;
  51190. private _enableTexturesOffline;
  51191. private _manifestVersionFound;
  51192. private _mustUpdateRessources;
  51193. private _hasReachedQuota;
  51194. private _isSupported;
  51195. private _idbFactory;
  51196. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51197. private static IsUASupportingBlobStorage;
  51198. /**
  51199. * Gets a boolean indicating if Database storate is enabled (off by default)
  51200. */
  51201. static IDBStorageEnabled: boolean;
  51202. /**
  51203. * Gets a boolean indicating if scene must be saved in the database
  51204. */
  51205. readonly enableSceneOffline: boolean;
  51206. /**
  51207. * Gets a boolean indicating if textures must be saved in the database
  51208. */
  51209. readonly enableTexturesOffline: boolean;
  51210. /**
  51211. * Creates a new Database
  51212. * @param urlToScene defines the url to load the scene
  51213. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51214. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51215. */
  51216. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51217. private static _ParseURL;
  51218. private static _ReturnFullUrlLocation;
  51219. private _checkManifestFile;
  51220. /**
  51221. * Open the database and make it available
  51222. * @param successCallback defines the callback to call on success
  51223. * @param errorCallback defines the callback to call on error
  51224. */
  51225. open(successCallback: () => void, errorCallback: () => void): void;
  51226. /**
  51227. * Loads an image from the database
  51228. * @param url defines the url to load from
  51229. * @param image defines the target DOM image
  51230. */
  51231. loadImage(url: string, image: HTMLImageElement): void;
  51232. private _loadImageFromDBAsync;
  51233. private _saveImageIntoDBAsync;
  51234. private _checkVersionFromDB;
  51235. private _loadVersionFromDBAsync;
  51236. private _saveVersionIntoDBAsync;
  51237. /**
  51238. * Loads a file from database
  51239. * @param url defines the URL to load from
  51240. * @param sceneLoaded defines a callback to call on success
  51241. * @param progressCallBack defines a callback to call when progress changed
  51242. * @param errorCallback defines a callback to call on error
  51243. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51244. */
  51245. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51246. private _loadFileAsync;
  51247. private _saveFileAsync;
  51248. /**
  51249. * Validates if xhr data is correct
  51250. * @param xhr defines the request to validate
  51251. * @param dataType defines the expected data type
  51252. * @returns true if data is correct
  51253. */
  51254. private static _ValidateXHRData;
  51255. }
  51256. }
  51257. declare module BABYLON {
  51258. /** @hidden */
  51259. export var gpuUpdateParticlesPixelShader: {
  51260. name: string;
  51261. shader: string;
  51262. };
  51263. }
  51264. declare module BABYLON {
  51265. /** @hidden */
  51266. export var gpuUpdateParticlesVertexShader: {
  51267. name: string;
  51268. shader: string;
  51269. };
  51270. }
  51271. declare module BABYLON {
  51272. /** @hidden */
  51273. export var clipPlaneFragmentDeclaration2: {
  51274. name: string;
  51275. shader: string;
  51276. };
  51277. }
  51278. declare module BABYLON {
  51279. /** @hidden */
  51280. export var gpuRenderParticlesPixelShader: {
  51281. name: string;
  51282. shader: string;
  51283. };
  51284. }
  51285. declare module BABYLON {
  51286. /** @hidden */
  51287. export var clipPlaneVertexDeclaration2: {
  51288. name: string;
  51289. shader: string;
  51290. };
  51291. }
  51292. declare module BABYLON {
  51293. /** @hidden */
  51294. export var gpuRenderParticlesVertexShader: {
  51295. name: string;
  51296. shader: string;
  51297. };
  51298. }
  51299. declare module BABYLON {
  51300. /**
  51301. * This represents a GPU particle system in Babylon
  51302. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51303. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51304. */
  51305. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51306. /**
  51307. * The layer mask we are rendering the particles through.
  51308. */
  51309. layerMask: number;
  51310. private _capacity;
  51311. private _activeCount;
  51312. private _currentActiveCount;
  51313. private _accumulatedCount;
  51314. private _renderEffect;
  51315. private _updateEffect;
  51316. private _buffer0;
  51317. private _buffer1;
  51318. private _spriteBuffer;
  51319. private _updateVAO;
  51320. private _renderVAO;
  51321. private _targetIndex;
  51322. private _sourceBuffer;
  51323. private _targetBuffer;
  51324. private _engine;
  51325. private _currentRenderId;
  51326. private _started;
  51327. private _stopped;
  51328. private _timeDelta;
  51329. private _randomTexture;
  51330. private _randomTexture2;
  51331. private _attributesStrideSize;
  51332. private _updateEffectOptions;
  51333. private _randomTextureSize;
  51334. private _actualFrame;
  51335. private readonly _rawTextureWidth;
  51336. /**
  51337. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51338. */
  51339. static readonly IsSupported: boolean;
  51340. /**
  51341. * An event triggered when the system is disposed.
  51342. */
  51343. onDisposeObservable: Observable<GPUParticleSystem>;
  51344. /**
  51345. * Gets the maximum number of particles active at the same time.
  51346. * @returns The max number of active particles.
  51347. */
  51348. getCapacity(): number;
  51349. /**
  51350. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51351. * to override the particles.
  51352. */
  51353. forceDepthWrite: boolean;
  51354. /**
  51355. * Gets or set the number of active particles
  51356. */
  51357. activeParticleCount: number;
  51358. private _preWarmDone;
  51359. /**
  51360. * Is this system ready to be used/rendered
  51361. * @return true if the system is ready
  51362. */
  51363. isReady(): boolean;
  51364. /**
  51365. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51366. * @returns True if it has been started, otherwise false.
  51367. */
  51368. isStarted(): boolean;
  51369. /**
  51370. * Starts the particle system and begins to emit
  51371. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51372. */
  51373. start(delay?: number): void;
  51374. /**
  51375. * Stops the particle system.
  51376. */
  51377. stop(): void;
  51378. /**
  51379. * Remove all active particles
  51380. */
  51381. reset(): void;
  51382. /**
  51383. * Returns the string "GPUParticleSystem"
  51384. * @returns a string containing the class name
  51385. */
  51386. getClassName(): string;
  51387. private _colorGradientsTexture;
  51388. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51389. /**
  51390. * Adds a new color gradient
  51391. * @param gradient defines the gradient to use (between 0 and 1)
  51392. * @param color1 defines the color to affect to the specified gradient
  51393. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51394. * @returns the current particle system
  51395. */
  51396. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51397. /**
  51398. * Remove a specific color gradient
  51399. * @param gradient defines the gradient to remove
  51400. * @returns the current particle system
  51401. */
  51402. removeColorGradient(gradient: number): GPUParticleSystem;
  51403. private _angularSpeedGradientsTexture;
  51404. private _sizeGradientsTexture;
  51405. private _velocityGradientsTexture;
  51406. private _limitVelocityGradientsTexture;
  51407. private _dragGradientsTexture;
  51408. private _addFactorGradient;
  51409. /**
  51410. * Adds a new size gradient
  51411. * @param gradient defines the gradient to use (between 0 and 1)
  51412. * @param factor defines the size factor to affect to the specified gradient
  51413. * @returns the current particle system
  51414. */
  51415. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51416. /**
  51417. * Remove a specific size gradient
  51418. * @param gradient defines the gradient to remove
  51419. * @returns the current particle system
  51420. */
  51421. removeSizeGradient(gradient: number): GPUParticleSystem;
  51422. /**
  51423. * Adds a new angular speed gradient
  51424. * @param gradient defines the gradient to use (between 0 and 1)
  51425. * @param factor defines the angular speed to affect to the specified gradient
  51426. * @returns the current particle system
  51427. */
  51428. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51429. /**
  51430. * Remove a specific angular speed gradient
  51431. * @param gradient defines the gradient to remove
  51432. * @returns the current particle system
  51433. */
  51434. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51435. /**
  51436. * Adds a new velocity gradient
  51437. * @param gradient defines the gradient to use (between 0 and 1)
  51438. * @param factor defines the velocity to affect to the specified gradient
  51439. * @returns the current particle system
  51440. */
  51441. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51442. /**
  51443. * Remove a specific velocity gradient
  51444. * @param gradient defines the gradient to remove
  51445. * @returns the current particle system
  51446. */
  51447. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51448. /**
  51449. * Adds a new limit velocity gradient
  51450. * @param gradient defines the gradient to use (between 0 and 1)
  51451. * @param factor defines the limit velocity value to affect to the specified gradient
  51452. * @returns the current particle system
  51453. */
  51454. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51455. /**
  51456. * Remove a specific limit velocity gradient
  51457. * @param gradient defines the gradient to remove
  51458. * @returns the current particle system
  51459. */
  51460. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51461. /**
  51462. * Adds a new drag gradient
  51463. * @param gradient defines the gradient to use (between 0 and 1)
  51464. * @param factor defines the drag value to affect to the specified gradient
  51465. * @returns the current particle system
  51466. */
  51467. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51468. /**
  51469. * Remove a specific drag gradient
  51470. * @param gradient defines the gradient to remove
  51471. * @returns the current particle system
  51472. */
  51473. removeDragGradient(gradient: number): GPUParticleSystem;
  51474. /**
  51475. * Not supported by GPUParticleSystem
  51476. * @param gradient defines the gradient to use (between 0 and 1)
  51477. * @param factor defines the emit rate value to affect to the specified gradient
  51478. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51479. * @returns the current particle system
  51480. */
  51481. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51482. /**
  51483. * Not supported by GPUParticleSystem
  51484. * @param gradient defines the gradient to remove
  51485. * @returns the current particle system
  51486. */
  51487. removeEmitRateGradient(gradient: number): IParticleSystem;
  51488. /**
  51489. * Not supported by GPUParticleSystem
  51490. * @param gradient defines the gradient to use (between 0 and 1)
  51491. * @param factor defines the start size value to affect to the specified gradient
  51492. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51493. * @returns the current particle system
  51494. */
  51495. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51496. /**
  51497. * Not supported by GPUParticleSystem
  51498. * @param gradient defines the gradient to remove
  51499. * @returns the current particle system
  51500. */
  51501. removeStartSizeGradient(gradient: number): IParticleSystem;
  51502. /**
  51503. * Not supported by GPUParticleSystem
  51504. * @param gradient defines the gradient to use (between 0 and 1)
  51505. * @param min defines the color remap minimal range
  51506. * @param max defines the color remap maximal range
  51507. * @returns the current particle system
  51508. */
  51509. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51510. /**
  51511. * Not supported by GPUParticleSystem
  51512. * @param gradient defines the gradient to remove
  51513. * @returns the current particle system
  51514. */
  51515. removeColorRemapGradient(): IParticleSystem;
  51516. /**
  51517. * Not supported by GPUParticleSystem
  51518. * @param gradient defines the gradient to use (between 0 and 1)
  51519. * @param min defines the alpha remap minimal range
  51520. * @param max defines the alpha remap maximal range
  51521. * @returns the current particle system
  51522. */
  51523. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51524. /**
  51525. * Not supported by GPUParticleSystem
  51526. * @param gradient defines the gradient to remove
  51527. * @returns the current particle system
  51528. */
  51529. removeAlphaRemapGradient(): IParticleSystem;
  51530. /**
  51531. * Not supported by GPUParticleSystem
  51532. * @param gradient defines the gradient to use (between 0 and 1)
  51533. * @param color defines the color to affect to the specified gradient
  51534. * @returns the current particle system
  51535. */
  51536. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51537. /**
  51538. * Not supported by GPUParticleSystem
  51539. * @param gradient defines the gradient to remove
  51540. * @returns the current particle system
  51541. */
  51542. removeRampGradient(): IParticleSystem;
  51543. /**
  51544. * Not supported by GPUParticleSystem
  51545. * @returns the list of ramp gradients
  51546. */
  51547. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51548. /**
  51549. * Not supported by GPUParticleSystem
  51550. * Gets or sets a boolean indicating that ramp gradients must be used
  51551. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51552. */
  51553. useRampGradients: boolean;
  51554. /**
  51555. * Not supported by GPUParticleSystem
  51556. * @param gradient defines the gradient to use (between 0 and 1)
  51557. * @param factor defines the life time factor to affect to the specified gradient
  51558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51559. * @returns the current particle system
  51560. */
  51561. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51562. /**
  51563. * Not supported by GPUParticleSystem
  51564. * @param gradient defines the gradient to remove
  51565. * @returns the current particle system
  51566. */
  51567. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51568. /**
  51569. * Instantiates a GPU particle system.
  51570. * 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.
  51571. * @param name The name of the particle system
  51572. * @param options The options used to create the system
  51573. * @param scene The scene the particle system belongs to
  51574. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51575. */
  51576. constructor(name: string, options: Partial<{
  51577. capacity: number;
  51578. randomTextureSize: number;
  51579. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51580. protected _reset(): void;
  51581. private _createUpdateVAO;
  51582. private _createRenderVAO;
  51583. private _initialize;
  51584. /** @hidden */
  51585. _recreateUpdateEffect(): void;
  51586. /** @hidden */
  51587. _recreateRenderEffect(): void;
  51588. /**
  51589. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51590. * @param preWarm defines if we are in the pre-warmimg phase
  51591. */
  51592. animate(preWarm?: boolean): void;
  51593. private _createFactorGradientTexture;
  51594. private _createSizeGradientTexture;
  51595. private _createAngularSpeedGradientTexture;
  51596. private _createVelocityGradientTexture;
  51597. private _createLimitVelocityGradientTexture;
  51598. private _createDragGradientTexture;
  51599. private _createColorGradientTexture;
  51600. /**
  51601. * Renders the particle system in its current state
  51602. * @param preWarm defines if the system should only update the particles but not render them
  51603. * @returns the current number of particles
  51604. */
  51605. render(preWarm?: boolean): number;
  51606. /**
  51607. * Rebuilds the particle system
  51608. */
  51609. rebuild(): void;
  51610. private _releaseBuffers;
  51611. private _releaseVAOs;
  51612. /**
  51613. * Disposes the particle system and free the associated resources
  51614. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51615. */
  51616. dispose(disposeTexture?: boolean): void;
  51617. /**
  51618. * Clones the particle system.
  51619. * @param name The name of the cloned object
  51620. * @param newEmitter The new emitter to use
  51621. * @returns the cloned particle system
  51622. */
  51623. clone(name: string, newEmitter: any): GPUParticleSystem;
  51624. /**
  51625. * Serializes the particle system to a JSON object.
  51626. * @returns the JSON object
  51627. */
  51628. serialize(): any;
  51629. /**
  51630. * Parses a JSON object to create a GPU particle system.
  51631. * @param parsedParticleSystem The JSON object to parse
  51632. * @param scene The scene to create the particle system in
  51633. * @param rootUrl The root url to use to load external dependencies like texture
  51634. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51635. * @returns the parsed GPU particle system
  51636. */
  51637. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51638. }
  51639. }
  51640. declare module BABYLON {
  51641. /**
  51642. * Represents a set of particle systems working together to create a specific effect
  51643. */
  51644. export class ParticleSystemSet implements IDisposable {
  51645. private _emitterCreationOptions;
  51646. private _emitterNode;
  51647. /**
  51648. * Gets the particle system list
  51649. */
  51650. systems: IParticleSystem[];
  51651. /**
  51652. * Gets the emitter node used with this set
  51653. */
  51654. readonly emitterNode: Nullable<TransformNode>;
  51655. /**
  51656. * Creates a new emitter mesh as a sphere
  51657. * @param options defines the options used to create the sphere
  51658. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51659. * @param scene defines the hosting scene
  51660. */
  51661. setEmitterAsSphere(options: {
  51662. diameter: number;
  51663. segments: number;
  51664. color: Color3;
  51665. }, renderingGroupId: number, scene: Scene): void;
  51666. /**
  51667. * Starts all particle systems of the set
  51668. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51669. */
  51670. start(emitter?: AbstractMesh): void;
  51671. /**
  51672. * Release all associated resources
  51673. */
  51674. dispose(): void;
  51675. /**
  51676. * Serialize the set into a JSON compatible object
  51677. * @returns a JSON compatible representation of the set
  51678. */
  51679. serialize(): any;
  51680. /**
  51681. * Parse a new ParticleSystemSet from a serialized source
  51682. * @param data defines a JSON compatible representation of the set
  51683. * @param scene defines the hosting scene
  51684. * @param gpu defines if we want GPU particles or CPU particles
  51685. * @returns a new ParticleSystemSet
  51686. */
  51687. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  51688. }
  51689. }
  51690. declare module BABYLON {
  51691. /**
  51692. * This class is made for on one-liner static method to help creating particle system set.
  51693. */
  51694. export class ParticleHelper {
  51695. /**
  51696. * Gets or sets base Assets URL
  51697. */
  51698. static BaseAssetsUrl: string;
  51699. /**
  51700. * Create a default particle system that you can tweak
  51701. * @param emitter defines the emitter to use
  51702. * @param capacity defines the system capacity (default is 500 particles)
  51703. * @param scene defines the hosting scene
  51704. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  51705. * @returns the new Particle system
  51706. */
  51707. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  51708. /**
  51709. * This is the main static method (one-liner) of this helper to create different particle systems
  51710. * @param type This string represents the type to the particle system to create
  51711. * @param scene The scene where the particle system should live
  51712. * @param gpu If the system will use gpu
  51713. * @returns the ParticleSystemSet created
  51714. */
  51715. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  51716. /**
  51717. * Static function used to export a particle system to a ParticleSystemSet variable.
  51718. * Please note that the emitter shape is not exported
  51719. * @param systems defines the particle systems to export
  51720. * @returns the created particle system set
  51721. */
  51722. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  51723. }
  51724. }
  51725. declare module BABYLON {
  51726. interface Engine {
  51727. /**
  51728. * Create an effect to use with particle systems.
  51729. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  51730. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  51731. * @param uniformsNames defines a list of attribute names
  51732. * @param samplers defines an array of string used to represent textures
  51733. * @param defines defines the string containing the defines to use to compile the shaders
  51734. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  51735. * @param onCompiled defines a function to call when the effect creation is successful
  51736. * @param onError defines a function to call when the effect creation has failed
  51737. * @returns the new Effect
  51738. */
  51739. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  51740. }
  51741. interface Mesh {
  51742. /**
  51743. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  51744. * @returns an array of IParticleSystem
  51745. */
  51746. getEmittedParticleSystems(): IParticleSystem[];
  51747. /**
  51748. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51749. * @returns an array of IParticleSystem
  51750. */
  51751. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51752. }
  51753. /**
  51754. * @hidden
  51755. */
  51756. export var _IDoNeedToBeInTheBuild: number;
  51757. }
  51758. declare module BABYLON {
  51759. interface Scene {
  51760. /** @hidden (Backing field) */
  51761. _physicsEngine: Nullable<IPhysicsEngine>;
  51762. /**
  51763. * Gets the current physics engine
  51764. * @returns a IPhysicsEngine or null if none attached
  51765. */
  51766. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51767. /**
  51768. * Enables physics to the current scene
  51769. * @param gravity defines the scene's gravity for the physics engine
  51770. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51771. * @return a boolean indicating if the physics engine was initialized
  51772. */
  51773. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51774. /**
  51775. * Disables and disposes the physics engine associated with the scene
  51776. */
  51777. disablePhysicsEngine(): void;
  51778. /**
  51779. * Gets a boolean indicating if there is an active physics engine
  51780. * @returns a boolean indicating if there is an active physics engine
  51781. */
  51782. isPhysicsEnabled(): boolean;
  51783. /**
  51784. * Deletes a physics compound impostor
  51785. * @param compound defines the compound to delete
  51786. */
  51787. deleteCompoundImpostor(compound: any): void;
  51788. /**
  51789. * An event triggered when physic simulation is about to be run
  51790. */
  51791. onBeforePhysicsObservable: Observable<Scene>;
  51792. /**
  51793. * An event triggered when physic simulation has been done
  51794. */
  51795. onAfterPhysicsObservable: Observable<Scene>;
  51796. }
  51797. interface AbstractMesh {
  51798. /** @hidden */
  51799. _physicsImpostor: Nullable<PhysicsImpostor>;
  51800. /**
  51801. * Gets or sets impostor used for physic simulation
  51802. * @see http://doc.babylonjs.com/features/physics_engine
  51803. */
  51804. physicsImpostor: Nullable<PhysicsImpostor>;
  51805. /**
  51806. * Gets the current physics impostor
  51807. * @see http://doc.babylonjs.com/features/physics_engine
  51808. * @returns a physics impostor or null
  51809. */
  51810. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51811. /** Apply a physic impulse to the mesh
  51812. * @param force defines the force to apply
  51813. * @param contactPoint defines where to apply the force
  51814. * @returns the current mesh
  51815. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51816. */
  51817. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51818. /**
  51819. * Creates a physic joint between two meshes
  51820. * @param otherMesh defines the other mesh to use
  51821. * @param pivot1 defines the pivot to use on this mesh
  51822. * @param pivot2 defines the pivot to use on the other mesh
  51823. * @param options defines additional options (can be plugin dependent)
  51824. * @returns the current mesh
  51825. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51826. */
  51827. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51828. /** @hidden */
  51829. _disposePhysicsObserver: Nullable<Observer<Node>>;
  51830. }
  51831. /**
  51832. * Defines the physics engine scene component responsible to manage a physics engine
  51833. */
  51834. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51835. /**
  51836. * The component name helpful to identify the component in the list of scene components.
  51837. */
  51838. readonly name: string;
  51839. /**
  51840. * The scene the component belongs to.
  51841. */
  51842. scene: Scene;
  51843. /**
  51844. * Creates a new instance of the component for the given scene
  51845. * @param scene Defines the scene to register the component in
  51846. */
  51847. constructor(scene: Scene);
  51848. /**
  51849. * Registers the component in a given scene
  51850. */
  51851. register(): void;
  51852. /**
  51853. * Rebuilds the elements related to this component in case of
  51854. * context lost for instance.
  51855. */
  51856. rebuild(): void;
  51857. /**
  51858. * Disposes the component and the associated ressources
  51859. */
  51860. dispose(): void;
  51861. }
  51862. }
  51863. declare module BABYLON {
  51864. /**
  51865. * A helper for physics simulations
  51866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51867. */
  51868. export class PhysicsHelper {
  51869. private _scene;
  51870. private _physicsEngine;
  51871. /**
  51872. * Initializes the Physics helper
  51873. * @param scene Babylon.js scene
  51874. */
  51875. constructor(scene: Scene);
  51876. /**
  51877. * Applies a radial explosion impulse
  51878. * @param origin the origin of the explosion
  51879. * @param radiusOrEventOptions the radius or the options of radial explosion
  51880. * @param strength the explosion strength
  51881. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51882. * @returns A physics radial explosion event, or null
  51883. */
  51884. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51885. /**
  51886. * Applies a radial explosion force
  51887. * @param origin the origin of the explosion
  51888. * @param radiusOrEventOptions the radius or the options of radial explosion
  51889. * @param strength the explosion strength
  51890. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51891. * @returns A physics radial explosion event, or null
  51892. */
  51893. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51894. /**
  51895. * Creates a gravitational field
  51896. * @param origin the origin of the explosion
  51897. * @param radiusOrEventOptions the radius or the options of radial explosion
  51898. * @param strength the explosion strength
  51899. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51900. * @returns A physics gravitational field event, or null
  51901. */
  51902. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51903. /**
  51904. * Creates a physics updraft event
  51905. * @param origin the origin of the updraft
  51906. * @param radiusOrEventOptions the radius or the options of the updraft
  51907. * @param strength the strength of the updraft
  51908. * @param height the height of the updraft
  51909. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51910. * @returns A physics updraft event, or null
  51911. */
  51912. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51913. /**
  51914. * Creates a physics vortex event
  51915. * @param origin the of the vortex
  51916. * @param radiusOrEventOptions the radius or the options of the vortex
  51917. * @param strength the strength of the vortex
  51918. * @param height the height of the vortex
  51919. * @returns a Physics vortex event, or null
  51920. * A physics vortex event or null
  51921. */
  51922. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  51923. }
  51924. /**
  51925. * Represents a physics radial explosion event
  51926. */
  51927. class PhysicsRadialExplosionEvent {
  51928. private _scene;
  51929. private _options;
  51930. private _sphere;
  51931. private _dataFetched;
  51932. /**
  51933. * Initializes a radial explosioin event
  51934. * @param _scene BabylonJS scene
  51935. * @param _options The options for the vortex event
  51936. */
  51937. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  51938. /**
  51939. * Returns the data related to the radial explosion event (sphere).
  51940. * @returns The radial explosion event data
  51941. */
  51942. getData(): PhysicsRadialExplosionEventData;
  51943. /**
  51944. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51945. * @param impostor A physics imposter
  51946. * @param origin the origin of the explosion
  51947. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  51948. */
  51949. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  51950. /**
  51951. * Triggers affecterd impostors callbacks
  51952. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  51953. */
  51954. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  51955. /**
  51956. * Disposes the sphere.
  51957. * @param force Specifies if the sphere should be disposed by force
  51958. */
  51959. dispose(force?: boolean): void;
  51960. /*** Helpers ***/
  51961. private _prepareSphere;
  51962. private _intersectsWithSphere;
  51963. }
  51964. /**
  51965. * Represents a gravitational field event
  51966. */
  51967. class PhysicsGravitationalFieldEvent {
  51968. private _physicsHelper;
  51969. private _scene;
  51970. private _origin;
  51971. private _options;
  51972. private _tickCallback;
  51973. private _sphere;
  51974. private _dataFetched;
  51975. /**
  51976. * Initializes the physics gravitational field event
  51977. * @param _physicsHelper A physics helper
  51978. * @param _scene BabylonJS scene
  51979. * @param _origin The origin position of the gravitational field event
  51980. * @param _options The options for the vortex event
  51981. */
  51982. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  51983. /**
  51984. * Returns the data related to the gravitational field event (sphere).
  51985. * @returns A gravitational field event
  51986. */
  51987. getData(): PhysicsGravitationalFieldEventData;
  51988. /**
  51989. * Enables the gravitational field.
  51990. */
  51991. enable(): void;
  51992. /**
  51993. * Disables the gravitational field.
  51994. */
  51995. disable(): void;
  51996. /**
  51997. * Disposes the sphere.
  51998. * @param force The force to dispose from the gravitational field event
  51999. */
  52000. dispose(force?: boolean): void;
  52001. private _tick;
  52002. }
  52003. /**
  52004. * Represents a physics updraft event
  52005. */
  52006. class PhysicsUpdraftEvent {
  52007. private _scene;
  52008. private _origin;
  52009. private _options;
  52010. private _physicsEngine;
  52011. private _originTop;
  52012. private _originDirection;
  52013. private _tickCallback;
  52014. private _cylinder;
  52015. private _cylinderPosition;
  52016. private _dataFetched;
  52017. /**
  52018. * Initializes the physics updraft event
  52019. * @param _scene BabylonJS scene
  52020. * @param _origin The origin position of the updraft
  52021. * @param _options The options for the updraft event
  52022. */
  52023. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  52024. /**
  52025. * Returns the data related to the updraft event (cylinder).
  52026. * @returns A physics updraft event
  52027. */
  52028. getData(): PhysicsUpdraftEventData;
  52029. /**
  52030. * Enables the updraft.
  52031. */
  52032. enable(): void;
  52033. /**
  52034. * Disables the updraft.
  52035. */
  52036. disable(): void;
  52037. /**
  52038. * Disposes the cylinder.
  52039. * @param force Specifies if the updraft should be disposed by force
  52040. */
  52041. dispose(force?: boolean): void;
  52042. private getImpostorHitData;
  52043. private _tick;
  52044. /*** Helpers ***/
  52045. private _prepareCylinder;
  52046. private _intersectsWithCylinder;
  52047. }
  52048. /**
  52049. * Represents a physics vortex event
  52050. */
  52051. class PhysicsVortexEvent {
  52052. private _scene;
  52053. private _origin;
  52054. private _options;
  52055. private _physicsEngine;
  52056. private _originTop;
  52057. private _tickCallback;
  52058. private _cylinder;
  52059. private _cylinderPosition;
  52060. private _dataFetched;
  52061. /**
  52062. * Initializes the physics vortex event
  52063. * @param _scene The BabylonJS scene
  52064. * @param _origin The origin position of the vortex
  52065. * @param _options The options for the vortex event
  52066. */
  52067. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  52068. /**
  52069. * Returns the data related to the vortex event (cylinder).
  52070. * @returns The physics vortex event data
  52071. */
  52072. getData(): PhysicsVortexEventData;
  52073. /**
  52074. * Enables the vortex.
  52075. */
  52076. enable(): void;
  52077. /**
  52078. * Disables the cortex.
  52079. */
  52080. disable(): void;
  52081. /**
  52082. * Disposes the sphere.
  52083. * @param force
  52084. */
  52085. dispose(force?: boolean): void;
  52086. private getImpostorHitData;
  52087. private _tick;
  52088. /*** Helpers ***/
  52089. private _prepareCylinder;
  52090. private _intersectsWithCylinder;
  52091. }
  52092. /**
  52093. * Options fot the radial explosion event
  52094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52095. */
  52096. export class PhysicsRadialExplosionEventOptions {
  52097. /**
  52098. * The radius of the sphere for the radial explosion.
  52099. */
  52100. radius: number;
  52101. /**
  52102. * The strenth of the explosion.
  52103. */
  52104. strength: number;
  52105. /**
  52106. * The strenght of the force in correspondence to the distance of the affected object
  52107. */
  52108. falloff: PhysicsRadialImpulseFalloff;
  52109. /**
  52110. * Sphere options for the radial explosion.
  52111. */
  52112. sphere: {
  52113. segments: number;
  52114. diameter: number;
  52115. };
  52116. /**
  52117. * Sphere options for the radial explosion.
  52118. */
  52119. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  52120. }
  52121. /**
  52122. * Options fot the updraft event
  52123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52124. */
  52125. export class PhysicsUpdraftEventOptions {
  52126. /**
  52127. * The radius of the cylinder for the vortex
  52128. */
  52129. radius: number;
  52130. /**
  52131. * The strenth of the updraft.
  52132. */
  52133. strength: number;
  52134. /**
  52135. * The height of the cylinder for the updraft.
  52136. */
  52137. height: number;
  52138. /**
  52139. * The mode for the the updraft.
  52140. */
  52141. updraftMode: PhysicsUpdraftMode;
  52142. }
  52143. /**
  52144. * Options fot the vortex event
  52145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52146. */
  52147. export class PhysicsVortexEventOptions {
  52148. /**
  52149. * The radius of the cylinder for the vortex
  52150. */
  52151. radius: number;
  52152. /**
  52153. * The strenth of the vortex.
  52154. */
  52155. strength: number;
  52156. /**
  52157. * The height of the cylinder for the vortex.
  52158. */
  52159. height: number;
  52160. /**
  52161. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  52162. */
  52163. centripetalForceThreshold: number;
  52164. /**
  52165. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  52166. */
  52167. centripetalForceMultiplier: number;
  52168. /**
  52169. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  52170. */
  52171. centrifugalForceMultiplier: number;
  52172. /**
  52173. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  52174. */
  52175. updraftForceMultiplier: number;
  52176. }
  52177. /**
  52178. * The strenght of the force in correspondence to the distance of the affected object
  52179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52180. */
  52181. export enum PhysicsRadialImpulseFalloff {
  52182. /** Defines that impulse is constant in strength across it's whole radius */
  52183. Constant = 0,
  52184. /** Defines that impulse gets weaker if it's further from the origin */
  52185. Linear = 1
  52186. }
  52187. /**
  52188. * The strength of the force in correspondence to the distance of the affected object
  52189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52190. */
  52191. export enum PhysicsUpdraftMode {
  52192. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52193. Center = 0,
  52194. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52195. Perpendicular = 1
  52196. }
  52197. /**
  52198. * Interface for a physics hit data
  52199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52200. */
  52201. export interface PhysicsHitData {
  52202. /**
  52203. * The force applied at the contact point
  52204. */
  52205. force: Vector3;
  52206. /**
  52207. * The contact point
  52208. */
  52209. contactPoint: Vector3;
  52210. /**
  52211. * The distance from the origin to the contact point
  52212. */
  52213. distanceFromOrigin: number;
  52214. }
  52215. /**
  52216. * Interface for radial explosion event data
  52217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52218. */
  52219. export interface PhysicsRadialExplosionEventData {
  52220. /**
  52221. * A sphere used for the radial explosion event
  52222. */
  52223. sphere: Mesh;
  52224. }
  52225. /**
  52226. * Interface for gravitational field event data
  52227. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52228. */
  52229. export interface PhysicsGravitationalFieldEventData {
  52230. /**
  52231. * A sphere mesh used for the gravitational field event
  52232. */
  52233. sphere: Mesh;
  52234. }
  52235. /**
  52236. * Interface for updraft event data
  52237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52238. */
  52239. export interface PhysicsUpdraftEventData {
  52240. /**
  52241. * A cylinder used for the updraft event
  52242. */
  52243. cylinder: Mesh;
  52244. }
  52245. /**
  52246. * Interface for vortex event data
  52247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52248. */
  52249. export interface PhysicsVortexEventData {
  52250. /**
  52251. * A cylinder used for the vortex event
  52252. */
  52253. cylinder: Mesh;
  52254. }
  52255. /**
  52256. * Interface for an affected physics impostor
  52257. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52258. */
  52259. export interface PhysicsAffectedImpostorWithData {
  52260. /**
  52261. * The impostor affected by the effect
  52262. */
  52263. impostor: PhysicsImpostor;
  52264. /**
  52265. * The data about the hit/horce from the explosion
  52266. */
  52267. hitData: PhysicsHitData;
  52268. }
  52269. }
  52270. declare module BABYLON {
  52271. /** @hidden */
  52272. export var blackAndWhitePixelShader: {
  52273. name: string;
  52274. shader: string;
  52275. };
  52276. }
  52277. declare module BABYLON {
  52278. /**
  52279. * Post process used to render in black and white
  52280. */
  52281. export class BlackAndWhitePostProcess extends PostProcess {
  52282. /**
  52283. * Linear about to convert he result to black and white (default: 1)
  52284. */
  52285. degree: number;
  52286. /**
  52287. * Creates a black and white post process
  52288. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52289. * @param name The name of the effect.
  52290. * @param options The required width/height ratio to downsize to before computing the render pass.
  52291. * @param camera The camera to apply the render pass to.
  52292. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52293. * @param engine The engine which the post process will be applied. (default: current engine)
  52294. * @param reusable If the post process can be reused on the same frame. (default: false)
  52295. */
  52296. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52297. }
  52298. }
  52299. declare module BABYLON {
  52300. /**
  52301. * This represents a set of one or more post processes in Babylon.
  52302. * A post process can be used to apply a shader to a texture after it is rendered.
  52303. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52304. */
  52305. export class PostProcessRenderEffect {
  52306. private _postProcesses;
  52307. private _getPostProcesses;
  52308. private _singleInstance;
  52309. private _cameras;
  52310. private _indicesForCamera;
  52311. /**
  52312. * Name of the effect
  52313. * @hidden
  52314. */
  52315. _name: string;
  52316. /**
  52317. * Instantiates a post process render effect.
  52318. * A post process can be used to apply a shader to a texture after it is rendered.
  52319. * @param engine The engine the effect is tied to
  52320. * @param name The name of the effect
  52321. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52322. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52323. */
  52324. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52325. /**
  52326. * Checks if all the post processes in the effect are supported.
  52327. */
  52328. readonly isSupported: boolean;
  52329. /**
  52330. * Updates the current state of the effect
  52331. * @hidden
  52332. */
  52333. _update(): void;
  52334. /**
  52335. * Attaches the effect on cameras
  52336. * @param cameras The camera to attach to.
  52337. * @hidden
  52338. */
  52339. _attachCameras(cameras: Camera): void;
  52340. /**
  52341. * Attaches the effect on cameras
  52342. * @param cameras The camera to attach to.
  52343. * @hidden
  52344. */
  52345. _attachCameras(cameras: Camera[]): void;
  52346. /**
  52347. * Detaches the effect on cameras
  52348. * @param cameras The camera to detatch from.
  52349. * @hidden
  52350. */
  52351. _detachCameras(cameras: Camera): void;
  52352. /**
  52353. * Detatches the effect on cameras
  52354. * @param cameras The camera to detatch from.
  52355. * @hidden
  52356. */
  52357. _detachCameras(cameras: Camera[]): void;
  52358. /**
  52359. * Enables the effect on given cameras
  52360. * @param cameras The camera to enable.
  52361. * @hidden
  52362. */
  52363. _enable(cameras: Camera): void;
  52364. /**
  52365. * Enables the effect on given cameras
  52366. * @param cameras The camera to enable.
  52367. * @hidden
  52368. */
  52369. _enable(cameras: Nullable<Camera[]>): void;
  52370. /**
  52371. * Disables the effect on the given cameras
  52372. * @param cameras The camera to disable.
  52373. * @hidden
  52374. */
  52375. _disable(cameras: Camera): void;
  52376. /**
  52377. * Disables the effect on the given cameras
  52378. * @param cameras The camera to disable.
  52379. * @hidden
  52380. */
  52381. _disable(cameras: Nullable<Camera[]>): void;
  52382. /**
  52383. * Gets a list of the post processes contained in the effect.
  52384. * @param camera The camera to get the post processes on.
  52385. * @returns The list of the post processes in the effect.
  52386. */
  52387. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52388. }
  52389. }
  52390. declare module BABYLON {
  52391. /** @hidden */
  52392. export var extractHighlightsPixelShader: {
  52393. name: string;
  52394. shader: string;
  52395. };
  52396. }
  52397. declare module BABYLON {
  52398. /**
  52399. * 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.
  52400. */
  52401. export class ExtractHighlightsPostProcess extends PostProcess {
  52402. /**
  52403. * The luminance threshold, pixels below this value will be set to black.
  52404. */
  52405. threshold: number;
  52406. /** @hidden */
  52407. _exposure: number;
  52408. /**
  52409. * Post process which has the input texture to be used when performing highlight extraction
  52410. * @hidden
  52411. */
  52412. _inputPostProcess: Nullable<PostProcess>;
  52413. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52414. }
  52415. }
  52416. declare module BABYLON {
  52417. /** @hidden */
  52418. export var bloomMergePixelShader: {
  52419. name: string;
  52420. shader: string;
  52421. };
  52422. }
  52423. declare module BABYLON {
  52424. /**
  52425. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52426. */
  52427. export class BloomMergePostProcess extends PostProcess {
  52428. /** Weight of the bloom to be added to the original input. */
  52429. weight: number;
  52430. /**
  52431. * Creates a new instance of @see BloomMergePostProcess
  52432. * @param name The name of the effect.
  52433. * @param originalFromInput Post process which's input will be used for the merge.
  52434. * @param blurred Blurred highlights post process which's output will be used.
  52435. * @param weight Weight of the bloom to be added to the original input.
  52436. * @param options The required width/height ratio to downsize to before computing the render pass.
  52437. * @param camera The camera to apply the render pass to.
  52438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52439. * @param engine The engine which the post process will be applied. (default: current engine)
  52440. * @param reusable If the post process can be reused on the same frame. (default: false)
  52441. * @param textureType Type of textures used when performing the post process. (default: 0)
  52442. * @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)
  52443. */
  52444. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52445. /** Weight of the bloom to be added to the original input. */
  52446. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52447. }
  52448. }
  52449. declare module BABYLON {
  52450. /**
  52451. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52452. */
  52453. export class BloomEffect extends PostProcessRenderEffect {
  52454. private bloomScale;
  52455. /**
  52456. * @hidden Internal
  52457. */
  52458. _effects: Array<PostProcess>;
  52459. /**
  52460. * @hidden Internal
  52461. */
  52462. _downscale: ExtractHighlightsPostProcess;
  52463. private _blurX;
  52464. private _blurY;
  52465. private _merge;
  52466. /**
  52467. * The luminance threshold to find bright areas of the image to bloom.
  52468. */
  52469. threshold: number;
  52470. /**
  52471. * The strength of the bloom.
  52472. */
  52473. weight: number;
  52474. /**
  52475. * Specifies the size of the bloom blur kernel, relative to the final output size
  52476. */
  52477. kernel: number;
  52478. /**
  52479. * Creates a new instance of @see BloomEffect
  52480. * @param scene The scene the effect belongs to.
  52481. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52482. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52483. * @param bloomWeight The the strength of bloom.
  52484. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52485. * @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)
  52486. */
  52487. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52488. /**
  52489. * Disposes each of the internal effects for a given camera.
  52490. * @param camera The camera to dispose the effect on.
  52491. */
  52492. disposeEffects(camera: Camera): void;
  52493. /**
  52494. * @hidden Internal
  52495. */
  52496. _updateEffects(): void;
  52497. /**
  52498. * Internal
  52499. * @returns if all the contained post processes are ready.
  52500. * @hidden
  52501. */
  52502. _isReady(): boolean;
  52503. }
  52504. }
  52505. declare module BABYLON {
  52506. /** @hidden */
  52507. export var chromaticAberrationPixelShader: {
  52508. name: string;
  52509. shader: string;
  52510. };
  52511. }
  52512. declare module BABYLON {
  52513. /**
  52514. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52515. */
  52516. export class ChromaticAberrationPostProcess extends PostProcess {
  52517. /**
  52518. * The amount of seperation of rgb channels (default: 30)
  52519. */
  52520. aberrationAmount: number;
  52521. /**
  52522. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52523. */
  52524. radialIntensity: number;
  52525. /**
  52526. * 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))
  52527. */
  52528. direction: Vector2;
  52529. /**
  52530. * 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))
  52531. */
  52532. centerPosition: Vector2;
  52533. /**
  52534. * Creates a new instance ChromaticAberrationPostProcess
  52535. * @param name The name of the effect.
  52536. * @param screenWidth The width of the screen to apply the effect on.
  52537. * @param screenHeight The height of the screen to apply the effect on.
  52538. * @param options The required width/height ratio to downsize to before computing the render pass.
  52539. * @param camera The camera to apply the render pass to.
  52540. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52541. * @param engine The engine which the post process will be applied. (default: current engine)
  52542. * @param reusable If the post process can be reused on the same frame. (default: false)
  52543. * @param textureType Type of textures used when performing the post process. (default: 0)
  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(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52547. }
  52548. }
  52549. declare module BABYLON {
  52550. /** @hidden */
  52551. export var circleOfConfusionPixelShader: {
  52552. name: string;
  52553. shader: string;
  52554. };
  52555. }
  52556. declare module BABYLON {
  52557. /**
  52558. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52559. */
  52560. export class CircleOfConfusionPostProcess extends PostProcess {
  52561. /**
  52562. * 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.
  52563. */
  52564. lensSize: number;
  52565. /**
  52566. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52567. */
  52568. fStop: number;
  52569. /**
  52570. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52571. */
  52572. focusDistance: number;
  52573. /**
  52574. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52575. */
  52576. focalLength: number;
  52577. private _depthTexture;
  52578. /**
  52579. * Creates a new instance CircleOfConfusionPostProcess
  52580. * @param name The name of the effect.
  52581. * @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.
  52582. * @param options The required width/height ratio to downsize to before computing the render pass.
  52583. * @param camera The camera to apply the render pass to.
  52584. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52585. * @param engine The engine which the post process will be applied. (default: current engine)
  52586. * @param reusable If the post process can be reused on the same frame. (default: false)
  52587. * @param textureType Type of textures used when performing the post process. (default: 0)
  52588. * @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)
  52589. */
  52590. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52591. /**
  52592. * 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.
  52593. */
  52594. depthTexture: RenderTargetTexture;
  52595. }
  52596. }
  52597. declare module BABYLON {
  52598. /** @hidden */
  52599. export var colorCorrectionPixelShader: {
  52600. name: string;
  52601. shader: string;
  52602. };
  52603. }
  52604. declare module BABYLON {
  52605. /**
  52606. *
  52607. * This post-process allows the modification of rendered colors by using
  52608. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52609. *
  52610. * The object needs to be provided an url to a texture containing the color
  52611. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52612. * Use an image editing software to tweak the LUT to match your needs.
  52613. *
  52614. * For an example of a color LUT, see here:
  52615. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52616. * For explanations on color grading, see here:
  52617. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52618. *
  52619. */
  52620. export class ColorCorrectionPostProcess extends PostProcess {
  52621. private _colorTableTexture;
  52622. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52623. }
  52624. }
  52625. declare module BABYLON {
  52626. /** @hidden */
  52627. export var convolutionPixelShader: {
  52628. name: string;
  52629. shader: string;
  52630. };
  52631. }
  52632. declare module BABYLON {
  52633. /**
  52634. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52635. * input texture to perform effects such as edge detection or sharpening
  52636. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52637. */
  52638. export class ConvolutionPostProcess extends PostProcess {
  52639. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52640. kernel: number[];
  52641. /**
  52642. * Creates a new instance ConvolutionPostProcess
  52643. * @param name The name of the effect.
  52644. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52645. * @param options The required width/height ratio to downsize to before computing the render pass.
  52646. * @param camera The camera to apply the render pass to.
  52647. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52648. * @param engine The engine which the post process will be applied. (default: current engine)
  52649. * @param reusable If the post process can be reused on the same frame. (default: false)
  52650. * @param textureType Type of textures used when performing the post process. (default: 0)
  52651. */
  52652. constructor(name: string,
  52653. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52654. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52655. /**
  52656. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52657. */
  52658. static EdgeDetect0Kernel: number[];
  52659. /**
  52660. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52661. */
  52662. static EdgeDetect1Kernel: number[];
  52663. /**
  52664. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52665. */
  52666. static EdgeDetect2Kernel: number[];
  52667. /**
  52668. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52669. */
  52670. static SharpenKernel: number[];
  52671. /**
  52672. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52673. */
  52674. static EmbossKernel: number[];
  52675. /**
  52676. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52677. */
  52678. static GaussianKernel: number[];
  52679. }
  52680. }
  52681. declare module BABYLON {
  52682. /**
  52683. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52684. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52685. * based on samples that have a large difference in distance than the center pixel.
  52686. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  52687. */
  52688. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  52689. direction: Vector2;
  52690. /**
  52691. * Creates a new instance CircleOfConfusionPostProcess
  52692. * @param name The name of the effect.
  52693. * @param scene The scene the effect belongs to.
  52694. * @param direction The direction the blur should be applied.
  52695. * @param kernel The size of the kernel used to blur.
  52696. * @param options The required width/height ratio to downsize to before computing the render pass.
  52697. * @param camera The camera to apply the render pass to.
  52698. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  52699. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  52700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52701. * @param engine The engine which the post process will be applied. (default: current engine)
  52702. * @param reusable If the post process can be reused on the same frame. (default: false)
  52703. * @param textureType Type of textures used when performing the post process. (default: 0)
  52704. * @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)
  52705. */
  52706. 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);
  52707. }
  52708. }
  52709. declare module BABYLON {
  52710. /** @hidden */
  52711. export var depthOfFieldMergePixelShader: {
  52712. name: string;
  52713. shader: string;
  52714. };
  52715. }
  52716. declare module BABYLON {
  52717. /**
  52718. * Options to be set when merging outputs from the default pipeline.
  52719. */
  52720. export class DepthOfFieldMergePostProcessOptions {
  52721. /**
  52722. * The original image to merge on top of
  52723. */
  52724. originalFromInput: PostProcess;
  52725. /**
  52726. * Parameters to perform the merge of the depth of field effect
  52727. */
  52728. depthOfField?: {
  52729. circleOfConfusion: PostProcess;
  52730. blurSteps: Array<PostProcess>;
  52731. };
  52732. /**
  52733. * Parameters to perform the merge of bloom effect
  52734. */
  52735. bloom?: {
  52736. blurred: PostProcess;
  52737. weight: number;
  52738. };
  52739. }
  52740. /**
  52741. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52742. */
  52743. export class DepthOfFieldMergePostProcess extends PostProcess {
  52744. private blurSteps;
  52745. /**
  52746. * Creates a new instance of DepthOfFieldMergePostProcess
  52747. * @param name The name of the effect.
  52748. * @param originalFromInput Post process which's input will be used for the merge.
  52749. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  52750. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  52751. * @param options The required width/height ratio to downsize to before computing the render pass.
  52752. * @param camera The camera to apply the render pass to.
  52753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52754. * @param engine The engine which the post process will be applied. (default: current engine)
  52755. * @param reusable If the post process can be reused on the same frame. (default: false)
  52756. * @param textureType Type of textures used when performing the post process. (default: 0)
  52757. * @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)
  52758. */
  52759. 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);
  52760. /**
  52761. * Updates the effect with the current post process compile time values and recompiles the shader.
  52762. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  52763. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  52764. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  52765. * @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
  52766. * @param onCompiled Called when the shader has been compiled.
  52767. * @param onError Called if there is an error when compiling a shader.
  52768. */
  52769. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52770. }
  52771. }
  52772. declare module BABYLON {
  52773. /**
  52774. * Specifies the level of max blur that should be applied when using the depth of field effect
  52775. */
  52776. export enum DepthOfFieldEffectBlurLevel {
  52777. /**
  52778. * Subtle blur
  52779. */
  52780. Low = 0,
  52781. /**
  52782. * Medium blur
  52783. */
  52784. Medium = 1,
  52785. /**
  52786. * Large blur
  52787. */
  52788. High = 2
  52789. }
  52790. /**
  52791. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52792. */
  52793. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52794. private _circleOfConfusion;
  52795. /**
  52796. * @hidden Internal, blurs from high to low
  52797. */
  52798. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52799. private _depthOfFieldBlurY;
  52800. private _dofMerge;
  52801. /**
  52802. * @hidden Internal post processes in depth of field effect
  52803. */
  52804. _effects: Array<PostProcess>;
  52805. /**
  52806. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52807. */
  52808. focalLength: number;
  52809. /**
  52810. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52811. */
  52812. fStop: number;
  52813. /**
  52814. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52815. */
  52816. focusDistance: number;
  52817. /**
  52818. * 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.
  52819. */
  52820. lensSize: number;
  52821. /**
  52822. * Creates a new instance DepthOfFieldEffect
  52823. * @param scene The scene the effect belongs to.
  52824. * @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.
  52825. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52826. * @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)
  52827. */
  52828. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52829. /**
  52830. * Get the current class name of the current effet
  52831. * @returns "DepthOfFieldEffect"
  52832. */
  52833. getClassName(): string;
  52834. /**
  52835. * 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.
  52836. */
  52837. depthTexture: RenderTargetTexture;
  52838. /**
  52839. * Disposes each of the internal effects for a given camera.
  52840. * @param camera The camera to dispose the effect on.
  52841. */
  52842. disposeEffects(camera: Camera): void;
  52843. /**
  52844. * @hidden Internal
  52845. */
  52846. _updateEffects(): void;
  52847. /**
  52848. * Internal
  52849. * @returns if all the contained post processes are ready.
  52850. * @hidden
  52851. */
  52852. _isReady(): boolean;
  52853. }
  52854. }
  52855. declare module BABYLON {
  52856. /** @hidden */
  52857. export var displayPassPixelShader: {
  52858. name: string;
  52859. shader: string;
  52860. };
  52861. }
  52862. declare module BABYLON {
  52863. /**
  52864. * DisplayPassPostProcess which produces an output the same as it's input
  52865. */
  52866. export class DisplayPassPostProcess extends PostProcess {
  52867. /**
  52868. * Creates the DisplayPassPostProcess
  52869. * @param name The name of the effect.
  52870. * @param options The required width/height ratio to downsize to before computing the render pass.
  52871. * @param camera The camera to apply the render pass to.
  52872. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52873. * @param engine The engine which the post process will be applied. (default: current engine)
  52874. * @param reusable If the post process can be reused on the same frame. (default: false)
  52875. */
  52876. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52877. }
  52878. }
  52879. declare module BABYLON {
  52880. /** @hidden */
  52881. export var filterPixelShader: {
  52882. name: string;
  52883. shader: string;
  52884. };
  52885. }
  52886. declare module BABYLON {
  52887. /**
  52888. * Applies a kernel filter to the image
  52889. */
  52890. export class FilterPostProcess extends PostProcess {
  52891. /** The matrix to be applied to the image */
  52892. kernelMatrix: Matrix;
  52893. /**
  52894. *
  52895. * @param name The name of the effect.
  52896. * @param kernelMatrix The matrix to be applied to the image
  52897. * @param options The required width/height ratio to downsize to before computing the render pass.
  52898. * @param camera The camera to apply the render pass to.
  52899. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52900. * @param engine The engine which the post process will be applied. (default: current engine)
  52901. * @param reusable If the post process can be reused on the same frame. (default: false)
  52902. */
  52903. constructor(name: string,
  52904. /** The matrix to be applied to the image */
  52905. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52906. }
  52907. }
  52908. declare module BABYLON {
  52909. /** @hidden */
  52910. export var fxaaPixelShader: {
  52911. name: string;
  52912. shader: string;
  52913. };
  52914. }
  52915. declare module BABYLON {
  52916. /** @hidden */
  52917. export var fxaaVertexShader: {
  52918. name: string;
  52919. shader: string;
  52920. };
  52921. }
  52922. declare module BABYLON {
  52923. /**
  52924. * Fxaa post process
  52925. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52926. */
  52927. export class FxaaPostProcess extends PostProcess {
  52928. /** @hidden */
  52929. texelWidth: number;
  52930. /** @hidden */
  52931. texelHeight: number;
  52932. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52933. private _getDefines;
  52934. }
  52935. }
  52936. declare module BABYLON {
  52937. /** @hidden */
  52938. export var grainPixelShader: {
  52939. name: string;
  52940. shader: string;
  52941. };
  52942. }
  52943. declare module BABYLON {
  52944. /**
  52945. * The GrainPostProcess adds noise to the image at mid luminance levels
  52946. */
  52947. export class GrainPostProcess extends PostProcess {
  52948. /**
  52949. * The intensity of the grain added (default: 30)
  52950. */
  52951. intensity: number;
  52952. /**
  52953. * If the grain should be randomized on every frame
  52954. */
  52955. animated: boolean;
  52956. /**
  52957. * Creates a new instance of @see GrainPostProcess
  52958. * @param name The name of the effect.
  52959. * @param options The required width/height ratio to downsize to before computing the render pass.
  52960. * @param camera The camera to apply the render pass to.
  52961. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52962. * @param engine The engine which the post process will be applied. (default: current engine)
  52963. * @param reusable If the post process can be reused on the same frame. (default: false)
  52964. * @param textureType Type of textures used when performing the post process. (default: 0)
  52965. * @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)
  52966. */
  52967. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52968. }
  52969. }
  52970. declare module BABYLON {
  52971. /** @hidden */
  52972. export var highlightsPixelShader: {
  52973. name: string;
  52974. shader: string;
  52975. };
  52976. }
  52977. declare module BABYLON {
  52978. /**
  52979. * Extracts highlights from the image
  52980. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52981. */
  52982. export class HighlightsPostProcess extends PostProcess {
  52983. /**
  52984. * Extracts highlights from the image
  52985. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52986. * @param name The name of the effect.
  52987. * @param options The required width/height ratio to downsize to before computing the render pass.
  52988. * @param camera The camera to apply the render pass to.
  52989. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52990. * @param engine The engine which the post process will be applied. (default: current engine)
  52991. * @param reusable If the post process can be reused on the same frame. (default: false)
  52992. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52993. */
  52994. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52995. }
  52996. }
  52997. declare module BABYLON {
  52998. /** @hidden */
  52999. export var mrtFragmentDeclaration: {
  53000. name: string;
  53001. shader: string;
  53002. };
  53003. }
  53004. declare module BABYLON {
  53005. /** @hidden */
  53006. export var geometryPixelShader: {
  53007. name: string;
  53008. shader: string;
  53009. };
  53010. }
  53011. declare module BABYLON {
  53012. /** @hidden */
  53013. export var geometryVertexShader: {
  53014. name: string;
  53015. shader: string;
  53016. };
  53017. }
  53018. declare module BABYLON {
  53019. /** @hidden */
  53020. interface ISavedTransformationMatrix {
  53021. world: Matrix;
  53022. viewProjection: Matrix;
  53023. }
  53024. /**
  53025. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53026. */
  53027. export class GeometryBufferRenderer {
  53028. /**
  53029. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53030. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53031. */
  53032. static readonly POSITION_TEXTURE_TYPE: number;
  53033. /**
  53034. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53035. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53036. */
  53037. static readonly VELOCITY_TEXTURE_TYPE: number;
  53038. /**
  53039. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53040. * in order to compute objects velocities when enableVelocity is set to "true"
  53041. * @hidden
  53042. */
  53043. _previousTransformationMatrices: {
  53044. [index: number]: ISavedTransformationMatrix;
  53045. };
  53046. /**
  53047. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  53048. * in order to compute objects velocities when enableVelocity is set to "true"
  53049. * @hidden
  53050. */
  53051. _previousBonesTransformationMatrices: {
  53052. [index: number]: Float32Array;
  53053. };
  53054. /**
  53055. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  53056. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  53057. */
  53058. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  53059. private _scene;
  53060. private _multiRenderTarget;
  53061. private _ratio;
  53062. private _enablePosition;
  53063. private _enableVelocity;
  53064. private _positionIndex;
  53065. private _velocityIndex;
  53066. protected _effect: Effect;
  53067. protected _cachedDefines: string;
  53068. /**
  53069. * Set the render list (meshes to be rendered) used in the G buffer.
  53070. */
  53071. renderList: Mesh[];
  53072. /**
  53073. * Gets wether or not G buffer are supported by the running hardware.
  53074. * This requires draw buffer supports
  53075. */
  53076. readonly isSupported: boolean;
  53077. /**
  53078. * Returns the index of the given texture type in the G-Buffer textures array
  53079. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53080. * @returns the index of the given texture type in the G-Buffer textures array
  53081. */
  53082. getTextureIndex(textureType: number): number;
  53083. /**
  53084. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53085. */
  53086. /**
  53087. * Sets whether or not objects positions are enabled for the G buffer.
  53088. */
  53089. enablePosition: boolean;
  53090. /**
  53091. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53092. */
  53093. /**
  53094. * Sets wether or not objects velocities are enabled for the G buffer.
  53095. */
  53096. enableVelocity: boolean;
  53097. /**
  53098. * Gets the scene associated with the buffer.
  53099. */
  53100. readonly scene: Scene;
  53101. /**
  53102. * Gets the ratio used by the buffer during its creation.
  53103. * How big is the buffer related to the main canvas.
  53104. */
  53105. readonly ratio: number;
  53106. /** @hidden */
  53107. static _SceneComponentInitialization: (scene: Scene) => void;
  53108. /**
  53109. * Creates a new G Buffer for the scene
  53110. * @param scene The scene the buffer belongs to
  53111. * @param ratio How big is the buffer related to the main canvas.
  53112. */
  53113. constructor(scene: Scene, ratio?: number);
  53114. /**
  53115. * Checks wether everything is ready to render a submesh to the G buffer.
  53116. * @param subMesh the submesh to check readiness for
  53117. * @param useInstances is the mesh drawn using instance or not
  53118. * @returns true if ready otherwise false
  53119. */
  53120. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53121. /**
  53122. * Gets the current underlying G Buffer.
  53123. * @returns the buffer
  53124. */
  53125. getGBuffer(): MultiRenderTarget;
  53126. /**
  53127. * Gets the number of samples used to render the buffer (anti aliasing).
  53128. */
  53129. /**
  53130. * Sets the number of samples used to render the buffer (anti aliasing).
  53131. */
  53132. samples: number;
  53133. /**
  53134. * Disposes the renderer and frees up associated resources.
  53135. */
  53136. dispose(): void;
  53137. protected _createRenderTargets(): void;
  53138. private _copyBonesTransformationMatrices;
  53139. }
  53140. }
  53141. declare module BABYLON {
  53142. interface Scene {
  53143. /** @hidden (Backing field) */
  53144. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53145. /**
  53146. * Gets or Sets the current geometry buffer associated to the scene.
  53147. */
  53148. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53149. /**
  53150. * Enables a GeometryBufferRender and associates it with the scene
  53151. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53152. * @returns the GeometryBufferRenderer
  53153. */
  53154. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53155. /**
  53156. * Disables the GeometryBufferRender associated with the scene
  53157. */
  53158. disableGeometryBufferRenderer(): void;
  53159. }
  53160. /**
  53161. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53162. * in several rendering techniques.
  53163. */
  53164. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53165. /**
  53166. * The component name helpful to identify the component in the list of scene components.
  53167. */
  53168. readonly name: string;
  53169. /**
  53170. * The scene the component belongs to.
  53171. */
  53172. scene: Scene;
  53173. /**
  53174. * Creates a new instance of the component for the given scene
  53175. * @param scene Defines the scene to register the component in
  53176. */
  53177. constructor(scene: Scene);
  53178. /**
  53179. * Registers the component in a given scene
  53180. */
  53181. register(): void;
  53182. /**
  53183. * Rebuilds the elements related to this component in case of
  53184. * context lost for instance.
  53185. */
  53186. rebuild(): void;
  53187. /**
  53188. * Disposes the component and the associated ressources
  53189. */
  53190. dispose(): void;
  53191. private _gatherRenderTargets;
  53192. }
  53193. }
  53194. declare module BABYLON {
  53195. /** @hidden */
  53196. export var motionBlurPixelShader: {
  53197. name: string;
  53198. shader: string;
  53199. };
  53200. }
  53201. declare module BABYLON {
  53202. /**
  53203. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53204. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53205. * As an example, all you have to do is to create the post-process:
  53206. * var mb = new BABYLON.MotionBlurPostProcess(
  53207. * 'mb', // The name of the effect.
  53208. * scene, // The scene containing the objects to blur according to their velocity.
  53209. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53210. * camera // The camera to apply the render pass to.
  53211. * );
  53212. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53213. */
  53214. export class MotionBlurPostProcess extends PostProcess {
  53215. /**
  53216. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53217. */
  53218. motionStrength: number;
  53219. /**
  53220. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53221. */
  53222. /**
  53223. * Sets the number of iterations to be used for motion blur quality
  53224. */
  53225. motionBlurSamples: number;
  53226. private _motionBlurSamples;
  53227. private _geometryBufferRenderer;
  53228. /**
  53229. * Creates a new instance MotionBlurPostProcess
  53230. * @param name The name of the effect.
  53231. * @param scene The scene containing the objects to blur according to their velocity.
  53232. * @param options The required width/height ratio to downsize to before computing the render pass.
  53233. * @param camera The camera to apply the render pass to.
  53234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53235. * @param engine The engine which the post process will be applied. (default: current engine)
  53236. * @param reusable If the post process can be reused on the same frame. (default: false)
  53237. * @param textureType Type of textures used when performing the post process. (default: 0)
  53238. * @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)
  53239. */
  53240. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53241. /**
  53242. * Excludes the given skinned mesh from computing bones velocities.
  53243. * 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.
  53244. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  53245. */
  53246. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  53247. /**
  53248. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  53249. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  53250. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  53251. */
  53252. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  53253. /**
  53254. * Disposes the post process.
  53255. * @param camera The camera to dispose the post process on.
  53256. */
  53257. dispose(camera?: Camera): void;
  53258. }
  53259. }
  53260. declare module BABYLON {
  53261. /** @hidden */
  53262. export var refractionPixelShader: {
  53263. name: string;
  53264. shader: string;
  53265. };
  53266. }
  53267. declare module BABYLON {
  53268. /**
  53269. * Post process which applies a refractin texture
  53270. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53271. */
  53272. export class RefractionPostProcess extends PostProcess {
  53273. /** the base color of the refraction (used to taint the rendering) */
  53274. color: Color3;
  53275. /** simulated refraction depth */
  53276. depth: number;
  53277. /** the coefficient of the base color (0 to remove base color tainting) */
  53278. colorLevel: number;
  53279. private _refTexture;
  53280. private _ownRefractionTexture;
  53281. /**
  53282. * Gets or sets the refraction texture
  53283. * Please note that you are responsible for disposing the texture if you set it manually
  53284. */
  53285. refractionTexture: Texture;
  53286. /**
  53287. * Initializes the RefractionPostProcess
  53288. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53289. * @param name The name of the effect.
  53290. * @param refractionTextureUrl Url of the refraction texture to use
  53291. * @param color the base color of the refraction (used to taint the rendering)
  53292. * @param depth simulated refraction depth
  53293. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53294. * @param camera The camera to apply the render pass to.
  53295. * @param options The required width/height ratio to downsize to before computing the render pass.
  53296. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53297. * @param engine The engine which the post process will be applied. (default: current engine)
  53298. * @param reusable If the post process can be reused on the same frame. (default: false)
  53299. */
  53300. constructor(name: string, refractionTextureUrl: string,
  53301. /** the base color of the refraction (used to taint the rendering) */
  53302. color: Color3,
  53303. /** simulated refraction depth */
  53304. depth: number,
  53305. /** the coefficient of the base color (0 to remove base color tainting) */
  53306. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53307. /**
  53308. * Disposes of the post process
  53309. * @param camera Camera to dispose post process on
  53310. */
  53311. dispose(camera: Camera): void;
  53312. }
  53313. }
  53314. declare module BABYLON {
  53315. /** @hidden */
  53316. export var sharpenPixelShader: {
  53317. name: string;
  53318. shader: string;
  53319. };
  53320. }
  53321. declare module BABYLON {
  53322. /**
  53323. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53324. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53325. */
  53326. export class SharpenPostProcess extends PostProcess {
  53327. /**
  53328. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53329. */
  53330. colorAmount: number;
  53331. /**
  53332. * How much sharpness should be applied (default: 0.3)
  53333. */
  53334. edgeAmount: number;
  53335. /**
  53336. * Creates a new instance ConvolutionPostProcess
  53337. * @param name The name of the effect.
  53338. * @param options The required width/height ratio to downsize to before computing the render pass.
  53339. * @param camera The camera to apply the render pass to.
  53340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53341. * @param engine The engine which the post process will be applied. (default: current engine)
  53342. * @param reusable If the post process can be reused on the same frame. (default: false)
  53343. * @param textureType Type of textures used when performing the post process. (default: 0)
  53344. * @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)
  53345. */
  53346. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53347. }
  53348. }
  53349. declare module BABYLON {
  53350. /**
  53351. * PostProcessRenderPipeline
  53352. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53353. */
  53354. export class PostProcessRenderPipeline {
  53355. private engine;
  53356. private _renderEffects;
  53357. private _renderEffectsForIsolatedPass;
  53358. /**
  53359. * List of inspectable custom properties (used by the Inspector)
  53360. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  53361. */
  53362. inspectableCustomProperties: IInspectable[];
  53363. /**
  53364. * @hidden
  53365. */
  53366. protected _cameras: Camera[];
  53367. /** @hidden */
  53368. _name: string;
  53369. /**
  53370. * Gets pipeline name
  53371. */
  53372. readonly name: string;
  53373. /**
  53374. * Initializes a PostProcessRenderPipeline
  53375. * @param engine engine to add the pipeline to
  53376. * @param name name of the pipeline
  53377. */
  53378. constructor(engine: Engine, name: string);
  53379. /**
  53380. * Gets the class name
  53381. * @returns "PostProcessRenderPipeline"
  53382. */
  53383. getClassName(): string;
  53384. /**
  53385. * If all the render effects in the pipeline are supported
  53386. */
  53387. readonly isSupported: boolean;
  53388. /**
  53389. * Adds an effect to the pipeline
  53390. * @param renderEffect the effect to add
  53391. */
  53392. addEffect(renderEffect: PostProcessRenderEffect): void;
  53393. /** @hidden */
  53394. _rebuild(): void;
  53395. /** @hidden */
  53396. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53397. /** @hidden */
  53398. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53399. /** @hidden */
  53400. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53401. /** @hidden */
  53402. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53403. /** @hidden */
  53404. _attachCameras(cameras: Camera, unique: boolean): void;
  53405. /** @hidden */
  53406. _attachCameras(cameras: Camera[], unique: boolean): void;
  53407. /** @hidden */
  53408. _detachCameras(cameras: Camera): void;
  53409. /** @hidden */
  53410. _detachCameras(cameras: Nullable<Camera[]>): void;
  53411. /** @hidden */
  53412. _update(): void;
  53413. /** @hidden */
  53414. _reset(): void;
  53415. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53416. /**
  53417. * Disposes of the pipeline
  53418. */
  53419. dispose(): void;
  53420. }
  53421. }
  53422. declare module BABYLON {
  53423. /**
  53424. * PostProcessRenderPipelineManager class
  53425. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53426. */
  53427. export class PostProcessRenderPipelineManager {
  53428. private _renderPipelines;
  53429. /**
  53430. * Initializes a PostProcessRenderPipelineManager
  53431. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53432. */
  53433. constructor();
  53434. /**
  53435. * Gets the list of supported render pipelines
  53436. */
  53437. readonly supportedPipelines: PostProcessRenderPipeline[];
  53438. /**
  53439. * Adds a pipeline to the manager
  53440. * @param renderPipeline The pipeline to add
  53441. */
  53442. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53443. /**
  53444. * Attaches a camera to the pipeline
  53445. * @param renderPipelineName The name of the pipeline to attach to
  53446. * @param cameras the camera to attach
  53447. * @param unique if the camera can be attached multiple times to the pipeline
  53448. */
  53449. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53450. /**
  53451. * Detaches a camera from the pipeline
  53452. * @param renderPipelineName The name of the pipeline to detach from
  53453. * @param cameras the camera to detach
  53454. */
  53455. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53456. /**
  53457. * Enables an effect by name on a pipeline
  53458. * @param renderPipelineName the name of the pipeline to enable the effect in
  53459. * @param renderEffectName the name of the effect to enable
  53460. * @param cameras the cameras that the effect should be enabled on
  53461. */
  53462. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53463. /**
  53464. * Disables an effect by name on a pipeline
  53465. * @param renderPipelineName the name of the pipeline to disable the effect in
  53466. * @param renderEffectName the name of the effect to disable
  53467. * @param cameras the cameras that the effect should be disabled on
  53468. */
  53469. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53470. /**
  53471. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53472. */
  53473. update(): void;
  53474. /** @hidden */
  53475. _rebuild(): void;
  53476. /**
  53477. * Disposes of the manager and pipelines
  53478. */
  53479. dispose(): void;
  53480. }
  53481. }
  53482. declare module BABYLON {
  53483. interface Scene {
  53484. /** @hidden (Backing field) */
  53485. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53486. /**
  53487. * Gets the postprocess render pipeline manager
  53488. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53489. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53490. */
  53491. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53492. }
  53493. /**
  53494. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53495. */
  53496. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53497. /**
  53498. * The component name helpfull to identify the component in the list of scene components.
  53499. */
  53500. readonly name: string;
  53501. /**
  53502. * The scene the component belongs to.
  53503. */
  53504. scene: Scene;
  53505. /**
  53506. * Creates a new instance of the component for the given scene
  53507. * @param scene Defines the scene to register the component in
  53508. */
  53509. constructor(scene: Scene);
  53510. /**
  53511. * Registers the component in a given scene
  53512. */
  53513. register(): void;
  53514. /**
  53515. * Rebuilds the elements related to this component in case of
  53516. * context lost for instance.
  53517. */
  53518. rebuild(): void;
  53519. /**
  53520. * Disposes the component and the associated ressources
  53521. */
  53522. dispose(): void;
  53523. private _gatherRenderTargets;
  53524. }
  53525. }
  53526. declare module BABYLON {
  53527. /**
  53528. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53529. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53530. */
  53531. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53532. private _scene;
  53533. private _camerasToBeAttached;
  53534. /**
  53535. * ID of the sharpen post process,
  53536. */
  53537. private readonly SharpenPostProcessId;
  53538. /**
  53539. * @ignore
  53540. * ID of the image processing post process;
  53541. */
  53542. readonly ImageProcessingPostProcessId: string;
  53543. /**
  53544. * @ignore
  53545. * ID of the Fast Approximate Anti-Aliasing post process;
  53546. */
  53547. readonly FxaaPostProcessId: string;
  53548. /**
  53549. * ID of the chromatic aberration post process,
  53550. */
  53551. private readonly ChromaticAberrationPostProcessId;
  53552. /**
  53553. * ID of the grain post process
  53554. */
  53555. private readonly GrainPostProcessId;
  53556. /**
  53557. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53558. */
  53559. sharpen: SharpenPostProcess;
  53560. private _sharpenEffect;
  53561. private bloom;
  53562. /**
  53563. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53564. */
  53565. depthOfField: DepthOfFieldEffect;
  53566. /**
  53567. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53568. */
  53569. fxaa: FxaaPostProcess;
  53570. /**
  53571. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53572. */
  53573. imageProcessing: ImageProcessingPostProcess;
  53574. /**
  53575. * Chromatic aberration post process which will shift rgb colors in the image
  53576. */
  53577. chromaticAberration: ChromaticAberrationPostProcess;
  53578. private _chromaticAberrationEffect;
  53579. /**
  53580. * Grain post process which add noise to the image
  53581. */
  53582. grain: GrainPostProcess;
  53583. private _grainEffect;
  53584. /**
  53585. * Glow post process which adds a glow to emissive areas of the image
  53586. */
  53587. private _glowLayer;
  53588. /**
  53589. * Animations which can be used to tweak settings over a period of time
  53590. */
  53591. animations: Animation[];
  53592. private _imageProcessingConfigurationObserver;
  53593. private _sharpenEnabled;
  53594. private _bloomEnabled;
  53595. private _depthOfFieldEnabled;
  53596. private _depthOfFieldBlurLevel;
  53597. private _fxaaEnabled;
  53598. private _imageProcessingEnabled;
  53599. private _defaultPipelineTextureType;
  53600. private _bloomScale;
  53601. private _chromaticAberrationEnabled;
  53602. private _grainEnabled;
  53603. private _buildAllowed;
  53604. /**
  53605. * Gets active scene
  53606. */
  53607. readonly scene: Scene;
  53608. /**
  53609. * Enable or disable the sharpen process from the pipeline
  53610. */
  53611. sharpenEnabled: boolean;
  53612. private _resizeObserver;
  53613. private _hardwareScaleLevel;
  53614. private _bloomKernel;
  53615. /**
  53616. * Specifies the size of the bloom blur kernel, relative to the final output size
  53617. */
  53618. bloomKernel: number;
  53619. /**
  53620. * Specifies the weight of the bloom in the final rendering
  53621. */
  53622. private _bloomWeight;
  53623. /**
  53624. * Specifies the luma threshold for the area that will be blurred by the bloom
  53625. */
  53626. private _bloomThreshold;
  53627. private _hdr;
  53628. /**
  53629. * The strength of the bloom.
  53630. */
  53631. bloomWeight: number;
  53632. /**
  53633. * The strength of the bloom.
  53634. */
  53635. bloomThreshold: number;
  53636. /**
  53637. * The scale of the bloom, lower value will provide better performance.
  53638. */
  53639. bloomScale: number;
  53640. /**
  53641. * Enable or disable the bloom from the pipeline
  53642. */
  53643. bloomEnabled: boolean;
  53644. private _rebuildBloom;
  53645. /**
  53646. * If the depth of field is enabled.
  53647. */
  53648. depthOfFieldEnabled: boolean;
  53649. /**
  53650. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53651. */
  53652. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53653. /**
  53654. * If the anti aliasing is enabled.
  53655. */
  53656. fxaaEnabled: boolean;
  53657. private _samples;
  53658. /**
  53659. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53660. */
  53661. samples: number;
  53662. /**
  53663. * If image processing is enabled.
  53664. */
  53665. imageProcessingEnabled: boolean;
  53666. /**
  53667. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53668. */
  53669. glowLayerEnabled: boolean;
  53670. /**
  53671. * Gets the glow layer (or null if not defined)
  53672. */
  53673. readonly glowLayer: Nullable<GlowLayer>;
  53674. /**
  53675. * Enable or disable the chromaticAberration process from the pipeline
  53676. */
  53677. chromaticAberrationEnabled: boolean;
  53678. /**
  53679. * Enable or disable the grain process from the pipeline
  53680. */
  53681. grainEnabled: boolean;
  53682. /**
  53683. * @constructor
  53684. * @param name - The rendering pipeline name (default: "")
  53685. * @param hdr - If high dynamic range textures should be used (default: true)
  53686. * @param scene - The scene linked to this pipeline (default: the last created scene)
  53687. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  53688. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  53689. */
  53690. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  53691. /**
  53692. * Get the class name
  53693. * @returns "DefaultRenderingPipeline"
  53694. */
  53695. getClassName(): string;
  53696. /**
  53697. * Force the compilation of the entire pipeline.
  53698. */
  53699. prepare(): void;
  53700. private _hasCleared;
  53701. private _prevPostProcess;
  53702. private _prevPrevPostProcess;
  53703. private _setAutoClearAndTextureSharing;
  53704. private _depthOfFieldSceneObserver;
  53705. private _buildPipeline;
  53706. private _disposePostProcesses;
  53707. /**
  53708. * Adds a camera to the pipeline
  53709. * @param camera the camera to be added
  53710. */
  53711. addCamera(camera: Camera): void;
  53712. /**
  53713. * Removes a camera from the pipeline
  53714. * @param camera the camera to remove
  53715. */
  53716. removeCamera(camera: Camera): void;
  53717. /**
  53718. * Dispose of the pipeline and stop all post processes
  53719. */
  53720. dispose(): void;
  53721. /**
  53722. * Serialize the rendering pipeline (Used when exporting)
  53723. * @returns the serialized object
  53724. */
  53725. serialize(): any;
  53726. /**
  53727. * Parse the serialized pipeline
  53728. * @param source Source pipeline.
  53729. * @param scene The scene to load the pipeline to.
  53730. * @param rootUrl The URL of the serialized pipeline.
  53731. * @returns An instantiated pipeline from the serialized object.
  53732. */
  53733. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  53734. }
  53735. }
  53736. declare module BABYLON {
  53737. /** @hidden */
  53738. export var lensHighlightsPixelShader: {
  53739. name: string;
  53740. shader: string;
  53741. };
  53742. }
  53743. declare module BABYLON {
  53744. /** @hidden */
  53745. export var depthOfFieldPixelShader: {
  53746. name: string;
  53747. shader: string;
  53748. };
  53749. }
  53750. declare module BABYLON {
  53751. /**
  53752. * BABYLON.JS Chromatic Aberration GLSL Shader
  53753. * Author: Olivier Guyot
  53754. * Separates very slightly R, G and B colors on the edges of the screen
  53755. * Inspired by Francois Tarlier & Martins Upitis
  53756. */
  53757. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  53758. /**
  53759. * @ignore
  53760. * The chromatic aberration PostProcess id in the pipeline
  53761. */
  53762. LensChromaticAberrationEffect: string;
  53763. /**
  53764. * @ignore
  53765. * The highlights enhancing PostProcess id in the pipeline
  53766. */
  53767. HighlightsEnhancingEffect: string;
  53768. /**
  53769. * @ignore
  53770. * The depth-of-field PostProcess id in the pipeline
  53771. */
  53772. LensDepthOfFieldEffect: string;
  53773. private _scene;
  53774. private _depthTexture;
  53775. private _grainTexture;
  53776. private _chromaticAberrationPostProcess;
  53777. private _highlightsPostProcess;
  53778. private _depthOfFieldPostProcess;
  53779. private _edgeBlur;
  53780. private _grainAmount;
  53781. private _chromaticAberration;
  53782. private _distortion;
  53783. private _highlightsGain;
  53784. private _highlightsThreshold;
  53785. private _dofDistance;
  53786. private _dofAperture;
  53787. private _dofDarken;
  53788. private _dofPentagon;
  53789. private _blurNoise;
  53790. /**
  53791. * @constructor
  53792. *
  53793. * Effect parameters are as follow:
  53794. * {
  53795. * chromatic_aberration: number; // from 0 to x (1 for realism)
  53796. * edge_blur: number; // from 0 to x (1 for realism)
  53797. * distortion: number; // from 0 to x (1 for realism)
  53798. * grain_amount: number; // from 0 to 1
  53799. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  53800. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  53801. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  53802. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  53803. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  53804. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  53805. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  53806. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  53807. * }
  53808. * Note: if an effect parameter is unset, effect is disabled
  53809. *
  53810. * @param name The rendering pipeline name
  53811. * @param parameters - An object containing all parameters (see above)
  53812. * @param scene The scene linked to this pipeline
  53813. * @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)
  53814. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53815. */
  53816. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  53817. /**
  53818. * Get the class name
  53819. * @returns "LensRenderingPipeline"
  53820. */
  53821. getClassName(): string;
  53822. /**
  53823. * Gets associated scene
  53824. */
  53825. readonly scene: Scene;
  53826. /**
  53827. * Gets or sets the edge blur
  53828. */
  53829. edgeBlur: number;
  53830. /**
  53831. * Gets or sets the grain amount
  53832. */
  53833. grainAmount: number;
  53834. /**
  53835. * Gets or sets the chromatic aberration amount
  53836. */
  53837. chromaticAberration: number;
  53838. /**
  53839. * Gets or sets the depth of field aperture
  53840. */
  53841. dofAperture: number;
  53842. /**
  53843. * Gets or sets the edge distortion
  53844. */
  53845. edgeDistortion: number;
  53846. /**
  53847. * Gets or sets the depth of field distortion
  53848. */
  53849. dofDistortion: number;
  53850. /**
  53851. * Gets or sets the darken out of focus amount
  53852. */
  53853. darkenOutOfFocus: number;
  53854. /**
  53855. * Gets or sets a boolean indicating if blur noise is enabled
  53856. */
  53857. blurNoise: boolean;
  53858. /**
  53859. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  53860. */
  53861. pentagonBokeh: boolean;
  53862. /**
  53863. * Gets or sets the highlight grain amount
  53864. */
  53865. highlightsGain: number;
  53866. /**
  53867. * Gets or sets the highlight threshold
  53868. */
  53869. highlightsThreshold: number;
  53870. /**
  53871. * Sets the amount of blur at the edges
  53872. * @param amount blur amount
  53873. */
  53874. setEdgeBlur(amount: number): void;
  53875. /**
  53876. * Sets edge blur to 0
  53877. */
  53878. disableEdgeBlur(): void;
  53879. /**
  53880. * Sets the amout of grain
  53881. * @param amount Amount of grain
  53882. */
  53883. setGrainAmount(amount: number): void;
  53884. /**
  53885. * Set grain amount to 0
  53886. */
  53887. disableGrain(): void;
  53888. /**
  53889. * Sets the chromatic aberration amount
  53890. * @param amount amount of chromatic aberration
  53891. */
  53892. setChromaticAberration(amount: number): void;
  53893. /**
  53894. * Sets chromatic aberration amount to 0
  53895. */
  53896. disableChromaticAberration(): void;
  53897. /**
  53898. * Sets the EdgeDistortion amount
  53899. * @param amount amount of EdgeDistortion
  53900. */
  53901. setEdgeDistortion(amount: number): void;
  53902. /**
  53903. * Sets edge distortion to 0
  53904. */
  53905. disableEdgeDistortion(): void;
  53906. /**
  53907. * Sets the FocusDistance amount
  53908. * @param amount amount of FocusDistance
  53909. */
  53910. setFocusDistance(amount: number): void;
  53911. /**
  53912. * Disables depth of field
  53913. */
  53914. disableDepthOfField(): void;
  53915. /**
  53916. * Sets the Aperture amount
  53917. * @param amount amount of Aperture
  53918. */
  53919. setAperture(amount: number): void;
  53920. /**
  53921. * Sets the DarkenOutOfFocus amount
  53922. * @param amount amount of DarkenOutOfFocus
  53923. */
  53924. setDarkenOutOfFocus(amount: number): void;
  53925. private _pentagonBokehIsEnabled;
  53926. /**
  53927. * Creates a pentagon bokeh effect
  53928. */
  53929. enablePentagonBokeh(): void;
  53930. /**
  53931. * Disables the pentagon bokeh effect
  53932. */
  53933. disablePentagonBokeh(): void;
  53934. /**
  53935. * Enables noise blur
  53936. */
  53937. enableNoiseBlur(): void;
  53938. /**
  53939. * Disables noise blur
  53940. */
  53941. disableNoiseBlur(): void;
  53942. /**
  53943. * Sets the HighlightsGain amount
  53944. * @param amount amount of HighlightsGain
  53945. */
  53946. setHighlightsGain(amount: number): void;
  53947. /**
  53948. * Sets the HighlightsThreshold amount
  53949. * @param amount amount of HighlightsThreshold
  53950. */
  53951. setHighlightsThreshold(amount: number): void;
  53952. /**
  53953. * Disables highlights
  53954. */
  53955. disableHighlights(): void;
  53956. /**
  53957. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53958. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53959. */
  53960. dispose(disableDepthRender?: boolean): void;
  53961. private _createChromaticAberrationPostProcess;
  53962. private _createHighlightsPostProcess;
  53963. private _createDepthOfFieldPostProcess;
  53964. private _createGrainTexture;
  53965. }
  53966. }
  53967. declare module BABYLON {
  53968. /** @hidden */
  53969. export var ssao2PixelShader: {
  53970. name: string;
  53971. shader: string;
  53972. };
  53973. }
  53974. declare module BABYLON {
  53975. /** @hidden */
  53976. export var ssaoCombinePixelShader: {
  53977. name: string;
  53978. shader: string;
  53979. };
  53980. }
  53981. declare module BABYLON {
  53982. /**
  53983. * Render pipeline to produce ssao effect
  53984. */
  53985. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53986. /**
  53987. * @ignore
  53988. * The PassPostProcess id in the pipeline that contains the original scene color
  53989. */
  53990. SSAOOriginalSceneColorEffect: string;
  53991. /**
  53992. * @ignore
  53993. * The SSAO PostProcess id in the pipeline
  53994. */
  53995. SSAORenderEffect: string;
  53996. /**
  53997. * @ignore
  53998. * The horizontal blur PostProcess id in the pipeline
  53999. */
  54000. SSAOBlurHRenderEffect: string;
  54001. /**
  54002. * @ignore
  54003. * The vertical blur PostProcess id in the pipeline
  54004. */
  54005. SSAOBlurVRenderEffect: string;
  54006. /**
  54007. * @ignore
  54008. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54009. */
  54010. SSAOCombineRenderEffect: string;
  54011. /**
  54012. * The output strength of the SSAO post-process. Default value is 1.0.
  54013. */
  54014. totalStrength: number;
  54015. /**
  54016. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  54017. */
  54018. maxZ: number;
  54019. /**
  54020. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  54021. */
  54022. minZAspect: number;
  54023. private _samples;
  54024. /**
  54025. * Number of samples used for the SSAO calculations. Default value is 8
  54026. */
  54027. samples: number;
  54028. private _textureSamples;
  54029. /**
  54030. * Number of samples to use for antialiasing
  54031. */
  54032. textureSamples: number;
  54033. /**
  54034. * Ratio object used for SSAO ratio and blur ratio
  54035. */
  54036. private _ratio;
  54037. /**
  54038. * Dynamically generated sphere sampler.
  54039. */
  54040. private _sampleSphere;
  54041. /**
  54042. * Blur filter offsets
  54043. */
  54044. private _samplerOffsets;
  54045. private _expensiveBlur;
  54046. /**
  54047. * If bilateral blur should be used
  54048. */
  54049. expensiveBlur: boolean;
  54050. /**
  54051. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54052. */
  54053. radius: number;
  54054. /**
  54055. * The base color of the SSAO post-process
  54056. * The final result is "base + ssao" between [0, 1]
  54057. */
  54058. base: number;
  54059. /**
  54060. * Support test.
  54061. */
  54062. static readonly IsSupported: boolean;
  54063. private _scene;
  54064. private _depthTexture;
  54065. private _normalTexture;
  54066. private _randomTexture;
  54067. private _originalColorPostProcess;
  54068. private _ssaoPostProcess;
  54069. private _blurHPostProcess;
  54070. private _blurVPostProcess;
  54071. private _ssaoCombinePostProcess;
  54072. private _firstUpdate;
  54073. /**
  54074. * Gets active scene
  54075. */
  54076. readonly scene: Scene;
  54077. /**
  54078. * @constructor
  54079. * @param name The rendering pipeline name
  54080. * @param scene The scene linked to this pipeline
  54081. * @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 }
  54082. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54083. */
  54084. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54085. /**
  54086. * Get the class name
  54087. * @returns "SSAO2RenderingPipeline"
  54088. */
  54089. getClassName(): string;
  54090. /**
  54091. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54092. */
  54093. dispose(disableGeometryBufferRenderer?: boolean): void;
  54094. private _createBlurPostProcess;
  54095. /** @hidden */
  54096. _rebuild(): void;
  54097. private _bits;
  54098. private _radicalInverse_VdC;
  54099. private _hammersley;
  54100. private _hemisphereSample_uniform;
  54101. private _generateHemisphere;
  54102. private _createSSAOPostProcess;
  54103. private _createSSAOCombinePostProcess;
  54104. private _createRandomTexture;
  54105. /**
  54106. * Serialize the rendering pipeline (Used when exporting)
  54107. * @returns the serialized object
  54108. */
  54109. serialize(): any;
  54110. /**
  54111. * Parse the serialized pipeline
  54112. * @param source Source pipeline.
  54113. * @param scene The scene to load the pipeline to.
  54114. * @param rootUrl The URL of the serialized pipeline.
  54115. * @returns An instantiated pipeline from the serialized object.
  54116. */
  54117. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54118. }
  54119. }
  54120. declare module BABYLON {
  54121. /** @hidden */
  54122. export var ssaoPixelShader: {
  54123. name: string;
  54124. shader: string;
  54125. };
  54126. }
  54127. declare module BABYLON {
  54128. /**
  54129. * Render pipeline to produce ssao effect
  54130. */
  54131. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54132. /**
  54133. * @ignore
  54134. * The PassPostProcess id in the pipeline that contains the original scene color
  54135. */
  54136. SSAOOriginalSceneColorEffect: string;
  54137. /**
  54138. * @ignore
  54139. * The SSAO PostProcess id in the pipeline
  54140. */
  54141. SSAORenderEffect: string;
  54142. /**
  54143. * @ignore
  54144. * The horizontal blur PostProcess id in the pipeline
  54145. */
  54146. SSAOBlurHRenderEffect: string;
  54147. /**
  54148. * @ignore
  54149. * The vertical blur PostProcess id in the pipeline
  54150. */
  54151. SSAOBlurVRenderEffect: string;
  54152. /**
  54153. * @ignore
  54154. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54155. */
  54156. SSAOCombineRenderEffect: string;
  54157. /**
  54158. * The output strength of the SSAO post-process. Default value is 1.0.
  54159. */
  54160. totalStrength: number;
  54161. /**
  54162. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54163. */
  54164. radius: number;
  54165. /**
  54166. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54167. * Must not be equal to fallOff and superior to fallOff.
  54168. * Default value is 0.0075
  54169. */
  54170. area: number;
  54171. /**
  54172. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54173. * Must not be equal to area and inferior to area.
  54174. * Default value is 0.000001
  54175. */
  54176. fallOff: number;
  54177. /**
  54178. * The base color of the SSAO post-process
  54179. * The final result is "base + ssao" between [0, 1]
  54180. */
  54181. base: number;
  54182. private _scene;
  54183. private _depthTexture;
  54184. private _randomTexture;
  54185. private _originalColorPostProcess;
  54186. private _ssaoPostProcess;
  54187. private _blurHPostProcess;
  54188. private _blurVPostProcess;
  54189. private _ssaoCombinePostProcess;
  54190. private _firstUpdate;
  54191. /**
  54192. * Gets active scene
  54193. */
  54194. readonly scene: Scene;
  54195. /**
  54196. * @constructor
  54197. * @param name - The rendering pipeline name
  54198. * @param scene - The scene linked to this pipeline
  54199. * @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 }
  54200. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54201. */
  54202. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54203. /**
  54204. * Get the class name
  54205. * @returns "SSAORenderingPipeline"
  54206. */
  54207. getClassName(): string;
  54208. /**
  54209. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54210. */
  54211. dispose(disableDepthRender?: boolean): void;
  54212. private _createBlurPostProcess;
  54213. /** @hidden */
  54214. _rebuild(): void;
  54215. private _createSSAOPostProcess;
  54216. private _createSSAOCombinePostProcess;
  54217. private _createRandomTexture;
  54218. }
  54219. }
  54220. declare module BABYLON {
  54221. /** @hidden */
  54222. export var standardPixelShader: {
  54223. name: string;
  54224. shader: string;
  54225. };
  54226. }
  54227. declare module BABYLON {
  54228. /**
  54229. * Standard rendering pipeline
  54230. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54231. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54232. */
  54233. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54234. /**
  54235. * Public members
  54236. */
  54237. /**
  54238. * Post-process which contains the original scene color before the pipeline applies all the effects
  54239. */
  54240. originalPostProcess: Nullable<PostProcess>;
  54241. /**
  54242. * Post-process used to down scale an image x4
  54243. */
  54244. downSampleX4PostProcess: Nullable<PostProcess>;
  54245. /**
  54246. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54247. */
  54248. brightPassPostProcess: Nullable<PostProcess>;
  54249. /**
  54250. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54251. */
  54252. blurHPostProcesses: PostProcess[];
  54253. /**
  54254. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54255. */
  54256. blurVPostProcesses: PostProcess[];
  54257. /**
  54258. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54259. */
  54260. textureAdderPostProcess: Nullable<PostProcess>;
  54261. /**
  54262. * Post-process used to create volumetric lighting effect
  54263. */
  54264. volumetricLightPostProcess: Nullable<PostProcess>;
  54265. /**
  54266. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54267. */
  54268. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54269. /**
  54270. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54271. */
  54272. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54273. /**
  54274. * Post-process used to merge the volumetric light effect and the real scene color
  54275. */
  54276. volumetricLightMergePostProces: Nullable<PostProcess>;
  54277. /**
  54278. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54279. */
  54280. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54281. /**
  54282. * Base post-process used to calculate the average luminance of the final image for HDR
  54283. */
  54284. luminancePostProcess: Nullable<PostProcess>;
  54285. /**
  54286. * Post-processes used to create down sample post-processes in order to get
  54287. * the average luminance of the final image for HDR
  54288. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54289. */
  54290. luminanceDownSamplePostProcesses: PostProcess[];
  54291. /**
  54292. * Post-process used to create a HDR effect (light adaptation)
  54293. */
  54294. hdrPostProcess: Nullable<PostProcess>;
  54295. /**
  54296. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54297. */
  54298. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54299. /**
  54300. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54301. */
  54302. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54303. /**
  54304. * Post-process used to merge the final HDR post-process and the real scene color
  54305. */
  54306. hdrFinalPostProcess: Nullable<PostProcess>;
  54307. /**
  54308. * Post-process used to create a lens flare effect
  54309. */
  54310. lensFlarePostProcess: Nullable<PostProcess>;
  54311. /**
  54312. * Post-process that merges the result of the lens flare post-process and the real scene color
  54313. */
  54314. lensFlareComposePostProcess: Nullable<PostProcess>;
  54315. /**
  54316. * Post-process used to create a motion blur effect
  54317. */
  54318. motionBlurPostProcess: Nullable<PostProcess>;
  54319. /**
  54320. * Post-process used to create a depth of field effect
  54321. */
  54322. depthOfFieldPostProcess: Nullable<PostProcess>;
  54323. /**
  54324. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54325. */
  54326. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54327. /**
  54328. * Represents the brightness threshold in order to configure the illuminated surfaces
  54329. */
  54330. brightThreshold: number;
  54331. /**
  54332. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54333. */
  54334. blurWidth: number;
  54335. /**
  54336. * Sets if the blur for highlighted surfaces must be only horizontal
  54337. */
  54338. horizontalBlur: boolean;
  54339. /**
  54340. * Gets the overall exposure used by the pipeline
  54341. */
  54342. /**
  54343. * Sets the overall exposure used by the pipeline
  54344. */
  54345. exposure: number;
  54346. /**
  54347. * Texture used typically to simulate "dirty" on camera lens
  54348. */
  54349. lensTexture: Nullable<Texture>;
  54350. /**
  54351. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54352. */
  54353. volumetricLightCoefficient: number;
  54354. /**
  54355. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54356. */
  54357. volumetricLightPower: number;
  54358. /**
  54359. * Used the set the blur intensity to smooth the volumetric lights
  54360. */
  54361. volumetricLightBlurScale: number;
  54362. /**
  54363. * Light (spot or directional) used to generate the volumetric lights rays
  54364. * The source light must have a shadow generate so the pipeline can get its
  54365. * depth map
  54366. */
  54367. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54368. /**
  54369. * For eye adaptation, represents the minimum luminance the eye can see
  54370. */
  54371. hdrMinimumLuminance: number;
  54372. /**
  54373. * For eye adaptation, represents the decrease luminance speed
  54374. */
  54375. hdrDecreaseRate: number;
  54376. /**
  54377. * For eye adaptation, represents the increase luminance speed
  54378. */
  54379. hdrIncreaseRate: number;
  54380. /**
  54381. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  54382. */
  54383. /**
  54384. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  54385. */
  54386. hdrAutoExposure: boolean;
  54387. /**
  54388. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54389. */
  54390. lensColorTexture: Nullable<Texture>;
  54391. /**
  54392. * The overall strengh for the lens flare effect
  54393. */
  54394. lensFlareStrength: number;
  54395. /**
  54396. * Dispersion coefficient for lens flare ghosts
  54397. */
  54398. lensFlareGhostDispersal: number;
  54399. /**
  54400. * Main lens flare halo width
  54401. */
  54402. lensFlareHaloWidth: number;
  54403. /**
  54404. * Based on the lens distortion effect, defines how much the lens flare result
  54405. * is distorted
  54406. */
  54407. lensFlareDistortionStrength: number;
  54408. /**
  54409. * Lens star texture must be used to simulate rays on the flares and is available
  54410. * in the documentation
  54411. */
  54412. lensStarTexture: Nullable<Texture>;
  54413. /**
  54414. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54415. * flare effect by taking account of the dirt texture
  54416. */
  54417. lensFlareDirtTexture: Nullable<Texture>;
  54418. /**
  54419. * Represents the focal length for the depth of field effect
  54420. */
  54421. depthOfFieldDistance: number;
  54422. /**
  54423. * Represents the blur intensity for the blurred part of the depth of field effect
  54424. */
  54425. depthOfFieldBlurWidth: number;
  54426. /**
  54427. * For motion blur, defines how much the image is blurred by the movement
  54428. */
  54429. motionStrength: number;
  54430. /**
  54431. * List of animations for the pipeline (IAnimatable implementation)
  54432. */
  54433. animations: Animation[];
  54434. /**
  54435. * Private members
  54436. */
  54437. private _scene;
  54438. private _currentDepthOfFieldSource;
  54439. private _basePostProcess;
  54440. private _fixedExposure;
  54441. private _currentExposure;
  54442. private _hdrAutoExposure;
  54443. private _hdrCurrentLuminance;
  54444. private _floatTextureType;
  54445. private _ratio;
  54446. private _bloomEnabled;
  54447. private _depthOfFieldEnabled;
  54448. private _vlsEnabled;
  54449. private _lensFlareEnabled;
  54450. private _hdrEnabled;
  54451. private _motionBlurEnabled;
  54452. private _fxaaEnabled;
  54453. private _motionBlurSamples;
  54454. private _volumetricLightStepsCount;
  54455. private _samples;
  54456. /**
  54457. * @ignore
  54458. * Specifies if the bloom pipeline is enabled
  54459. */
  54460. BloomEnabled: boolean;
  54461. /**
  54462. * @ignore
  54463. * Specifies if the depth of field pipeline is enabed
  54464. */
  54465. DepthOfFieldEnabled: boolean;
  54466. /**
  54467. * @ignore
  54468. * Specifies if the lens flare pipeline is enabed
  54469. */
  54470. LensFlareEnabled: boolean;
  54471. /**
  54472. * @ignore
  54473. * Specifies if the HDR pipeline is enabled
  54474. */
  54475. HDREnabled: boolean;
  54476. /**
  54477. * @ignore
  54478. * Specifies if the volumetric lights scattering effect is enabled
  54479. */
  54480. VLSEnabled: boolean;
  54481. /**
  54482. * @ignore
  54483. * Specifies if the motion blur effect is enabled
  54484. */
  54485. MotionBlurEnabled: boolean;
  54486. /**
  54487. * Specifies if anti-aliasing is enabled
  54488. */
  54489. fxaaEnabled: boolean;
  54490. /**
  54491. * Specifies the number of steps used to calculate the volumetric lights
  54492. * Typically in interval [50, 200]
  54493. */
  54494. volumetricLightStepsCount: number;
  54495. /**
  54496. * Specifies the number of samples used for the motion blur effect
  54497. * Typically in interval [16, 64]
  54498. */
  54499. motionBlurSamples: number;
  54500. /**
  54501. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54502. */
  54503. samples: number;
  54504. /**
  54505. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54506. * @constructor
  54507. * @param name The rendering pipeline name
  54508. * @param scene The scene linked to this pipeline
  54509. * @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)
  54510. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54511. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54512. */
  54513. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54514. private _buildPipeline;
  54515. private _createDownSampleX4PostProcess;
  54516. private _createBrightPassPostProcess;
  54517. private _createBlurPostProcesses;
  54518. private _createTextureAdderPostProcess;
  54519. private _createVolumetricLightPostProcess;
  54520. private _createLuminancePostProcesses;
  54521. private _createHdrPostProcess;
  54522. private _createLensFlarePostProcess;
  54523. private _createDepthOfFieldPostProcess;
  54524. private _createMotionBlurPostProcess;
  54525. private _getDepthTexture;
  54526. private _disposePostProcesses;
  54527. /**
  54528. * Dispose of the pipeline and stop all post processes
  54529. */
  54530. dispose(): void;
  54531. /**
  54532. * Serialize the rendering pipeline (Used when exporting)
  54533. * @returns the serialized object
  54534. */
  54535. serialize(): any;
  54536. /**
  54537. * Parse the serialized pipeline
  54538. * @param source Source pipeline.
  54539. * @param scene The scene to load the pipeline to.
  54540. * @param rootUrl The URL of the serialized pipeline.
  54541. * @returns An instantiated pipeline from the serialized object.
  54542. */
  54543. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54544. /**
  54545. * Luminance steps
  54546. */
  54547. static LuminanceSteps: number;
  54548. }
  54549. }
  54550. declare module BABYLON {
  54551. /** @hidden */
  54552. export var tonemapPixelShader: {
  54553. name: string;
  54554. shader: string;
  54555. };
  54556. }
  54557. declare module BABYLON {
  54558. /** Defines operator used for tonemapping */
  54559. export enum TonemappingOperator {
  54560. /** Hable */
  54561. Hable = 0,
  54562. /** Reinhard */
  54563. Reinhard = 1,
  54564. /** HejiDawson */
  54565. HejiDawson = 2,
  54566. /** Photographic */
  54567. Photographic = 3
  54568. }
  54569. /**
  54570. * Defines a post process to apply tone mapping
  54571. */
  54572. export class TonemapPostProcess extends PostProcess {
  54573. private _operator;
  54574. /** Defines the required exposure adjustement */
  54575. exposureAdjustment: number;
  54576. /**
  54577. * Creates a new TonemapPostProcess
  54578. * @param name defines the name of the postprocess
  54579. * @param _operator defines the operator to use
  54580. * @param exposureAdjustment defines the required exposure adjustement
  54581. * @param camera defines the camera to use (can be null)
  54582. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54583. * @param engine defines the hosting engine (can be ignore if camera is set)
  54584. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54585. */
  54586. constructor(name: string, _operator: TonemappingOperator,
  54587. /** Defines the required exposure adjustement */
  54588. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54589. }
  54590. }
  54591. declare module BABYLON {
  54592. /** @hidden */
  54593. export var depthVertexShader: {
  54594. name: string;
  54595. shader: string;
  54596. };
  54597. }
  54598. declare module BABYLON {
  54599. /** @hidden */
  54600. export var volumetricLightScatteringPixelShader: {
  54601. name: string;
  54602. shader: string;
  54603. };
  54604. }
  54605. declare module BABYLON {
  54606. /** @hidden */
  54607. export var volumetricLightScatteringPassPixelShader: {
  54608. name: string;
  54609. shader: string;
  54610. };
  54611. }
  54612. declare module BABYLON {
  54613. /**
  54614. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54615. */
  54616. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54617. private _volumetricLightScatteringPass;
  54618. private _volumetricLightScatteringRTT;
  54619. private _viewPort;
  54620. private _screenCoordinates;
  54621. private _cachedDefines;
  54622. /**
  54623. * If not undefined, the mesh position is computed from the attached node position
  54624. */
  54625. attachedNode: {
  54626. position: Vector3;
  54627. };
  54628. /**
  54629. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54630. */
  54631. customMeshPosition: Vector3;
  54632. /**
  54633. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54634. */
  54635. useCustomMeshPosition: boolean;
  54636. /**
  54637. * If the post-process should inverse the light scattering direction
  54638. */
  54639. invert: boolean;
  54640. /**
  54641. * The internal mesh used by the post-process
  54642. */
  54643. mesh: Mesh;
  54644. /**
  54645. * @hidden
  54646. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54647. */
  54648. useDiffuseColor: boolean;
  54649. /**
  54650. * Array containing the excluded meshes not rendered in the internal pass
  54651. */
  54652. excludedMeshes: AbstractMesh[];
  54653. /**
  54654. * Controls the overall intensity of the post-process
  54655. */
  54656. exposure: number;
  54657. /**
  54658. * Dissipates each sample's contribution in range [0, 1]
  54659. */
  54660. decay: number;
  54661. /**
  54662. * Controls the overall intensity of each sample
  54663. */
  54664. weight: number;
  54665. /**
  54666. * Controls the density of each sample
  54667. */
  54668. density: number;
  54669. /**
  54670. * @constructor
  54671. * @param name The post-process name
  54672. * @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)
  54673. * @param camera The camera that the post-process will be attached to
  54674. * @param mesh The mesh used to create the light scattering
  54675. * @param samples The post-process quality, default 100
  54676. * @param samplingModeThe post-process filtering mode
  54677. * @param engine The babylon engine
  54678. * @param reusable If the post-process is reusable
  54679. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  54680. */
  54681. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  54682. /**
  54683. * Returns the string "VolumetricLightScatteringPostProcess"
  54684. * @returns "VolumetricLightScatteringPostProcess"
  54685. */
  54686. getClassName(): string;
  54687. private _isReady;
  54688. /**
  54689. * Sets the new light position for light scattering effect
  54690. * @param position The new custom light position
  54691. */
  54692. setCustomMeshPosition(position: Vector3): void;
  54693. /**
  54694. * Returns the light position for light scattering effect
  54695. * @return Vector3 The custom light position
  54696. */
  54697. getCustomMeshPosition(): Vector3;
  54698. /**
  54699. * Disposes the internal assets and detaches the post-process from the camera
  54700. */
  54701. dispose(camera: Camera): void;
  54702. /**
  54703. * Returns the render target texture used by the post-process
  54704. * @return the render target texture used by the post-process
  54705. */
  54706. getPass(): RenderTargetTexture;
  54707. private _meshExcluded;
  54708. private _createPass;
  54709. private _updateMeshScreenCoordinates;
  54710. /**
  54711. * Creates a default mesh for the Volumeric Light Scattering post-process
  54712. * @param name The mesh name
  54713. * @param scene The scene where to create the mesh
  54714. * @return the default mesh
  54715. */
  54716. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  54717. }
  54718. }
  54719. declare module BABYLON {
  54720. interface Scene {
  54721. /** @hidden (Backing field) */
  54722. _boundingBoxRenderer: BoundingBoxRenderer;
  54723. /** @hidden (Backing field) */
  54724. _forceShowBoundingBoxes: boolean;
  54725. /**
  54726. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  54727. */
  54728. forceShowBoundingBoxes: boolean;
  54729. /**
  54730. * Gets the bounding box renderer associated with the scene
  54731. * @returns a BoundingBoxRenderer
  54732. */
  54733. getBoundingBoxRenderer(): BoundingBoxRenderer;
  54734. }
  54735. interface AbstractMesh {
  54736. /** @hidden (Backing field) */
  54737. _showBoundingBox: boolean;
  54738. /**
  54739. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  54740. */
  54741. showBoundingBox: boolean;
  54742. }
  54743. /**
  54744. * Component responsible of rendering the bounding box of the meshes in a scene.
  54745. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  54746. */
  54747. export class BoundingBoxRenderer implements ISceneComponent {
  54748. /**
  54749. * The component name helpfull to identify the component in the list of scene components.
  54750. */
  54751. readonly name: string;
  54752. /**
  54753. * The scene the component belongs to.
  54754. */
  54755. scene: Scene;
  54756. /**
  54757. * Color of the bounding box lines placed in front of an object
  54758. */
  54759. frontColor: Color3;
  54760. /**
  54761. * Color of the bounding box lines placed behind an object
  54762. */
  54763. backColor: Color3;
  54764. /**
  54765. * Defines if the renderer should show the back lines or not
  54766. */
  54767. showBackLines: boolean;
  54768. /**
  54769. * @hidden
  54770. */
  54771. renderList: SmartArray<BoundingBox>;
  54772. private _colorShader;
  54773. private _vertexBuffers;
  54774. private _indexBuffer;
  54775. /**
  54776. * Instantiates a new bounding box renderer in a scene.
  54777. * @param scene the scene the renderer renders in
  54778. */
  54779. constructor(scene: Scene);
  54780. /**
  54781. * Registers the component in a given scene
  54782. */
  54783. register(): void;
  54784. private _evaluateSubMesh;
  54785. private _activeMesh;
  54786. private _prepareRessources;
  54787. private _createIndexBuffer;
  54788. /**
  54789. * Rebuilds the elements related to this component in case of
  54790. * context lost for instance.
  54791. */
  54792. rebuild(): void;
  54793. /**
  54794. * @hidden
  54795. */
  54796. reset(): void;
  54797. /**
  54798. * Render the bounding boxes of a specific rendering group
  54799. * @param renderingGroupId defines the rendering group to render
  54800. */
  54801. render(renderingGroupId: number): void;
  54802. /**
  54803. * In case of occlusion queries, we can render the occlusion bounding box through this method
  54804. * @param mesh Define the mesh to render the occlusion bounding box for
  54805. */
  54806. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  54807. /**
  54808. * Dispose and release the resources attached to this renderer.
  54809. */
  54810. dispose(): void;
  54811. }
  54812. }
  54813. declare module BABYLON {
  54814. /** @hidden */
  54815. export var depthPixelShader: {
  54816. name: string;
  54817. shader: string;
  54818. };
  54819. }
  54820. declare module BABYLON {
  54821. /**
  54822. * This represents a depth renderer in Babylon.
  54823. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54824. */
  54825. export class DepthRenderer {
  54826. private _scene;
  54827. private _depthMap;
  54828. private _effect;
  54829. private _cachedDefines;
  54830. private _camera;
  54831. /**
  54832. * Specifiess that the depth renderer will only be used within
  54833. * the camera it is created for.
  54834. * This can help forcing its rendering during the camera processing.
  54835. */
  54836. useOnlyInActiveCamera: boolean;
  54837. /** @hidden */
  54838. static _SceneComponentInitialization: (scene: Scene) => void;
  54839. /**
  54840. * Instantiates a depth renderer
  54841. * @param scene The scene the renderer belongs to
  54842. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54843. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54844. */
  54845. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54846. /**
  54847. * Creates the depth rendering effect and checks if the effect is ready.
  54848. * @param subMesh The submesh to be used to render the depth map of
  54849. * @param useInstances If multiple world instances should be used
  54850. * @returns if the depth renderer is ready to render the depth map
  54851. */
  54852. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54853. /**
  54854. * Gets the texture which the depth map will be written to.
  54855. * @returns The depth map texture
  54856. */
  54857. getDepthMap(): RenderTargetTexture;
  54858. /**
  54859. * Disposes of the depth renderer.
  54860. */
  54861. dispose(): void;
  54862. }
  54863. }
  54864. declare module BABYLON {
  54865. interface Scene {
  54866. /** @hidden (Backing field) */
  54867. _depthRenderer: {
  54868. [id: string]: DepthRenderer;
  54869. };
  54870. /**
  54871. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54872. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54873. * @returns the created depth renderer
  54874. */
  54875. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54876. /**
  54877. * Disables a depth renderer for a given camera
  54878. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54879. */
  54880. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54881. }
  54882. /**
  54883. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54884. * in several rendering techniques.
  54885. */
  54886. export class DepthRendererSceneComponent implements ISceneComponent {
  54887. /**
  54888. * The component name helpfull to identify the component in the list of scene components.
  54889. */
  54890. readonly name: string;
  54891. /**
  54892. * The scene the component belongs to.
  54893. */
  54894. scene: Scene;
  54895. /**
  54896. * Creates a new instance of the component for the given scene
  54897. * @param scene Defines the scene to register the component in
  54898. */
  54899. constructor(scene: Scene);
  54900. /**
  54901. * Registers the component in a given scene
  54902. */
  54903. register(): void;
  54904. /**
  54905. * Rebuilds the elements related to this component in case of
  54906. * context lost for instance.
  54907. */
  54908. rebuild(): void;
  54909. /**
  54910. * Disposes the component and the associated ressources
  54911. */
  54912. dispose(): void;
  54913. private _gatherRenderTargets;
  54914. private _gatherActiveCameraRenderTargets;
  54915. }
  54916. }
  54917. declare module BABYLON {
  54918. /** @hidden */
  54919. export var outlinePixelShader: {
  54920. name: string;
  54921. shader: string;
  54922. };
  54923. }
  54924. declare module BABYLON {
  54925. /** @hidden */
  54926. export var outlineVertexShader: {
  54927. name: string;
  54928. shader: string;
  54929. };
  54930. }
  54931. declare module BABYLON {
  54932. interface Scene {
  54933. /** @hidden */
  54934. _outlineRenderer: OutlineRenderer;
  54935. /**
  54936. * Gets the outline renderer associated with the scene
  54937. * @returns a OutlineRenderer
  54938. */
  54939. getOutlineRenderer(): OutlineRenderer;
  54940. }
  54941. interface AbstractMesh {
  54942. /** @hidden (Backing field) */
  54943. _renderOutline: boolean;
  54944. /**
  54945. * Gets or sets a boolean indicating if the outline must be rendered as well
  54946. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54947. */
  54948. renderOutline: boolean;
  54949. /** @hidden (Backing field) */
  54950. _renderOverlay: boolean;
  54951. /**
  54952. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54953. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54954. */
  54955. renderOverlay: boolean;
  54956. }
  54957. /**
  54958. * This class is responsible to draw bothe outline/overlay of meshes.
  54959. * It should not be used directly but through the available method on mesh.
  54960. */
  54961. export class OutlineRenderer implements ISceneComponent {
  54962. /**
  54963. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  54964. */
  54965. private static _StencilReference;
  54966. /**
  54967. * The name of the component. Each component must have a unique name.
  54968. */
  54969. name: string;
  54970. /**
  54971. * The scene the component belongs to.
  54972. */
  54973. scene: Scene;
  54974. /**
  54975. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54976. */
  54977. zOffset: number;
  54978. private _engine;
  54979. private _effect;
  54980. private _cachedDefines;
  54981. private _savedDepthWrite;
  54982. /**
  54983. * Instantiates a new outline renderer. (There could be only one per scene).
  54984. * @param scene Defines the scene it belongs to
  54985. */
  54986. constructor(scene: Scene);
  54987. /**
  54988. * Register the component to one instance of a scene.
  54989. */
  54990. register(): void;
  54991. /**
  54992. * Rebuilds the elements related to this component in case of
  54993. * context lost for instance.
  54994. */
  54995. rebuild(): void;
  54996. /**
  54997. * Disposes the component and the associated ressources.
  54998. */
  54999. dispose(): void;
  55000. /**
  55001. * Renders the outline in the canvas.
  55002. * @param subMesh Defines the sumesh to render
  55003. * @param batch Defines the batch of meshes in case of instances
  55004. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55005. */
  55006. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55007. /**
  55008. * Returns whether or not the outline renderer is ready for a given submesh.
  55009. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55010. * @param subMesh Defines the submesh to check readyness for
  55011. * @param useInstances Defines wheter wee are trying to render instances or not
  55012. * @returns true if ready otherwise false
  55013. */
  55014. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55015. private _beforeRenderingMesh;
  55016. private _afterRenderingMesh;
  55017. }
  55018. }
  55019. declare module BABYLON {
  55020. /**
  55021. * Defines the list of states available for a task inside a AssetsManager
  55022. */
  55023. export enum AssetTaskState {
  55024. /**
  55025. * Initialization
  55026. */
  55027. INIT = 0,
  55028. /**
  55029. * Running
  55030. */
  55031. RUNNING = 1,
  55032. /**
  55033. * Done
  55034. */
  55035. DONE = 2,
  55036. /**
  55037. * Error
  55038. */
  55039. ERROR = 3
  55040. }
  55041. /**
  55042. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55043. */
  55044. export abstract class AbstractAssetTask {
  55045. /**
  55046. * Task name
  55047. */ name: string;
  55048. /**
  55049. * Callback called when the task is successful
  55050. */
  55051. onSuccess: (task: any) => void;
  55052. /**
  55053. * Callback called when the task is not successful
  55054. */
  55055. onError: (task: any, message?: string, exception?: any) => void;
  55056. /**
  55057. * Creates a new AssetsManager
  55058. * @param name defines the name of the task
  55059. */
  55060. constructor(
  55061. /**
  55062. * Task name
  55063. */ name: string);
  55064. private _isCompleted;
  55065. private _taskState;
  55066. private _errorObject;
  55067. /**
  55068. * Get if the task is completed
  55069. */
  55070. readonly isCompleted: boolean;
  55071. /**
  55072. * Gets the current state of the task
  55073. */
  55074. readonly taskState: AssetTaskState;
  55075. /**
  55076. * Gets the current error object (if task is in error)
  55077. */
  55078. readonly errorObject: {
  55079. message?: string;
  55080. exception?: any;
  55081. };
  55082. /**
  55083. * Internal only
  55084. * @hidden
  55085. */
  55086. _setErrorObject(message?: string, exception?: any): void;
  55087. /**
  55088. * Execute the current task
  55089. * @param scene defines the scene where you want your assets to be loaded
  55090. * @param onSuccess is a callback called when the task is successfully executed
  55091. * @param onError is a callback called if an error occurs
  55092. */
  55093. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55094. /**
  55095. * Execute the current task
  55096. * @param scene defines the scene where you want your assets to be loaded
  55097. * @param onSuccess is a callback called when the task is successfully executed
  55098. * @param onError is a callback called if an error occurs
  55099. */
  55100. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55101. /**
  55102. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55103. * This can be used with failed tasks that have the reason for failure fixed.
  55104. */
  55105. reset(): void;
  55106. private onErrorCallback;
  55107. private onDoneCallback;
  55108. }
  55109. /**
  55110. * Define the interface used by progress events raised during assets loading
  55111. */
  55112. export interface IAssetsProgressEvent {
  55113. /**
  55114. * Defines the number of remaining tasks to process
  55115. */
  55116. remainingCount: number;
  55117. /**
  55118. * Defines the total number of tasks
  55119. */
  55120. totalCount: number;
  55121. /**
  55122. * Defines the task that was just processed
  55123. */
  55124. task: AbstractAssetTask;
  55125. }
  55126. /**
  55127. * Class used to share progress information about assets loading
  55128. */
  55129. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55130. /**
  55131. * Defines the number of remaining tasks to process
  55132. */
  55133. remainingCount: number;
  55134. /**
  55135. * Defines the total number of tasks
  55136. */
  55137. totalCount: number;
  55138. /**
  55139. * Defines the task that was just processed
  55140. */
  55141. task: AbstractAssetTask;
  55142. /**
  55143. * Creates a AssetsProgressEvent
  55144. * @param remainingCount defines the number of remaining tasks to process
  55145. * @param totalCount defines the total number of tasks
  55146. * @param task defines the task that was just processed
  55147. */
  55148. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55149. }
  55150. /**
  55151. * Define a task used by AssetsManager to load meshes
  55152. */
  55153. export class MeshAssetTask extends AbstractAssetTask {
  55154. /**
  55155. * Defines the name of the task
  55156. */
  55157. name: string;
  55158. /**
  55159. * Defines the list of mesh's names you want to load
  55160. */
  55161. meshesNames: any;
  55162. /**
  55163. * Defines the root url to use as a base to load your meshes and associated resources
  55164. */
  55165. rootUrl: string;
  55166. /**
  55167. * Defines the filename of the scene to load from
  55168. */
  55169. sceneFilename: string;
  55170. /**
  55171. * Gets the list of loaded meshes
  55172. */
  55173. loadedMeshes: Array<AbstractMesh>;
  55174. /**
  55175. * Gets the list of loaded particle systems
  55176. */
  55177. loadedParticleSystems: Array<IParticleSystem>;
  55178. /**
  55179. * Gets the list of loaded skeletons
  55180. */
  55181. loadedSkeletons: Array<Skeleton>;
  55182. /**
  55183. * Gets the list of loaded animation groups
  55184. */
  55185. loadedAnimationGroups: Array<AnimationGroup>;
  55186. /**
  55187. * Callback called when the task is successful
  55188. */
  55189. onSuccess: (task: MeshAssetTask) => void;
  55190. /**
  55191. * Callback called when the task is successful
  55192. */
  55193. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55194. /**
  55195. * Creates a new MeshAssetTask
  55196. * @param name defines the name of the task
  55197. * @param meshesNames defines the list of mesh's names you want to load
  55198. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55199. * @param sceneFilename defines the filename of the scene to load from
  55200. */
  55201. constructor(
  55202. /**
  55203. * Defines the name of the task
  55204. */
  55205. name: string,
  55206. /**
  55207. * Defines the list of mesh's names you want to load
  55208. */
  55209. meshesNames: any,
  55210. /**
  55211. * Defines the root url to use as a base to load your meshes and associated resources
  55212. */
  55213. rootUrl: string,
  55214. /**
  55215. * Defines the filename of the scene to load from
  55216. */
  55217. sceneFilename: string);
  55218. /**
  55219. * Execute the current task
  55220. * @param scene defines the scene where you want your assets to be loaded
  55221. * @param onSuccess is a callback called when the task is successfully executed
  55222. * @param onError is a callback called if an error occurs
  55223. */
  55224. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55225. }
  55226. /**
  55227. * Define a task used by AssetsManager to load text content
  55228. */
  55229. export class TextFileAssetTask extends AbstractAssetTask {
  55230. /**
  55231. * Defines the name of the task
  55232. */
  55233. name: string;
  55234. /**
  55235. * Defines the location of the file to load
  55236. */
  55237. url: string;
  55238. /**
  55239. * Gets the loaded text string
  55240. */
  55241. text: string;
  55242. /**
  55243. * Callback called when the task is successful
  55244. */
  55245. onSuccess: (task: TextFileAssetTask) => void;
  55246. /**
  55247. * Callback called when the task is successful
  55248. */
  55249. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55250. /**
  55251. * Creates a new TextFileAssetTask object
  55252. * @param name defines the name of the task
  55253. * @param url defines the location of the file to load
  55254. */
  55255. constructor(
  55256. /**
  55257. * Defines the name of the task
  55258. */
  55259. name: string,
  55260. /**
  55261. * Defines the location of the file to load
  55262. */
  55263. url: string);
  55264. /**
  55265. * Execute the current task
  55266. * @param scene defines the scene where you want your assets to be loaded
  55267. * @param onSuccess is a callback called when the task is successfully executed
  55268. * @param onError is a callback called if an error occurs
  55269. */
  55270. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55271. }
  55272. /**
  55273. * Define a task used by AssetsManager to load binary data
  55274. */
  55275. export class BinaryFileAssetTask extends AbstractAssetTask {
  55276. /**
  55277. * Defines the name of the task
  55278. */
  55279. name: string;
  55280. /**
  55281. * Defines the location of the file to load
  55282. */
  55283. url: string;
  55284. /**
  55285. * Gets the lodaded data (as an array buffer)
  55286. */
  55287. data: ArrayBuffer;
  55288. /**
  55289. * Callback called when the task is successful
  55290. */
  55291. onSuccess: (task: BinaryFileAssetTask) => void;
  55292. /**
  55293. * Callback called when the task is successful
  55294. */
  55295. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55296. /**
  55297. * Creates a new BinaryFileAssetTask object
  55298. * @param name defines the name of the new task
  55299. * @param url defines the location of the file to load
  55300. */
  55301. constructor(
  55302. /**
  55303. * Defines the name of the task
  55304. */
  55305. name: string,
  55306. /**
  55307. * Defines the location of the file to load
  55308. */
  55309. url: string);
  55310. /**
  55311. * Execute the current task
  55312. * @param scene defines the scene where you want your assets to be loaded
  55313. * @param onSuccess is a callback called when the task is successfully executed
  55314. * @param onError is a callback called if an error occurs
  55315. */
  55316. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55317. }
  55318. /**
  55319. * Define a task used by AssetsManager to load images
  55320. */
  55321. export class ImageAssetTask extends AbstractAssetTask {
  55322. /**
  55323. * Defines the name of the task
  55324. */
  55325. name: string;
  55326. /**
  55327. * Defines the location of the image to load
  55328. */
  55329. url: string;
  55330. /**
  55331. * Gets the loaded images
  55332. */
  55333. image: HTMLImageElement;
  55334. /**
  55335. * Callback called when the task is successful
  55336. */
  55337. onSuccess: (task: ImageAssetTask) => void;
  55338. /**
  55339. * Callback called when the task is successful
  55340. */
  55341. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55342. /**
  55343. * Creates a new ImageAssetTask
  55344. * @param name defines the name of the task
  55345. * @param url defines the location of the image to load
  55346. */
  55347. constructor(
  55348. /**
  55349. * Defines the name of the task
  55350. */
  55351. name: string,
  55352. /**
  55353. * Defines the location of the image to load
  55354. */
  55355. url: string);
  55356. /**
  55357. * Execute the current task
  55358. * @param scene defines the scene where you want your assets to be loaded
  55359. * @param onSuccess is a callback called when the task is successfully executed
  55360. * @param onError is a callback called if an error occurs
  55361. */
  55362. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55363. }
  55364. /**
  55365. * Defines the interface used by texture loading tasks
  55366. */
  55367. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55368. /**
  55369. * Gets the loaded texture
  55370. */
  55371. texture: TEX;
  55372. }
  55373. /**
  55374. * Define a task used by AssetsManager to load 2D textures
  55375. */
  55376. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55377. /**
  55378. * Defines the name of the task
  55379. */
  55380. name: string;
  55381. /**
  55382. * Defines the location of the file to load
  55383. */
  55384. url: string;
  55385. /**
  55386. * Defines if mipmap should not be generated (default is false)
  55387. */
  55388. noMipmap?: boolean | undefined;
  55389. /**
  55390. * Defines if texture must be inverted on Y axis (default is false)
  55391. */
  55392. invertY?: boolean | undefined;
  55393. /**
  55394. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55395. */
  55396. samplingMode: number;
  55397. /**
  55398. * Gets the loaded texture
  55399. */
  55400. texture: Texture;
  55401. /**
  55402. * Callback called when the task is successful
  55403. */
  55404. onSuccess: (task: TextureAssetTask) => void;
  55405. /**
  55406. * Callback called when the task is successful
  55407. */
  55408. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55409. /**
  55410. * Creates a new TextureAssetTask object
  55411. * @param name defines the name of the task
  55412. * @param url defines the location of the file to load
  55413. * @param noMipmap defines if mipmap should not be generated (default is false)
  55414. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55415. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55416. */
  55417. constructor(
  55418. /**
  55419. * Defines the name of the task
  55420. */
  55421. name: string,
  55422. /**
  55423. * Defines the location of the file to load
  55424. */
  55425. url: string,
  55426. /**
  55427. * Defines if mipmap should not be generated (default is false)
  55428. */
  55429. noMipmap?: boolean | undefined,
  55430. /**
  55431. * Defines if texture must be inverted on Y axis (default is false)
  55432. */
  55433. invertY?: boolean | undefined,
  55434. /**
  55435. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55436. */
  55437. samplingMode?: number);
  55438. /**
  55439. * Execute the current task
  55440. * @param scene defines the scene where you want your assets to be loaded
  55441. * @param onSuccess is a callback called when the task is successfully executed
  55442. * @param onError is a callback called if an error occurs
  55443. */
  55444. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55445. }
  55446. /**
  55447. * Define a task used by AssetsManager to load cube textures
  55448. */
  55449. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55450. /**
  55451. * Defines the name of the task
  55452. */
  55453. name: string;
  55454. /**
  55455. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55456. */
  55457. url: string;
  55458. /**
  55459. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55460. */
  55461. extensions?: string[] | undefined;
  55462. /**
  55463. * Defines if mipmaps should not be generated (default is false)
  55464. */
  55465. noMipmap?: boolean | undefined;
  55466. /**
  55467. * Defines the explicit list of files (undefined by default)
  55468. */
  55469. files?: string[] | undefined;
  55470. /**
  55471. * Gets the loaded texture
  55472. */
  55473. texture: CubeTexture;
  55474. /**
  55475. * Callback called when the task is successful
  55476. */
  55477. onSuccess: (task: CubeTextureAssetTask) => void;
  55478. /**
  55479. * Callback called when the task is successful
  55480. */
  55481. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55482. /**
  55483. * Creates a new CubeTextureAssetTask
  55484. * @param name defines the name of the task
  55485. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55486. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55487. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55488. * @param files defines the explicit list of files (undefined by default)
  55489. */
  55490. constructor(
  55491. /**
  55492. * Defines the name of the task
  55493. */
  55494. name: string,
  55495. /**
  55496. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55497. */
  55498. url: string,
  55499. /**
  55500. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55501. */
  55502. extensions?: string[] | undefined,
  55503. /**
  55504. * Defines if mipmaps should not be generated (default is false)
  55505. */
  55506. noMipmap?: boolean | undefined,
  55507. /**
  55508. * Defines the explicit list of files (undefined by default)
  55509. */
  55510. files?: string[] | undefined);
  55511. /**
  55512. * Execute the current task
  55513. * @param scene defines the scene where you want your assets to be loaded
  55514. * @param onSuccess is a callback called when the task is successfully executed
  55515. * @param onError is a callback called if an error occurs
  55516. */
  55517. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55518. }
  55519. /**
  55520. * Define a task used by AssetsManager to load HDR cube textures
  55521. */
  55522. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55523. /**
  55524. * Defines the name of the task
  55525. */
  55526. name: string;
  55527. /**
  55528. * Defines the location of the file to load
  55529. */
  55530. url: string;
  55531. /**
  55532. * Defines the desired size (the more it increases the longer the generation will be)
  55533. */
  55534. size: number;
  55535. /**
  55536. * Defines if mipmaps should not be generated (default is false)
  55537. */
  55538. noMipmap: boolean;
  55539. /**
  55540. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55541. */
  55542. generateHarmonics: boolean;
  55543. /**
  55544. * 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)
  55545. */
  55546. gammaSpace: boolean;
  55547. /**
  55548. * Internal Use Only
  55549. */
  55550. reserved: boolean;
  55551. /**
  55552. * Gets the loaded texture
  55553. */
  55554. texture: HDRCubeTexture;
  55555. /**
  55556. * Callback called when the task is successful
  55557. */
  55558. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55559. /**
  55560. * Callback called when the task is successful
  55561. */
  55562. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55563. /**
  55564. * Creates a new HDRCubeTextureAssetTask object
  55565. * @param name defines the name of the task
  55566. * @param url defines the location of the file to load
  55567. * @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.
  55568. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55569. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55570. * @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)
  55571. * @param reserved Internal use only
  55572. */
  55573. constructor(
  55574. /**
  55575. * Defines the name of the task
  55576. */
  55577. name: string,
  55578. /**
  55579. * Defines the location of the file to load
  55580. */
  55581. url: string,
  55582. /**
  55583. * Defines the desired size (the more it increases the longer the generation will be)
  55584. */
  55585. size: number,
  55586. /**
  55587. * Defines if mipmaps should not be generated (default is false)
  55588. */
  55589. noMipmap?: boolean,
  55590. /**
  55591. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55592. */
  55593. generateHarmonics?: boolean,
  55594. /**
  55595. * 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)
  55596. */
  55597. gammaSpace?: boolean,
  55598. /**
  55599. * Internal Use Only
  55600. */
  55601. reserved?: boolean);
  55602. /**
  55603. * Execute the current task
  55604. * @param scene defines the scene where you want your assets to be loaded
  55605. * @param onSuccess is a callback called when the task is successfully executed
  55606. * @param onError is a callback called if an error occurs
  55607. */
  55608. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55609. }
  55610. /**
  55611. * Define a task used by AssetsManager to load Equirectangular cube textures
  55612. */
  55613. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  55614. /**
  55615. * Defines the name of the task
  55616. */
  55617. name: string;
  55618. /**
  55619. * Defines the location of the file to load
  55620. */
  55621. url: string;
  55622. /**
  55623. * Defines the desired size (the more it increases the longer the generation will be)
  55624. */
  55625. size: number;
  55626. /**
  55627. * Defines if mipmaps should not be generated (default is false)
  55628. */
  55629. noMipmap: boolean;
  55630. /**
  55631. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55632. * but the standard material would require them in Gamma space) (default is true)
  55633. */
  55634. gammaSpace: boolean;
  55635. /**
  55636. * Gets the loaded texture
  55637. */
  55638. texture: EquiRectangularCubeTexture;
  55639. /**
  55640. * Callback called when the task is successful
  55641. */
  55642. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  55643. /**
  55644. * Callback called when the task is successful
  55645. */
  55646. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  55647. /**
  55648. * Creates a new EquiRectangularCubeTextureAssetTask object
  55649. * @param name defines the name of the task
  55650. * @param url defines the location of the file to load
  55651. * @param size defines the desired size (the more it increases the longer the generation will be)
  55652. * If the size is omitted this implies you are using a preprocessed cubemap.
  55653. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55654. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  55655. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  55656. * (default is true)
  55657. */
  55658. constructor(
  55659. /**
  55660. * Defines the name of the task
  55661. */
  55662. name: string,
  55663. /**
  55664. * Defines the location of the file to load
  55665. */
  55666. url: string,
  55667. /**
  55668. * Defines the desired size (the more it increases the longer the generation will be)
  55669. */
  55670. size: number,
  55671. /**
  55672. * Defines if mipmaps should not be generated (default is false)
  55673. */
  55674. noMipmap?: boolean,
  55675. /**
  55676. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55677. * but the standard material would require them in Gamma space) (default is true)
  55678. */
  55679. gammaSpace?: boolean);
  55680. /**
  55681. * Execute the current task
  55682. * @param scene defines the scene where you want your assets to be loaded
  55683. * @param onSuccess is a callback called when the task is successfully executed
  55684. * @param onError is a callback called if an error occurs
  55685. */
  55686. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55687. }
  55688. /**
  55689. * This class can be used to easily import assets into a scene
  55690. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  55691. */
  55692. export class AssetsManager {
  55693. private _scene;
  55694. private _isLoading;
  55695. protected _tasks: AbstractAssetTask[];
  55696. protected _waitingTasksCount: number;
  55697. protected _totalTasksCount: number;
  55698. /**
  55699. * Callback called when all tasks are processed
  55700. */
  55701. onFinish: (tasks: AbstractAssetTask[]) => void;
  55702. /**
  55703. * Callback called when a task is successful
  55704. */
  55705. onTaskSuccess: (task: AbstractAssetTask) => void;
  55706. /**
  55707. * Callback called when a task had an error
  55708. */
  55709. onTaskError: (task: AbstractAssetTask) => void;
  55710. /**
  55711. * Callback called when a task is done (whatever the result is)
  55712. */
  55713. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  55714. /**
  55715. * Observable called when all tasks are processed
  55716. */
  55717. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  55718. /**
  55719. * Observable called when a task had an error
  55720. */
  55721. onTaskErrorObservable: Observable<AbstractAssetTask>;
  55722. /**
  55723. * Observable called when all tasks were executed
  55724. */
  55725. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  55726. /**
  55727. * Observable called when a task is done (whatever the result is)
  55728. */
  55729. onProgressObservable: Observable<IAssetsProgressEvent>;
  55730. /**
  55731. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  55732. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  55733. */
  55734. useDefaultLoadingScreen: boolean;
  55735. /**
  55736. * Creates a new AssetsManager
  55737. * @param scene defines the scene to work on
  55738. */
  55739. constructor(scene: Scene);
  55740. /**
  55741. * Add a MeshAssetTask to the list of active tasks
  55742. * @param taskName defines the name of the new task
  55743. * @param meshesNames defines the name of meshes to load
  55744. * @param rootUrl defines the root url to use to locate files
  55745. * @param sceneFilename defines the filename of the scene file
  55746. * @returns a new MeshAssetTask object
  55747. */
  55748. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  55749. /**
  55750. * Add a TextFileAssetTask to the list of active tasks
  55751. * @param taskName defines the name of the new task
  55752. * @param url defines the url of the file to load
  55753. * @returns a new TextFileAssetTask object
  55754. */
  55755. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  55756. /**
  55757. * Add a BinaryFileAssetTask to the list of active tasks
  55758. * @param taskName defines the name of the new task
  55759. * @param url defines the url of the file to load
  55760. * @returns a new BinaryFileAssetTask object
  55761. */
  55762. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  55763. /**
  55764. * Add a ImageAssetTask to the list of active tasks
  55765. * @param taskName defines the name of the new task
  55766. * @param url defines the url of the file to load
  55767. * @returns a new ImageAssetTask object
  55768. */
  55769. addImageTask(taskName: string, url: string): ImageAssetTask;
  55770. /**
  55771. * Add a TextureAssetTask to the list of active tasks
  55772. * @param taskName defines the name of the new task
  55773. * @param url defines the url of the file to load
  55774. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55775. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  55776. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  55777. * @returns a new TextureAssetTask object
  55778. */
  55779. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  55780. /**
  55781. * Add a CubeTextureAssetTask to the list of active tasks
  55782. * @param taskName defines the name of the new task
  55783. * @param url defines the url of the file to load
  55784. * @param extensions defines the extension to use to load the cube map (can be null)
  55785. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55786. * @param files defines the list of files to load (can be null)
  55787. * @returns a new CubeTextureAssetTask object
  55788. */
  55789. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55790. /**
  55791. *
  55792. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55793. * @param taskName defines the name of the new task
  55794. * @param url defines the url of the file to load
  55795. * @param size defines the size you want for the cubemap (can be null)
  55796. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55797. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55798. * @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)
  55799. * @param reserved Internal use only
  55800. * @returns a new HDRCubeTextureAssetTask object
  55801. */
  55802. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55803. /**
  55804. *
  55805. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  55806. * @param taskName defines the name of the new task
  55807. * @param url defines the url of the file to load
  55808. * @param size defines the size you want for the cubemap (can be null)
  55809. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55810. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55811. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55812. * @returns a new EquiRectangularCubeTextureAssetTask object
  55813. */
  55814. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  55815. /**
  55816. * Remove a task from the assets manager.
  55817. * @param task the task to remove
  55818. */
  55819. removeTask(task: AbstractAssetTask): void;
  55820. private _decreaseWaitingTasksCount;
  55821. private _runTask;
  55822. /**
  55823. * Reset the AssetsManager and remove all tasks
  55824. * @return the current instance of the AssetsManager
  55825. */
  55826. reset(): AssetsManager;
  55827. /**
  55828. * Start the loading process
  55829. * @return the current instance of the AssetsManager
  55830. */
  55831. load(): AssetsManager;
  55832. /**
  55833. * Start the loading process as an async operation
  55834. * @return a promise returning the list of failed tasks
  55835. */
  55836. loadAsync(): Promise<void>;
  55837. }
  55838. }
  55839. declare module BABYLON {
  55840. /**
  55841. * Wrapper class for promise with external resolve and reject.
  55842. */
  55843. export class Deferred<T> {
  55844. /**
  55845. * The promise associated with this deferred object.
  55846. */
  55847. readonly promise: Promise<T>;
  55848. private _resolve;
  55849. private _reject;
  55850. /**
  55851. * The resolve method of the promise associated with this deferred object.
  55852. */
  55853. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55854. /**
  55855. * The reject method of the promise associated with this deferred object.
  55856. */
  55857. readonly reject: (reason?: any) => void;
  55858. /**
  55859. * Constructor for this deferred object.
  55860. */
  55861. constructor();
  55862. }
  55863. }
  55864. declare module BABYLON {
  55865. /**
  55866. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  55867. */
  55868. export class MeshExploder {
  55869. private _centerMesh;
  55870. private _meshes;
  55871. private _meshesOrigins;
  55872. private _toCenterVectors;
  55873. private _scaledDirection;
  55874. private _newPosition;
  55875. private _centerPosition;
  55876. /**
  55877. * Explodes meshes from a center mesh.
  55878. * @param meshes The meshes to explode.
  55879. * @param centerMesh The mesh to be center of explosion.
  55880. */
  55881. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  55882. private _setCenterMesh;
  55883. /**
  55884. * Get class name
  55885. * @returns "MeshExploder"
  55886. */
  55887. getClassName(): string;
  55888. /**
  55889. * "Exploded meshes"
  55890. * @returns Array of meshes with the centerMesh at index 0.
  55891. */
  55892. getMeshes(): Array<Mesh>;
  55893. /**
  55894. * Explodes meshes giving a specific direction
  55895. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  55896. */
  55897. explode(direction?: number): void;
  55898. }
  55899. }
  55900. declare module BABYLON {
  55901. /**
  55902. * Class used to help managing file picking and drag'n'drop
  55903. */
  55904. export class FilesInput {
  55905. /**
  55906. * List of files ready to be loaded
  55907. */
  55908. static readonly FilesToLoad: {
  55909. [key: string]: File;
  55910. };
  55911. /**
  55912. * Callback called when a file is processed
  55913. */
  55914. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55915. private _engine;
  55916. private _currentScene;
  55917. private _sceneLoadedCallback;
  55918. private _progressCallback;
  55919. private _additionalRenderLoopLogicCallback;
  55920. private _textureLoadingCallback;
  55921. private _startingProcessingFilesCallback;
  55922. private _onReloadCallback;
  55923. private _errorCallback;
  55924. private _elementToMonitor;
  55925. private _sceneFileToLoad;
  55926. private _filesToLoad;
  55927. /**
  55928. * Creates a new FilesInput
  55929. * @param engine defines the rendering engine
  55930. * @param scene defines the hosting scene
  55931. * @param sceneLoadedCallback callback called when scene is loaded
  55932. * @param progressCallback callback called to track progress
  55933. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55934. * @param textureLoadingCallback callback called when a texture is loading
  55935. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55936. * @param onReloadCallback callback called when a reload is requested
  55937. * @param errorCallback callback call if an error occurs
  55938. */
  55939. 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);
  55940. private _dragEnterHandler;
  55941. private _dragOverHandler;
  55942. private _dropHandler;
  55943. /**
  55944. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55945. * @param elementToMonitor defines the DOM element to track
  55946. */
  55947. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55948. /**
  55949. * Release all associated resources
  55950. */
  55951. dispose(): void;
  55952. private renderFunction;
  55953. private drag;
  55954. private drop;
  55955. private _traverseFolder;
  55956. private _processFiles;
  55957. /**
  55958. * Load files from a drop event
  55959. * @param event defines the drop event to use as source
  55960. */
  55961. loadFiles(event: any): void;
  55962. private _processReload;
  55963. /**
  55964. * Reload the current scene from the loaded files
  55965. */
  55966. reload(): void;
  55967. }
  55968. }
  55969. declare module BABYLON {
  55970. /**
  55971. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55972. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55973. */
  55974. export class SceneOptimization {
  55975. /**
  55976. * Defines the priority of this optimization (0 by default which means first in the list)
  55977. */
  55978. priority: number;
  55979. /**
  55980. * Gets a string describing the action executed by the current optimization
  55981. * @returns description string
  55982. */
  55983. getDescription(): string;
  55984. /**
  55985. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55986. * @param scene defines the current scene where to apply this optimization
  55987. * @param optimizer defines the current optimizer
  55988. * @returns true if everything that can be done was applied
  55989. */
  55990. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55991. /**
  55992. * Creates the SceneOptimization object
  55993. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55994. * @param desc defines the description associated with the optimization
  55995. */
  55996. constructor(
  55997. /**
  55998. * Defines the priority of this optimization (0 by default which means first in the list)
  55999. */
  56000. priority?: number);
  56001. }
  56002. /**
  56003. * Defines an optimization used to reduce the size of render target textures
  56004. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56005. */
  56006. export class TextureOptimization extends SceneOptimization {
  56007. /**
  56008. * Defines the priority of this optimization (0 by default which means first in the list)
  56009. */
  56010. priority: number;
  56011. /**
  56012. * 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
  56013. */
  56014. maximumSize: number;
  56015. /**
  56016. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56017. */
  56018. step: number;
  56019. /**
  56020. * Gets a string describing the action executed by the current optimization
  56021. * @returns description string
  56022. */
  56023. getDescription(): string;
  56024. /**
  56025. * Creates the TextureOptimization object
  56026. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56027. * @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
  56028. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56029. */
  56030. constructor(
  56031. /**
  56032. * Defines the priority of this optimization (0 by default which means first in the list)
  56033. */
  56034. priority?: number,
  56035. /**
  56036. * 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
  56037. */
  56038. maximumSize?: number,
  56039. /**
  56040. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56041. */
  56042. step?: number);
  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. /**
  56052. * Defines an optimization used to increase or decrease the rendering resolution
  56053. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56054. */
  56055. export class HardwareScalingOptimization extends SceneOptimization {
  56056. /**
  56057. * Defines the priority of this optimization (0 by default which means first in the list)
  56058. */
  56059. priority: number;
  56060. /**
  56061. * Defines the maximum scale to use (2 by default)
  56062. */
  56063. maximumScale: number;
  56064. /**
  56065. * Defines the step to use between two passes (0.5 by default)
  56066. */
  56067. step: number;
  56068. private _currentScale;
  56069. private _directionOffset;
  56070. /**
  56071. * Gets a string describing the action executed by the current optimization
  56072. * @return description string
  56073. */
  56074. getDescription(): string;
  56075. /**
  56076. * Creates the HardwareScalingOptimization object
  56077. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56078. * @param maximumScale defines the maximum scale to use (2 by default)
  56079. * @param step defines the step to use between two passes (0.5 by default)
  56080. */
  56081. constructor(
  56082. /**
  56083. * Defines the priority of this optimization (0 by default which means first in the list)
  56084. */
  56085. priority?: number,
  56086. /**
  56087. * Defines the maximum scale to use (2 by default)
  56088. */
  56089. maximumScale?: number,
  56090. /**
  56091. * Defines the step to use between two passes (0.5 by default)
  56092. */
  56093. step?: number);
  56094. /**
  56095. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56096. * @param scene defines the current scene where to apply this optimization
  56097. * @param optimizer defines the current optimizer
  56098. * @returns true if everything that can be done was applied
  56099. */
  56100. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56101. }
  56102. /**
  56103. * Defines an optimization used to remove shadows
  56104. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56105. */
  56106. export class ShadowsOptimization extends SceneOptimization {
  56107. /**
  56108. * Gets a string describing the action executed by the current optimization
  56109. * @return description string
  56110. */
  56111. getDescription(): string;
  56112. /**
  56113. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56114. * @param scene defines the current scene where to apply this optimization
  56115. * @param optimizer defines the current optimizer
  56116. * @returns true if everything that can be done was applied
  56117. */
  56118. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56119. }
  56120. /**
  56121. * Defines an optimization used to turn post-processes off
  56122. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56123. */
  56124. export class PostProcessesOptimization extends SceneOptimization {
  56125. /**
  56126. * Gets a string describing the action executed by the current optimization
  56127. * @return description string
  56128. */
  56129. getDescription(): string;
  56130. /**
  56131. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56132. * @param scene defines the current scene where to apply this optimization
  56133. * @param optimizer defines the current optimizer
  56134. * @returns true if everything that can be done was applied
  56135. */
  56136. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56137. }
  56138. /**
  56139. * Defines an optimization used to turn lens flares off
  56140. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56141. */
  56142. export class LensFlaresOptimization extends SceneOptimization {
  56143. /**
  56144. * Gets a string describing the action executed by the current optimization
  56145. * @return description string
  56146. */
  56147. getDescription(): string;
  56148. /**
  56149. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56150. * @param scene defines the current scene where to apply this optimization
  56151. * @param optimizer defines the current optimizer
  56152. * @returns true if everything that can be done was applied
  56153. */
  56154. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56155. }
  56156. /**
  56157. * Defines an optimization based on user defined callback.
  56158. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56159. */
  56160. export class CustomOptimization extends SceneOptimization {
  56161. /**
  56162. * Callback called to apply the custom optimization.
  56163. */
  56164. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56165. /**
  56166. * Callback called to get custom description
  56167. */
  56168. onGetDescription: () => string;
  56169. /**
  56170. * Gets a string describing the action executed by the current optimization
  56171. * @returns description string
  56172. */
  56173. getDescription(): string;
  56174. /**
  56175. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56176. * @param scene defines the current scene where to apply this optimization
  56177. * @param optimizer defines the current optimizer
  56178. * @returns true if everything that can be done was applied
  56179. */
  56180. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56181. }
  56182. /**
  56183. * Defines an optimization used to turn particles off
  56184. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56185. */
  56186. export class ParticlesOptimization extends SceneOptimization {
  56187. /**
  56188. * Gets a string describing the action executed by the current optimization
  56189. * @return description string
  56190. */
  56191. getDescription(): string;
  56192. /**
  56193. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56194. * @param scene defines the current scene where to apply this optimization
  56195. * @param optimizer defines the current optimizer
  56196. * @returns true if everything that can be done was applied
  56197. */
  56198. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56199. }
  56200. /**
  56201. * Defines an optimization used to turn render targets off
  56202. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56203. */
  56204. export class RenderTargetsOptimization extends SceneOptimization {
  56205. /**
  56206. * Gets a string describing the action executed by the current optimization
  56207. * @return description string
  56208. */
  56209. getDescription(): string;
  56210. /**
  56211. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56212. * @param scene defines the current scene where to apply this optimization
  56213. * @param optimizer defines the current optimizer
  56214. * @returns true if everything that can be done was applied
  56215. */
  56216. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56217. }
  56218. /**
  56219. * Defines an optimization used to merge meshes with compatible materials
  56220. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56221. */
  56222. export class MergeMeshesOptimization extends SceneOptimization {
  56223. private static _UpdateSelectionTree;
  56224. /**
  56225. * Gets or sets a boolean which defines if optimization octree has to be updated
  56226. */
  56227. /**
  56228. * Gets or sets a boolean which defines if optimization octree has to be updated
  56229. */
  56230. static UpdateSelectionTree: boolean;
  56231. /**
  56232. * Gets a string describing the action executed by the current optimization
  56233. * @return description string
  56234. */
  56235. getDescription(): string;
  56236. private _canBeMerged;
  56237. /**
  56238. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56239. * @param scene defines the current scene where to apply this optimization
  56240. * @param optimizer defines the current optimizer
  56241. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56242. * @returns true if everything that can be done was applied
  56243. */
  56244. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56245. }
  56246. /**
  56247. * Defines a list of options used by SceneOptimizer
  56248. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56249. */
  56250. export class SceneOptimizerOptions {
  56251. /**
  56252. * Defines the target frame rate to reach (60 by default)
  56253. */
  56254. targetFrameRate: number;
  56255. /**
  56256. * Defines the interval between two checkes (2000ms by default)
  56257. */
  56258. trackerDuration: number;
  56259. /**
  56260. * Gets the list of optimizations to apply
  56261. */
  56262. optimizations: SceneOptimization[];
  56263. /**
  56264. * Creates a new list of options used by SceneOptimizer
  56265. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56266. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56267. */
  56268. constructor(
  56269. /**
  56270. * Defines the target frame rate to reach (60 by default)
  56271. */
  56272. targetFrameRate?: number,
  56273. /**
  56274. * Defines the interval between two checkes (2000ms by default)
  56275. */
  56276. trackerDuration?: number);
  56277. /**
  56278. * Add a new optimization
  56279. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56280. * @returns the current SceneOptimizerOptions
  56281. */
  56282. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56283. /**
  56284. * Add a new custom optimization
  56285. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56286. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56287. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56288. * @returns the current SceneOptimizerOptions
  56289. */
  56290. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56291. /**
  56292. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56293. * @param targetFrameRate defines the target frame rate (60 by default)
  56294. * @returns a SceneOptimizerOptions object
  56295. */
  56296. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56297. /**
  56298. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56299. * @param targetFrameRate defines the target frame rate (60 by default)
  56300. * @returns a SceneOptimizerOptions object
  56301. */
  56302. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56303. /**
  56304. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56305. * @param targetFrameRate defines the target frame rate (60 by default)
  56306. * @returns a SceneOptimizerOptions object
  56307. */
  56308. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56309. }
  56310. /**
  56311. * Class used to run optimizations in order to reach a target frame rate
  56312. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56313. */
  56314. export class SceneOptimizer implements IDisposable {
  56315. private _isRunning;
  56316. private _options;
  56317. private _scene;
  56318. private _currentPriorityLevel;
  56319. private _targetFrameRate;
  56320. private _trackerDuration;
  56321. private _currentFrameRate;
  56322. private _sceneDisposeObserver;
  56323. private _improvementMode;
  56324. /**
  56325. * Defines an observable called when the optimizer reaches the target frame rate
  56326. */
  56327. onSuccessObservable: Observable<SceneOptimizer>;
  56328. /**
  56329. * Defines an observable called when the optimizer enables an optimization
  56330. */
  56331. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56332. /**
  56333. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56334. */
  56335. onFailureObservable: Observable<SceneOptimizer>;
  56336. /**
  56337. * Gets a boolean indicating if the optimizer is in improvement mode
  56338. */
  56339. readonly isInImprovementMode: boolean;
  56340. /**
  56341. * Gets the current priority level (0 at start)
  56342. */
  56343. readonly currentPriorityLevel: number;
  56344. /**
  56345. * Gets the current frame rate checked by the SceneOptimizer
  56346. */
  56347. readonly currentFrameRate: number;
  56348. /**
  56349. * Gets or sets the current target frame rate (60 by default)
  56350. */
  56351. /**
  56352. * Gets or sets the current target frame rate (60 by default)
  56353. */
  56354. targetFrameRate: number;
  56355. /**
  56356. * Gets or sets the current interval between two checks (every 2000ms by default)
  56357. */
  56358. /**
  56359. * Gets or sets the current interval between two checks (every 2000ms by default)
  56360. */
  56361. trackerDuration: number;
  56362. /**
  56363. * Gets the list of active optimizations
  56364. */
  56365. readonly optimizations: SceneOptimization[];
  56366. /**
  56367. * Creates a new SceneOptimizer
  56368. * @param scene defines the scene to work on
  56369. * @param options defines the options to use with the SceneOptimizer
  56370. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56371. * @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)
  56372. */
  56373. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56374. /**
  56375. * Stops the current optimizer
  56376. */
  56377. stop(): void;
  56378. /**
  56379. * Reset the optimizer to initial step (current priority level = 0)
  56380. */
  56381. reset(): void;
  56382. /**
  56383. * Start the optimizer. By default it will try to reach a specific framerate
  56384. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56385. */
  56386. start(): void;
  56387. private _checkCurrentState;
  56388. /**
  56389. * Release all resources
  56390. */
  56391. dispose(): void;
  56392. /**
  56393. * Helper function to create a SceneOptimizer with one single line of code
  56394. * @param scene defines the scene to work on
  56395. * @param options defines the options to use with the SceneOptimizer
  56396. * @param onSuccess defines a callback to call on success
  56397. * @param onFailure defines a callback to call on failure
  56398. * @returns the new SceneOptimizer object
  56399. */
  56400. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56401. }
  56402. }
  56403. declare module BABYLON {
  56404. /**
  56405. * Class used to serialize a scene into a string
  56406. */
  56407. export class SceneSerializer {
  56408. /**
  56409. * Clear cache used by a previous serialization
  56410. */
  56411. static ClearCache(): void;
  56412. /**
  56413. * Serialize a scene into a JSON compatible object
  56414. * @param scene defines the scene to serialize
  56415. * @returns a JSON compatible object
  56416. */
  56417. static Serialize(scene: Scene): any;
  56418. /**
  56419. * Serialize a mesh into a JSON compatible object
  56420. * @param toSerialize defines the mesh to serialize
  56421. * @param withParents defines if parents must be serialized as well
  56422. * @param withChildren defines if children must be serialized as well
  56423. * @returns a JSON compatible object
  56424. */
  56425. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56426. }
  56427. }
  56428. declare module BABYLON {
  56429. /**
  56430. * Class used to host texture specific utilities
  56431. */
  56432. export class TextureTools {
  56433. /**
  56434. * Uses the GPU to create a copy texture rescaled at a given size
  56435. * @param texture Texture to copy from
  56436. * @param width defines the desired width
  56437. * @param height defines the desired height
  56438. * @param useBilinearMode defines if bilinear mode has to be used
  56439. * @return the generated texture
  56440. */
  56441. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  56442. }
  56443. }
  56444. declare module BABYLON {
  56445. /**
  56446. * This represents the different options avilable for the video capture.
  56447. */
  56448. export interface VideoRecorderOptions {
  56449. /** Defines the mime type of the video */
  56450. mimeType: string;
  56451. /** Defines the video the video should be recorded at */
  56452. fps: number;
  56453. /** Defines the chunk size for the recording data */
  56454. recordChunckSize: number;
  56455. /** The audio tracks to attach to the record */
  56456. audioTracks?: MediaStreamTrack[];
  56457. }
  56458. /**
  56459. * This can helps recording videos from BabylonJS.
  56460. * This is based on the available WebRTC functionalities of the browser.
  56461. *
  56462. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56463. */
  56464. export class VideoRecorder {
  56465. private static readonly _defaultOptions;
  56466. /**
  56467. * Returns wehther or not the VideoRecorder is available in your browser.
  56468. * @param engine Defines the Babylon Engine to check the support for
  56469. * @returns true if supported otherwise false
  56470. */
  56471. static IsSupported(engine: Engine): boolean;
  56472. private readonly _options;
  56473. private _canvas;
  56474. private _mediaRecorder;
  56475. private _recordedChunks;
  56476. private _fileName;
  56477. private _resolve;
  56478. private _reject;
  56479. /**
  56480. * True wether a recording is already in progress.
  56481. */
  56482. readonly isRecording: boolean;
  56483. /**
  56484. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56485. * a video file.
  56486. * @param engine Defines the BabylonJS Engine you wish to record
  56487. * @param options Defines options that can be used to customized the capture
  56488. */
  56489. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56490. /**
  56491. * Stops the current recording before the default capture timeout passed in the startRecording
  56492. * functions.
  56493. */
  56494. stopRecording(): void;
  56495. /**
  56496. * Starts recording the canvas for a max duration specified in parameters.
  56497. * @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.
  56498. * @param maxDuration Defines the maximum recording time in seconds.
  56499. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56500. * @return a promise callback at the end of the recording with the video data in Blob.
  56501. */
  56502. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56503. /**
  56504. * Releases internal resources used during the recording.
  56505. */
  56506. dispose(): void;
  56507. private _handleDataAvailable;
  56508. private _handleError;
  56509. private _handleStop;
  56510. }
  56511. }
  56512. declare module BABYLON {
  56513. /**
  56514. * Class containing a set of static utilities functions for screenshots
  56515. */
  56516. export class ScreenshotTools {
  56517. /**
  56518. * Captures a screenshot of the current rendering
  56519. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56520. * @param engine defines the rendering engine
  56521. * @param camera defines the source camera
  56522. * @param size This parameter can be set to a single number or to an object with the
  56523. * following (optional) properties: precision, width, height. If a single number is passed,
  56524. * it will be used for both width and height. If an object is passed, the screenshot size
  56525. * will be derived from the parameters. The precision property is a multiplier allowing
  56526. * rendering at a higher or lower resolution
  56527. * @param successCallback defines the callback receives a single parameter which contains the
  56528. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56529. * src parameter of an <img> to display it
  56530. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56531. * Check your browser for supported MIME types
  56532. */
  56533. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56534. /**
  56535. * Generates an image screenshot from the specified camera.
  56536. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56537. * @param engine The engine to use for rendering
  56538. * @param camera The camera to use for rendering
  56539. * @param size This parameter can be set to a single number or to an object with the
  56540. * following (optional) properties: precision, width, height. If a single number is passed,
  56541. * it will be used for both width and height. If an object is passed, the screenshot size
  56542. * will be derived from the parameters. The precision property is a multiplier allowing
  56543. * rendering at a higher or lower resolution
  56544. * @param successCallback The callback receives a single parameter which contains the
  56545. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56546. * src parameter of an <img> to display it
  56547. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56548. * Check your browser for supported MIME types
  56549. * @param samples Texture samples (default: 1)
  56550. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56551. * @param fileName A name for for the downloaded file.
  56552. */
  56553. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56554. }
  56555. }
  56556. declare module BABYLON {
  56557. /**
  56558. * A cursor which tracks a point on a path
  56559. */
  56560. export class PathCursor {
  56561. private path;
  56562. /**
  56563. * Stores path cursor callbacks for when an onchange event is triggered
  56564. */
  56565. private _onchange;
  56566. /**
  56567. * The value of the path cursor
  56568. */
  56569. value: number;
  56570. /**
  56571. * The animation array of the path cursor
  56572. */
  56573. animations: Animation[];
  56574. /**
  56575. * Initializes the path cursor
  56576. * @param path The path to track
  56577. */
  56578. constructor(path: Path2);
  56579. /**
  56580. * Gets the cursor point on the path
  56581. * @returns A point on the path cursor at the cursor location
  56582. */
  56583. getPoint(): Vector3;
  56584. /**
  56585. * Moves the cursor ahead by the step amount
  56586. * @param step The amount to move the cursor forward
  56587. * @returns This path cursor
  56588. */
  56589. moveAhead(step?: number): PathCursor;
  56590. /**
  56591. * Moves the cursor behind by the step amount
  56592. * @param step The amount to move the cursor back
  56593. * @returns This path cursor
  56594. */
  56595. moveBack(step?: number): PathCursor;
  56596. /**
  56597. * Moves the cursor by the step amount
  56598. * If the step amount is greater than one, an exception is thrown
  56599. * @param step The amount to move the cursor
  56600. * @returns This path cursor
  56601. */
  56602. move(step: number): PathCursor;
  56603. /**
  56604. * Ensures that the value is limited between zero and one
  56605. * @returns This path cursor
  56606. */
  56607. private ensureLimits;
  56608. /**
  56609. * Runs onchange callbacks on change (used by the animation engine)
  56610. * @returns This path cursor
  56611. */
  56612. private raiseOnChange;
  56613. /**
  56614. * Executes a function on change
  56615. * @param f A path cursor onchange callback
  56616. * @returns This path cursor
  56617. */
  56618. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56619. }
  56620. }
  56621. declare module BABYLON {
  56622. /** @hidden */
  56623. export var blurPixelShader: {
  56624. name: string;
  56625. shader: string;
  56626. };
  56627. }
  56628. declare module BABYLON {
  56629. /** @hidden */
  56630. export var bones300Declaration: {
  56631. name: string;
  56632. shader: string;
  56633. };
  56634. }
  56635. declare module BABYLON {
  56636. /** @hidden */
  56637. export var instances300Declaration: {
  56638. name: string;
  56639. shader: string;
  56640. };
  56641. }
  56642. declare module BABYLON {
  56643. /** @hidden */
  56644. export var pointCloudVertexDeclaration: {
  56645. name: string;
  56646. shader: string;
  56647. };
  56648. }
  56649. // Mixins
  56650. interface Window {
  56651. mozIndexedDB: IDBFactory;
  56652. webkitIndexedDB: IDBFactory;
  56653. msIndexedDB: IDBFactory;
  56654. webkitURL: typeof URL;
  56655. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56656. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56657. WebGLRenderingContext: WebGLRenderingContext;
  56658. MSGesture: MSGesture;
  56659. CANNON: any;
  56660. AudioContext: AudioContext;
  56661. webkitAudioContext: AudioContext;
  56662. PointerEvent: any;
  56663. Math: Math;
  56664. Uint8Array: Uint8ArrayConstructor;
  56665. Float32Array: Float32ArrayConstructor;
  56666. mozURL: typeof URL;
  56667. msURL: typeof URL;
  56668. VRFrameData: any; // WebVR, from specs 1.1
  56669. DracoDecoderModule: any;
  56670. setImmediate(handler: (...args: any[]) => void): number;
  56671. }
  56672. interface HTMLCanvasElement {
  56673. requestPointerLock(): void;
  56674. msRequestPointerLock?(): void;
  56675. mozRequestPointerLock?(): void;
  56676. webkitRequestPointerLock?(): void;
  56677. /** Track wether a record is in progress */
  56678. isRecording: boolean;
  56679. /** Capture Stream method defined by some browsers */
  56680. captureStream(fps?: number): MediaStream;
  56681. }
  56682. interface CanvasRenderingContext2D {
  56683. msImageSmoothingEnabled: boolean;
  56684. }
  56685. interface MouseEvent {
  56686. mozMovementX: number;
  56687. mozMovementY: number;
  56688. webkitMovementX: number;
  56689. webkitMovementY: number;
  56690. msMovementX: number;
  56691. msMovementY: number;
  56692. }
  56693. interface Navigator {
  56694. mozGetVRDevices: (any: any) => any;
  56695. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56696. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56697. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  56698. webkitGetGamepads(): Gamepad[];
  56699. msGetGamepads(): Gamepad[];
  56700. webkitGamepads(): Gamepad[];
  56701. }
  56702. interface HTMLVideoElement {
  56703. mozSrcObject: any;
  56704. }
  56705. interface Math {
  56706. fround(x: number): number;
  56707. imul(a: number, b: number): number;
  56708. }
  56709. interface WebGLRenderingContext {
  56710. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  56711. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  56712. vertexAttribDivisor(index: number, divisor: number): void;
  56713. createVertexArray(): any;
  56714. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  56715. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  56716. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  56717. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56718. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56719. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56720. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56721. // Queries
  56722. createQuery(): WebGLQuery;
  56723. deleteQuery(query: WebGLQuery): void;
  56724. beginQuery(target: number, query: WebGLQuery): void;
  56725. endQuery(target: number): void;
  56726. getQueryParameter(query: WebGLQuery, pname: number): any;
  56727. getQuery(target: number, pname: number): any;
  56728. MAX_SAMPLES: number;
  56729. RGBA8: number;
  56730. READ_FRAMEBUFFER: number;
  56731. DRAW_FRAMEBUFFER: number;
  56732. UNIFORM_BUFFER: number;
  56733. HALF_FLOAT_OES: number;
  56734. RGBA16F: number;
  56735. RGBA32F: number;
  56736. R32F: number;
  56737. RG32F: number;
  56738. RGB32F: number;
  56739. R16F: number;
  56740. RG16F: number;
  56741. RGB16F: number;
  56742. RED: number;
  56743. RG: number;
  56744. R8: number;
  56745. RG8: number;
  56746. UNSIGNED_INT_24_8: number;
  56747. DEPTH24_STENCIL8: number;
  56748. /* Multiple Render Targets */
  56749. drawBuffers(buffers: number[]): void;
  56750. readBuffer(src: number): void;
  56751. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56752. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56753. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56754. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56755. // Occlusion Query
  56756. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56757. ANY_SAMPLES_PASSED: number;
  56758. QUERY_RESULT_AVAILABLE: number;
  56759. QUERY_RESULT: number;
  56760. }
  56761. interface WebGLProgram {
  56762. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56763. }
  56764. interface EXT_disjoint_timer_query {
  56765. QUERY_COUNTER_BITS_EXT: number;
  56766. TIME_ELAPSED_EXT: number;
  56767. TIMESTAMP_EXT: number;
  56768. GPU_DISJOINT_EXT: number;
  56769. QUERY_RESULT_EXT: number;
  56770. QUERY_RESULT_AVAILABLE_EXT: number;
  56771. queryCounterEXT(query: WebGLQuery, target: number): void;
  56772. createQueryEXT(): WebGLQuery;
  56773. beginQueryEXT(target: number, query: WebGLQuery): void;
  56774. endQueryEXT(target: number): void;
  56775. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56776. deleteQueryEXT(query: WebGLQuery): void;
  56777. }
  56778. interface WebGLUniformLocation {
  56779. _currentState: any;
  56780. }
  56781. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56782. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56783. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56784. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56785. interface WebGLRenderingContext {
  56786. readonly RASTERIZER_DISCARD: number;
  56787. readonly DEPTH_COMPONENT24: number;
  56788. readonly TEXTURE_3D: number;
  56789. readonly TEXTURE_2D_ARRAY: number;
  56790. readonly TEXTURE_COMPARE_FUNC: number;
  56791. readonly TEXTURE_COMPARE_MODE: number;
  56792. readonly COMPARE_REF_TO_TEXTURE: number;
  56793. readonly TEXTURE_WRAP_R: number;
  56794. readonly HALF_FLOAT: number;
  56795. readonly RGB8: number;
  56796. readonly RED_INTEGER: number;
  56797. readonly RG_INTEGER: number;
  56798. readonly RGB_INTEGER: number;
  56799. readonly RGBA_INTEGER: number;
  56800. readonly R8_SNORM: number;
  56801. readonly RG8_SNORM: number;
  56802. readonly RGB8_SNORM: number;
  56803. readonly RGBA8_SNORM: number;
  56804. readonly R8I: number;
  56805. readonly RG8I: number;
  56806. readonly RGB8I: number;
  56807. readonly RGBA8I: number;
  56808. readonly R8UI: number;
  56809. readonly RG8UI: number;
  56810. readonly RGB8UI: number;
  56811. readonly RGBA8UI: number;
  56812. readonly R16I: number;
  56813. readonly RG16I: number;
  56814. readonly RGB16I: number;
  56815. readonly RGBA16I: number;
  56816. readonly R16UI: number;
  56817. readonly RG16UI: number;
  56818. readonly RGB16UI: number;
  56819. readonly RGBA16UI: number;
  56820. readonly R32I: number;
  56821. readonly RG32I: number;
  56822. readonly RGB32I: number;
  56823. readonly RGBA32I: number;
  56824. readonly R32UI: number;
  56825. readonly RG32UI: number;
  56826. readonly RGB32UI: number;
  56827. readonly RGBA32UI: number;
  56828. readonly RGB10_A2UI: number;
  56829. readonly R11F_G11F_B10F: number;
  56830. readonly RGB9_E5: number;
  56831. readonly RGB10_A2: number;
  56832. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56833. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56834. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56835. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56836. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56837. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56838. 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;
  56839. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56840. readonly TRANSFORM_FEEDBACK: number;
  56841. readonly INTERLEAVED_ATTRIBS: number;
  56842. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56843. createTransformFeedback(): WebGLTransformFeedback;
  56844. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56845. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56846. beginTransformFeedback(primitiveMode: number): void;
  56847. endTransformFeedback(): void;
  56848. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56849. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56850. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56851. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56852. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56853. }
  56854. interface ImageBitmap {
  56855. readonly width: number;
  56856. readonly height: number;
  56857. close(): void;
  56858. }
  56859. interface WebGLQuery extends WebGLObject {
  56860. }
  56861. declare var WebGLQuery: {
  56862. prototype: WebGLQuery;
  56863. new(): WebGLQuery;
  56864. };
  56865. interface WebGLSampler extends WebGLObject {
  56866. }
  56867. declare var WebGLSampler: {
  56868. prototype: WebGLSampler;
  56869. new(): WebGLSampler;
  56870. };
  56871. interface WebGLSync extends WebGLObject {
  56872. }
  56873. declare var WebGLSync: {
  56874. prototype: WebGLSync;
  56875. new(): WebGLSync;
  56876. };
  56877. interface WebGLTransformFeedback extends WebGLObject {
  56878. }
  56879. declare var WebGLTransformFeedback: {
  56880. prototype: WebGLTransformFeedback;
  56881. new(): WebGLTransformFeedback;
  56882. };
  56883. interface WebGLVertexArrayObject extends WebGLObject {
  56884. }
  56885. declare var WebGLVertexArrayObject: {
  56886. prototype: WebGLVertexArrayObject;
  56887. new(): WebGLVertexArrayObject;
  56888. };
  56889. // Type definitions for WebVR API
  56890. // Project: https://w3c.github.io/webvr/
  56891. // Definitions by: six a <https://github.com/lostfictions>
  56892. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56893. interface VRDisplay extends EventTarget {
  56894. /**
  56895. * Dictionary of capabilities describing the VRDisplay.
  56896. */
  56897. readonly capabilities: VRDisplayCapabilities;
  56898. /**
  56899. * z-depth defining the far plane of the eye view frustum
  56900. * enables mapping of values in the render target depth
  56901. * attachment to scene coordinates. Initially set to 10000.0.
  56902. */
  56903. depthFar: number;
  56904. /**
  56905. * z-depth defining the near plane of the eye view frustum
  56906. * enables mapping of values in the render target depth
  56907. * attachment to scene coordinates. Initially set to 0.01.
  56908. */
  56909. depthNear: number;
  56910. /**
  56911. * An identifier for this distinct VRDisplay. Used as an
  56912. * association point in the Gamepad API.
  56913. */
  56914. readonly displayId: number;
  56915. /**
  56916. * A display name, a user-readable name identifying it.
  56917. */
  56918. readonly displayName: string;
  56919. readonly isConnected: boolean;
  56920. readonly isPresenting: boolean;
  56921. /**
  56922. * If this VRDisplay supports room-scale experiences, the optional
  56923. * stage attribute contains details on the room-scale parameters.
  56924. */
  56925. readonly stageParameters: VRStageParameters | null;
  56926. /**
  56927. * Passing the value returned by `requestAnimationFrame` to
  56928. * `cancelAnimationFrame` will unregister the callback.
  56929. * @param handle Define the hanle of the request to cancel
  56930. */
  56931. cancelAnimationFrame(handle: number): void;
  56932. /**
  56933. * Stops presenting to the VRDisplay.
  56934. * @returns a promise to know when it stopped
  56935. */
  56936. exitPresent(): Promise<void>;
  56937. /**
  56938. * Return the current VREyeParameters for the given eye.
  56939. * @param whichEye Define the eye we want the parameter for
  56940. * @returns the eye parameters
  56941. */
  56942. getEyeParameters(whichEye: string): VREyeParameters;
  56943. /**
  56944. * Populates the passed VRFrameData with the information required to render
  56945. * the current frame.
  56946. * @param frameData Define the data structure to populate
  56947. * @returns true if ok otherwise false
  56948. */
  56949. getFrameData(frameData: VRFrameData): boolean;
  56950. /**
  56951. * Get the layers currently being presented.
  56952. * @returns the list of VR layers
  56953. */
  56954. getLayers(): VRLayer[];
  56955. /**
  56956. * Return a VRPose containing the future predicted pose of the VRDisplay
  56957. * when the current frame will be presented. The value returned will not
  56958. * change until JavaScript has returned control to the browser.
  56959. *
  56960. * The VRPose will contain the position, orientation, velocity,
  56961. * and acceleration of each of these properties.
  56962. * @returns the pose object
  56963. */
  56964. getPose(): VRPose;
  56965. /**
  56966. * Return the current instantaneous pose of the VRDisplay, with no
  56967. * prediction applied.
  56968. * @returns the current instantaneous pose
  56969. */
  56970. getImmediatePose(): VRPose;
  56971. /**
  56972. * The callback passed to `requestAnimationFrame` will be called
  56973. * any time a new frame should be rendered. When the VRDisplay is
  56974. * presenting the callback will be called at the native refresh
  56975. * rate of the HMD. When not presenting this function acts
  56976. * identically to how window.requestAnimationFrame acts. Content should
  56977. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56978. * asynchronously from other displays and at differing refresh rates.
  56979. * @param callback Define the eaction to run next frame
  56980. * @returns the request handle it
  56981. */
  56982. requestAnimationFrame(callback: FrameRequestCallback): number;
  56983. /**
  56984. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56985. * Repeat calls while already presenting will update the VRLayers being displayed.
  56986. * @param layers Define the list of layer to present
  56987. * @returns a promise to know when the request has been fulfilled
  56988. */
  56989. requestPresent(layers: VRLayer[]): Promise<void>;
  56990. /**
  56991. * Reset the pose for this display, treating its current position and
  56992. * orientation as the "origin/zero" values. VRPose.position,
  56993. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56994. * updated when calling resetPose(). This should be called in only
  56995. * sitting-space experiences.
  56996. */
  56997. resetPose(): void;
  56998. /**
  56999. * The VRLayer provided to the VRDisplay will be captured and presented
  57000. * in the HMD. Calling this function has the same effect on the source
  57001. * canvas as any other operation that uses its source image, and canvases
  57002. * created without preserveDrawingBuffer set to true will be cleared.
  57003. * @param pose Define the pose to submit
  57004. */
  57005. submitFrame(pose?: VRPose): void;
  57006. }
  57007. declare var VRDisplay: {
  57008. prototype: VRDisplay;
  57009. new(): VRDisplay;
  57010. };
  57011. interface VRLayer {
  57012. leftBounds?: number[] | Float32Array | null;
  57013. rightBounds?: number[] | Float32Array | null;
  57014. source?: HTMLCanvasElement | null;
  57015. }
  57016. interface VRDisplayCapabilities {
  57017. readonly canPresent: boolean;
  57018. readonly hasExternalDisplay: boolean;
  57019. readonly hasOrientation: boolean;
  57020. readonly hasPosition: boolean;
  57021. readonly maxLayers: number;
  57022. }
  57023. interface VREyeParameters {
  57024. /** @deprecated */
  57025. readonly fieldOfView: VRFieldOfView;
  57026. readonly offset: Float32Array;
  57027. readonly renderHeight: number;
  57028. readonly renderWidth: number;
  57029. }
  57030. interface VRFieldOfView {
  57031. readonly downDegrees: number;
  57032. readonly leftDegrees: number;
  57033. readonly rightDegrees: number;
  57034. readonly upDegrees: number;
  57035. }
  57036. interface VRFrameData {
  57037. readonly leftProjectionMatrix: Float32Array;
  57038. readonly leftViewMatrix: Float32Array;
  57039. readonly pose: VRPose;
  57040. readonly rightProjectionMatrix: Float32Array;
  57041. readonly rightViewMatrix: Float32Array;
  57042. readonly timestamp: number;
  57043. }
  57044. interface VRPose {
  57045. readonly angularAcceleration: Float32Array | null;
  57046. readonly angularVelocity: Float32Array | null;
  57047. readonly linearAcceleration: Float32Array | null;
  57048. readonly linearVelocity: Float32Array | null;
  57049. readonly orientation: Float32Array | null;
  57050. readonly position: Float32Array | null;
  57051. readonly timestamp: number;
  57052. }
  57053. interface VRStageParameters {
  57054. sittingToStandingTransform?: Float32Array;
  57055. sizeX?: number;
  57056. sizeY?: number;
  57057. }
  57058. interface Navigator {
  57059. getVRDisplays(): Promise<VRDisplay[]>;
  57060. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57061. }
  57062. interface Window {
  57063. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57064. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57065. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57066. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57067. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57068. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57069. }
  57070. interface Gamepad {
  57071. readonly displayId: number;
  57072. }
  57073. interface XRDevice {
  57074. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57075. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57076. }
  57077. interface XRSession {
  57078. getInputSources(): Array<any>;
  57079. baseLayer: XRWebGLLayer;
  57080. requestFrameOfReference(type: string): Promise<void>;
  57081. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57082. end(): Promise<void>;
  57083. requestAnimationFrame: Function;
  57084. addEventListener: Function;
  57085. }
  57086. interface XRSessionCreationOptions {
  57087. outputContext?: WebGLRenderingContext | null;
  57088. immersive?: boolean;
  57089. environmentIntegration?: boolean;
  57090. }
  57091. interface XRLayer {
  57092. getViewport: Function;
  57093. framebufferWidth: number;
  57094. framebufferHeight: number;
  57095. }
  57096. interface XRView {
  57097. projectionMatrix: Float32Array;
  57098. }
  57099. interface XRFrame {
  57100. getDevicePose: Function;
  57101. getInputPose: Function;
  57102. views: Array<XRView>;
  57103. baseLayer: XRLayer;
  57104. }
  57105. interface XRFrameOfReference {
  57106. }
  57107. interface XRWebGLLayer extends XRLayer {
  57108. framebuffer: WebGLFramebuffer;
  57109. }
  57110. declare var XRWebGLLayer: {
  57111. prototype: XRWebGLLayer;
  57112. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57113. };